Reputation: 194
I have a web-site project that I needed to convert to web-application. After I resolved all the compilation errors I hit a runtime exception in a piece of code I got from Telerik's website.
In the part where I de-serialize the grid settings data I get an exception
System.ArgumentException
HResult=0x80070057
Message=The serialized data is invalid.
Source=BMS.WebApp
Inner Exception 1:
SerializationException: Unable to find assembly 'App_Code.5gd62bdt, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
public static GridSettingsCollection LoadFromSerializedData(string data)
{
LosFormatter formatter = new LosFormatter();
// the line that throws the exception: formatter.Deserialize(data)
return (GridSettingsCollection)formatter.Deserialize(data);
}
This works no problem when it was a Web-Site project. I am guessing assemblies that start with an App_Code.* usually means that it is compiling at runtime. I tried clearing all the ASP temp folders.
Any help is greatly appreciated. Thanks.
Upvotes: 0
Views: 83
Reputation: 88
It's not a problem with Telerik itself but with serialization in general. GridSettingsCollection
from Telerik's example uses [Serializable]
attribute which in turn uses BinaryFormatter
for serialization. Beside the binary object data it also stores the serialized object's class metadata including assembly name.
If you change the assembly name (which happened when you converted the Web Site to Web Application) and you still need to use old serialized data, you have to use SerializationBinder
as in this answer.
Upvotes: 1