tags:

views:

20

answers:

2

I have a .NET 3.5 MVC2 web app that runs fine from Visual Studio 2008 but when I publish to a remote site, I get an error in a certain function.

Any idea what I should be looking for here?

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.
+1  A: 

Well.. is your exception class marked as serializable?

James
No it's not, it's in a 3rd party dll. It works fine when running in VS (exceptions are thrown as per normal), which I don't understand. I have checked through the source code and nowhere does it attempt to serialize the Exception. So I'm not sure how this error is caused?
Pete
A: 

Aop is right, you have to put [Serializable()] before your class. This tells the compiler this class can be serialized.

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

More info about attributes and serialization :

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

Run CMD