Programmatically specify which version of .NET to load

My application is a native, non-.NET application. However, at times it may need to invoke some .NET services through COM. Sometimes it needs to load a specific version of .NET to accomplish what it needs to do. (My app uses a COM interface to System.EnterpriseServices in order to programmatically register assemblies and install them in the GAC).

Normally, I could use MyApp.exe.config (as explained here) if this information was known ahead of time and didn't change between runs.

Unfortunately, the specific version of .NET to load will not be known until runtime (and in fact, may change between runs on the same system). Therefore using MyApp.exe.config will not work.

Is there a way for a native application to supply this information to Windows programmatically before it loads .NET?

(Though my application is written in Delphi, this is more of a general Windows question and answers in any language would be welcome)

Answers


You will have to write your own CLR host, instead of relying on the IJW "it just works" .NET feature.

If .NET 4 is installed on the machine, this link describes how to do it: Loading the Common Language Runtime into a Process. With .NET 4, you can even load multiple versions of the CLR side by side in the same process (with restrictions though).

Additional information: Use CLR4 Hosting API to invoke .NET assembly from native C++


Need Your Help

Websocket SSL handshake failure

tomcat ssl websocket android-5.0-lollipop tyrus

I have spring-boot Tomcat server for secure websocket connections. The server accepts Android 4.4, iOS, Firefox, and Chrome clients without failure with an authority-signed certificate. Android 5.0,

QT-Graphics - How to constrain the item's movement

c++ user-interface qt

I am doing a picture mingling project using QGraphics Scene. So I am placing the pictures inside the QGraphicsscene as QgraphicspixmapItem. But the problem is when I am moving the itm(by mouse drag...