all groups > dotnet interop > october 2005 >
You're in the

dotnet interop

group:

CompiledAssembly.CreateInstance returns nothing



Re: CompiledAssembly.CreateInstance returns nothing Robert Jordan
10/20/2005 12:00:00 AM
dotnet interop: Eric,

[quoted text, click to view]

Check the Errors property of the compiler object to see
whether the assembly has been generated at all.

Re: CompiledAssembly.CreateInstance returns nothing Robert Jordan
10/20/2005 12:00:00 AM
Eric,

[quoted text, click to view]

Check the class name. It should include the name space as well.
Does the class have a public ctor?

Rob


[quoted text, click to view]
Re: CompiledAssembly.CreateInstance returns nothing Robert Jordan
10/20/2005 12:00:00 AM
Eric,

[quoted text, click to view]

What do you mean with "through interop". CreateInstance is actually
reflection.

Rob


[quoted text, click to view]
CompiledAssembly.CreateInstance returns nothing Eric
10/20/2005 8:02:08 AM
I have a .Net class in a dll that compiles code on the fly. Everything is
working great from all .Net applications. I'm now trying to make this class
Interopable. I don't receive any erros after calling
CompileAssemblyFromSource but when I try to create a instance of my class
(CompiledAssembly.CreateInstance(targetClassName)) I get a null value
returned. No exceptions or other errors are reported. Has anyone tried
compiling code on the fly in an Interop class? I'm starting to think maybe
it's a security issue but I thought I would have gotten an exception. This
one has caused me problems for days.

Thanks,

Eric

Re: CompiledAssembly.CreateInstance returns nothing Eric
10/20/2005 9:09:10 AM
Rob,

The Compiler.Errors.Count = 0. I also checked the temp diectory an a dll
is created. Is there anything else I should check?

Thanks,

Eric


[quoted text, click to view]

Re: CompiledAssembly.CreateInstance returns nothing Eric
10/20/2005 9:42:48 AM
Rob,

The classname is prefixed with the full namepsace. This class does have a
public constructor with no parameters. This all works if I call it from
another .Net application so I'm pretty sure I'm compiling and creating the
Instance correctly. I'm just having problems when I go through interop.

Thanks,

Eric



[quoted text, click to view]
Re: CompiledAssembly.CreateInstance returns nothing Eric
10/20/2005 10:06:54 AM
Rob,

You are right about the reflection. When I say through Interop I mean how
my class is actual called. I have a .Net dll with a very simple class that
is setup for interop. The simple class internal uses reflection to create a
class from a string to use for some calculations and returns a result. This
is where my problems comes in. The CreateInstance always returns null.
Hopefully I've cleared up the confusion.


Thanks,

Eric


[quoted text, click to view]

Re: CompiledAssembly.CreateInstance returns nothing Eric
10/20/2005 11:36:07 AM
Heres some more information. Original I had GenerateInMemory = true; when
compiling. I changed this to false so that I could look into the dll and it
started to work. Does anyone know why this would work now? I would really
like to get it back in memory if possible.

Thanks,

Eric



[quoted text, click to view]

AddThis Social Bookmark Button