Vilx-
Vilx-

Reputation: 106970

Problems with serializing a custom type in ASP.NET ViewState

I've got a little struct that I want to serialize in my ViewState. It looks something like this:

[Serializable]
private struct DayMoney
{
    public readonly DateTime ValidFrom;
    public readonly string CurrencyCode;
    public readonly double Amount;
}

It serializes just fine, but when I perform a postback/callback, I get an exception for deserializing it. Wrapped in a long list of InnerException's the root cause seems to be:

Unable to find assembly 'BussinessTripModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Which is kinda ridiculous, because that assembly is definately loaded in the current AppDomain.

WTF?

Upvotes: 0

Views: 823

Answers (2)

massimogentilini
massimogentilini

Reputation: 4172

This kind of problems is very difficult to diagnose.

My suggestion is to use the Fusion Log Viewer to diagnose why your particular assembly is not found. Keep in mind that some specific options of Fuslogvw that are not so easy to setup, luckily google can help you a lot.

But, to start... make your structure public, as someone else said!!!

Upvotes: 2

blowdart
blowdart

Reputation: 56530

Your struct is private. Deserialisation happens in the framework itself, not in your assembly. It's probably that's the problem, make it public and see if that solves it

Upvotes: 1

Related Questions