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 / June 2006

Tip: Looking for answers? Try searching our database.

Generating IL code, running, changing, running again ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rickard - 13 Jun 2006 13:52 GMT
I have written a small program that generates a dynamic assembly using
Reflection.Emit and adding IL code to it using ILGenerator.

Now, if I call CreateType() on my TypeBuilder object, the assembly
becomes locked. I want to be able to change the IL code afterwards.
It is important that I can not create new assemblies all the time
because this is going to be done a large number of times. Is it possible
to e.g. refer to a byte array where the IL code is, and allow this to be
changed dynamically?

It seems the only way to constantly change IL code is to use application
domains and create new assemblies all the time. The overhead of this is
way too large to be useful in my case. (I'm going to change the code
thousands of times over or even more).

Any suggestions are appreciated on this matter.
Barry Kelly - 13 Jun 2006 14:22 GMT
> I have written a small program that generates a dynamic assembly using
> Reflection.Emit and adding IL code to it using ILGenerator.
[quoted text clipped - 5 lines]
> to e.g. refer to a byte array where the IL code is, and allow this to be
> changed dynamically?

Another way is to use DynamicMethod (in .NET 2.0) instead, if you can
(and with a little persuasion and cleverness with supplying the "target"
parameter to DynamicMethod.CreateDelegate, you can get it to do most
things.)

-- Barry

Signature

http://barrkel.blogspot.com/

Rickard - 14 Jun 2006 10:12 GMT
This seems to be what I was looking for. Thank you.

>> I have written a small program that generates a dynamic assembly using
>> Reflection.Emit and adding IL code to it using ILGenerator.
[quoted text clipped - 12 lines]
>
> -- Barry

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.