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();
}
"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();
}