injecting a line of code to top of class by reading dll file and injecting in to it reg RRS feed

  • Question

  • Hi,

    I have made a .NET class library in C# that initializes some logging with aop concepts using postsharp , sent to an external tool. The library is altogether separate from any application, but in order to initialize it, I need to make at least one method call to it.

    Is there a way for me to put something into app.config that will auto-load that dll, and call call the class file and inject what ever i send to it? I can change the contents to suit whatever, I don't need to support any own class name or method name or whatnot.

    Note, I need this to be done without any changes to the application in question, save for changing the app.config file.

    Is this possible? If so, what should I be looking at?

    Can I use your method to intercept messages of one application and route them to the same application running on another machine? And any hints on how to ensure these messages correctly handled?

    Monday, May 28, 2012 5:27 AM


All replies

  • I have a question for you.  Do you plan to deplay this software package to more than one computer?  How do you plan to put the dll on other computers?

    My recommendations is to put the dll in the build folder and add it to your project as an existing object.  Then it will automactially get installed on other computers when you Publish your application.


    Monday, May 28, 2012 11:08 AM
  • jdweng,

    I too have checked like that like creating a separate intercept using postsharp in seperate class file and build it der by adding that dll to my project but problem is trace attribute does not works

    my code is

    using testpostsharp;                                 // it is the name space for created  dll with postsharp

    [assembly: Trace(AttributeTargetTypes = "testpostsharp.Class1")]      // it is trace attribute listed in other project




    Monday, May 28, 2012 11:29 AM
  • Have you followed all these steps?


    Monday, May 28, 2012 11:48 AM