类型'Tamir.SharpSsh.jsch.JSchException'未标记为可序列化

时间:2010-08-24 13:21:11

标签: c# .net-3.5

我有一个从Visual Studio 2008运行良好的.NET 3.5 MVC2 Web应用程序但是当我发布到远程站点时,我在某个功能中出错。

知道我应该在这里寻找什么吗?

Event Type: Error
Event Source:   ASP.NET 2.0.50727.0
Event Category: None
Event ID:   1334
Date:       24/08/2010
Time:       13:58:55
User:       N/A
Computer:   MSVSC01-G124NW
Description:
An unhandled exception occurred and the process was terminated.

Application ID: DefaultDomain

Process ID: 17048

Exception: System.Runtime.Serialization.SerializationException

Message: Type 'Tamir.SharpSsh.jsch.JSchException' in Assembly 'Tamir.SharpSSH, Version=1.1.1.13, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

StackTrace:    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject(Object obj, MemoryStream stm)
   at System.AppDomain.Serialize(Object o)
   at System.AppDomain.MarshalObject(Object o)


For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

3 个答案:

答案 0 :(得分:1)

那么..你的异常类是否标记为可序列化?

答案 1 :(得分:0)

Aop是对的,你必须在课前放置[Serializable()]。这告诉编译器这个类可以被序列化。

[Serializable()]        
public class TestSimpleObject  { ... }

有关属性和序列化的更多信息:

http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=94

http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx

http://msdn.microsoft.com/en-us/library/system.serializableattribute(VS.71).aspx

答案 2 :(得分:0)

您是否在另一个可序列化的类的成员中使用该类?如果是这样,您可能需要将这些属性添加到该变量

[XmlIgnore][field: NonSerialized]   private JSch                _jsch

我希望有帮助