"Insufficient state to deserialize the object. More information is needed." AppDomain Load

S

Sean McKaharay

I am using the code below and I am getting this error:
"Insufficient state to deserialize the object. More information is needed."
Has anyone seen this? It is working with other dll's but not on a certain
one. Can some help?




private void LoadAssembly(string DllLocationDirectory, string
applicationName, bool shadowCopyFiles, string friendlyName, string dllName,
string className)
{
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = DllLocationDirectory;
setup.ApplicationName = applicationName;
setup.ShadowCopyFiles = shadowCopyFiles.ToString();
setup.ShadowCopyDirectories = DllLocationDirectory;

this._AppDomain = AppDomain.CreateDomain(friendlyName, null, setup);

SetAppDomainPolicy(_AppDomain);

byte[] AssemblyBtyes = this.LoadAssemblyBytes(DllLocationDirectory +
dllName);
Assembly asm = this._AppDomain.Load(AssemblyBtyes);
this._ClassLoaded = asm.CreateInstance(className);
}

private byte[] LoadAssemblyBytes(string filename)
{
FileStream fin = new FileStream(filename, FileMode.Open,FileAccess.Read);
byte[] bin = new byte[16384];
long rdlen = 0;
long total= fin.Length;
int len;
MemoryStream memStream = new MemoryStream((int)total);
rdlen = 0;
while(rdlen < total)
{
len = fin.Read(bin, 0, 16384);
memStream.Write(bin, 0, len);
rdlen = rdlen + len;
}
// done with input file
fin.Close();
return memStream.ToArray();
}
 
F

Frans Bouma [C# MVP]

Sean said:
I am using the code below and I am getting this error:
"Insufficient state to deserialize the object. More information is needed."
Has anyone seen this? It is working with other dll's but not on a certain
one. Can some help?


This error is caused because it can't load a particular assembly. Make sure
the assembly is findable, for example by placing it into the GAC or the
program directory of the .exe which is doing the deserialization.

Frans.
 
N

Nicholas Paldino [.NET/C# MVP]

Sean,

Can you give all the Exception information (call stack, message, etc,
etc), as well as the line it occurs on?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top