Cannot CreateInstance of Assembly after loading it with Assembly.Load(byte[])

  • Thread starter Thread starter Dmitriy Krasnikov
  • Start date Start date
D

Dmitriy Krasnikov

Hi everybody. It's probably something easy, but stops me dead on
tracks.
I have no problem CreateInstance or InvokeMember on constructor when I
am loading assembly using Assembly.LoadFile.
But if I use Assembly.Load(byte[]), I cannot Invoke constructor,
cannot Activator.CreateInstance - it gives be error "Exception were
thrown by target".
Please help.
 
<Dmitriy Krasnikov <dmitriykrasnikov.remove this its for
Hi everybody. It's probably something easy, but stops me dead on
tracks.
I have no problem CreateInstance or InvokeMember on constructor when I
am loading assembly using Assembly.LoadFile.
But if I use Assembly.Load(byte[]), I cannot Invoke constructor,
cannot Activator.CreateInstance - it gives be error "Exception were
thrown by target".
Please help.

Well the first thing to do is see what exception has been thrown - look
at the InnerException property.
 
<Dmitriy Krasnikov <dmitriykrasnikov.remove this its for
Hi everybody. It's probably something easy, but stops me dead on
tracks.
I have no problem CreateInstance or InvokeMember on constructor when I
am loading assembly using Assembly.LoadFile.
But if I use Assembly.Load(byte[]), I cannot Invoke constructor,
cannot Activator.CreateInstance - it gives be error "Exception were
thrown by target".
Please help.

Well the first thing to do is see what exception has been thrown - look
at the InnerException property.

Thank you. It gave more meaningfull message.
"Unable to generate a serializer for type wst.SqlMessage from assembly
<Unknown> because the assembly may be dynamic. Save the assembly and
load it from disk to use it with XmlSerialization."
Any workarounds possible? The problem is, if I load it from disk I
cannot delete it later and generate new.
 
<Dmitriy Krasnikov <dmitriykrasnikov.remove this its for
Thank you. It gave more meaningfull message.
"Unable to generate a serializer for type wst.SqlMessage from assembly
<Unknown> because the assembly may be dynamic. Save the assembly and
load it from disk to use it with XmlSerialization."
Any workarounds possible? The problem is, if I load it from disk I
cannot delete it later and generate new.

I'm afraid I don't know - I haven't done much with serialisation.
 
Back
Top