Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2005

Tip: Looking for answers? Try searching our database.

CompiledAssembly.CreateInstance returns nothing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric - 20 Oct 2005 13:02 GMT
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
Robert Jordan - 20 Oct 2005 13:08 GMT
Eric,

> 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
[quoted text clipped - 5 lines]
> it's a security issue but I thought I would have gotten an exception.  This
> one has caused me problems for days.

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

Rob
Eric - 20 Oct 2005 14:09 GMT
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

> Eric,
>
[quoted text clipped - 12 lines]
>
> Rob
Robert Jordan - 20 Oct 2005 14:29 GMT
Eric,

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

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

Rob

> Thanks,
>
[quoted text clipped - 16 lines]
>>
>>Rob
Eric - 20 Oct 2005 14:42 GMT
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

> Eric,
>
[quoted text clipped - 26 lines]
>>>
>>>Rob
Robert Jordan - 20 Oct 2005 14:50 GMT
Eric,

>   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.

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

Rob

> Thanks,
>
[quoted text clipped - 30 lines]
>>>>
>>>>Rob
Eric - 20 Oct 2005 15:06 GMT
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

> Eric,
>
[quoted text clipped - 44 lines]
>>>>>
>>>>>Rob
Eric - 20 Oct 2005 16:36 GMT
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

>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
[quoted text clipped - 9 lines]
>
> Eric

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.