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 / CLR / October 2005

Tip: Looking for answers? Try searching our database.

Creating dynamic assemblies - almost there

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rein.petersen@gmail.com - 17 Oct 2005 14:39 GMT
Hi All,

I've been working on having my application create dynamic assemblies
within the current domain of the application and loading them at a
later point inside new domains (so they can be unloaded as necessary)
and I feel I'm almost there thanks to great help from people in the
dotnet newsgroups.

I have, however, reached another impasse which is probably very simple
to solve but I'm just not seeing it. I'll try to explain:

My dynamic assemblies have types defined (TypeBuilder) which must
inherit from (early-bound) types already defined in the current domain.
Cracking open one of my dll's in ILDASM reveals that, in fact, the
dynamic types extend the types intended but I can't help thinking that
I should probably have some references to the appropriate assemblies to
actually make those extensions work.

I haven't been able to locate methods on either
System.Reflection.Emit.AssemblyBuilder or
System.Reflection.Emit.TypeBuilder that would allow you to add
references and am confused as to why I am  missing this.

*All* suggestions are greatly appreciated :)

Thanks, Rein
Nick Hertl - 18 Oct 2005 16:25 GMT
With Reflection.Emit, you don't needto "reference" assemblies that are
already loaded because you already have them.

For example, let's say you had a type in one.dll and a type in two.dll.
A type in two.dll extends a type in one.dll.  In order to compile
these using the C# compiler, you need to first do "csc /target:library
one.cs" and then "csc /target:library /r:one.dll two.cs"

However, if you want to use Reflection emit to create this "two"
assembly with a type that extends a type in one.dll, you can just load
make sure that one.dll is loaded, and if it's not, load it.  Then use
the overload of ModuleBuilder.DefineType that takes a Type argument.
There are many ways to get that type from one.dll, but start with
Assembly.GetType(string) on the assembly that you know has that type in
it.

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.