Is it possible to "inject" a .NET dll into another .NET application, by way of app.config perhaps? -


I have created a .NET class library in C #, which initializes some logging, is sent to the external device. The library is completely separate from any application, but to get it started, I need to call it at least one method.

Do I have to put something in app.config that automatically loads that dll, and says something in it? Whatever content I can change to suit, I do not have to support any class name or method name or whatnot.

Note, I need this to be done without any changes in any application, save to replace App.config file.

Is this possible? If so, what should I look like?

This was a surprise to me for a while, how to do it. I originally thought that it could be achieved by creating a custom WebProxy that will configure logging, and using the configuration element it will load it in the main application. Although it is suffering from the same problem in other configuration suggestions, when required code (only when an HTTP request is used) - thus requiring a change in the original application.

I have achieved this by leaving behind the perspective, rather than trying to get the original app to configure logging, you can write a stub of the application that configures logging And then launches the original app.

As an example:

I have a WinForms application that has been named Forms.exe Point is defined:

  [STAThread] Internal static zero main () {application. Play (New Mainform ()); }  

In my stub application (which I have as a console application), I configure logging and then load and run Forms.exe I:

Internal Stable Zero Main () {Configurable Laging () Assembly App = Assembly.load (@ "... Formss.exe"); App.EntryPoint.Invoke (empty, zero); }

This uses reflection to load other applications that configure logging.

Alerts:

  • There should be a net application to load other applications in this way
  • To find the right logic to pass, you may have to use the reflector to inspect the other application (i.e. if it takes string [] argues , then you get to Null instead of empty string [] might be required to logic)
  • Original applications The console of the console will hang around the window, while the other application runs (this is probably not a problem, but if you can try to hide it)

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -