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 2003

Tip: Looking for answers? Try searching our database.

Code injection. Is it possible using codeDom?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marco - 09 Oct 2003 09:41 GMT
Hi all,
      I want to extend a class in a dll without having the code for
it. Is it possible using codeDom? I still didn't studied codeDom and
I've just an idea of it but I'm wondering if it's possible to
construct a CodeDom Graph from an existing assembly, take a reference
to a class contained in the Graph, adding a property to the class and
then recompiling it.

Thank you
Marco Paci
Gabriele G. Ponti - 09 Oct 2003 14:02 GMT
Marco,

There is an article on the September 2003 issue of MSDN Magazine that could
be an interesting reading for your project.

From the article summary: "In this article, the author shows how to
dynamically rewrite Microsoft Intermediate Language code on the fly using
the Profiling API of the CLR. Unlike approaches based on Reflection.Emit,
this scheme works with the existing assemblies and doesn't require the
creation of proxy or dynamic assemblies. The needs for IL code rewriting
emerges when you want to make your changes transparent to the client and
preserve the identity of classes. This technique can be used for creation of
interceptors, pre- and post-processing method calls, and code
instrumentation and verification."

Rewrite MSIL Code on the Fly with the .NET Framework Profiling API
http://msdn.microsoft.com/msdnmag/issues/03/09/NETProfilingAPI/default.aspx

Regards,

   Gabriele

> Hi all,
>        I want to extend a class in a dll without having the code for
[quoted text clipped - 6 lines]
> Thank you
> Marco Paci
Dino Chiesa [Microsoft] - 09 Oct 2003 22:53 GMT
Here's an example that uses CodeDom to create a wrapper class, on the fly.
The wrapper converts fields in the original type to Properties on the
wrapper type.

http://www.winisp.net/cheeso/srcview.aspx?file=MorphArray.cs

Signature

Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m

> Marco,
>
[quoted text clipped - 12 lines]
>
> Rewrite MSIL Code on the Fly with the .NET Framework Profiling API

http://msdn.microsoft.com/msdnmag/issues/03/09/NETProfilingAPI/default.aspx

> Regards,
>
[quoted text clipped - 10 lines]
> > Thank you
> > Marco Paci
Nick - 15 Oct 2003 14:10 GMT
You dont need codedom if you want to "extend a class" all
you have to do is add a referance to the assembly. Then
you can extend any non-sealed class in that assembly just
as you would extend a class in your assembly. Perhaps you
already knew this and need codedom for other reasons, but
I figured I'd tell you just in case.

Nick

>-----Original Message-----
>Hi all,
[quoted text clipped - 8 lines]
>Marco Paci
>.

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.