Force CLR Version
-
My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.
Did you reference any other assemblies from the 4.0 framework? What framework is the solution targetting? (See project properties page)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
-
Did you reference any other assemblies from the 4.0 framework? What framework is the solution targetting? (See project properties page)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
-
My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.
Try running it on a machine with no net 4.0 installed.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch
-
Try running it on a machine with no net 4.0 installed.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch
Thank you for the reply. I have tried with 3.5 ramework still same issue. The actual problem is I am using axcepta 2.0 version dll in .net 2.0 version which is finally using by java application. This works fine with any .net app. But When it goes to java the .net 2.0 dll is running with 4.0CLR there i am getting the Mixed mode assembly reference issue.
-
My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.
Have you tried adding a
supportedRunTime
element to the application's configuration file? See http://msdn.microsoft.com/en-us/library/w4atty68(v=vs.80).aspx[^] I can't tell from the documentation if this would force a particular version of the CLR to load, but it would be worth doing an experiment to find out. Alan -
My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.
You cannot force a .DLL to use a specific CLR version. The code will run under whatever the CLR version the .EXE is using. .DLL's are loaded into the process the same as any other code in the .EXE. If you want to change which version of the CLR the code uses, you have to specify that in the application manifest file. How to: Configure an Application to Target a .NET Framework Version[^]
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
You cannot force a .DLL to use a specific CLR version. The code will run under whatever the CLR version the .EXE is using. .DLL's are loaded into the process the same as any other code in the .EXE. If you want to change which version of the CLR the code uses, you have to specify that in the application manifest file. How to: Configure an Application to Target a .NET Framework Version[^]
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Have you tried adding a
supportedRunTime
element to the application's configuration file? See http://msdn.microsoft.com/en-us/library/w4atty68(v=vs.80).aspx[^] I can't tell from the documentation if this would force a particular version of the CLR to load, but it would be worth doing an experiment to find out. Alan -
0905v49 wrote:
No am not using any assemblies from 4.0 framework and it is targetting to 2.0 framework.
Then your assembly will work on .NET 2.0 (and up!); which runtime it uses depends on the app that consumes the assembly, and all it's references. I do not see a problem with it running on CLR 4.0. Do you?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
-
Do you mean app.config file? Even though I specify in app.config but my deliverable is only dll so it dnt work out for me.
Sorry, yes, app.config. config files only work with .EXE's. You cannot make an app.config for a .DLL file. The .DLL is loaded as part of the .EXE as if it was in the same file as the .EXE. That's why config's only work with .EXE's and not .DLL's. If you want your .DLL to run with a certain CLR version, the .EXE that's loading it ALSO has to run with that CLR version.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Sorry, yes, app.config. config files only work with .EXE's. You cannot make an app.config for a .DLL file. The .DLL is loaded as part of the .EXE as if it was in the same file as the .EXE. That's why config's only work with .EXE's and not .DLL's. If you want your .DLL to run with a certain CLR version, the .EXE that's loading it ALSO has to run with that CLR version.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Hi Dave, I have to creat only class library which is using in JNI(java). So I have specify target version through my class library code. Is there any way to do this.
Again, no. The only way to do that is to specify it in the app.config of the HOST .EXE that is loading your .DLL. Why can't your .DLL run under the .NET 4.0 CLR??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Again, no. The only way to do that is to specify it in the app.config of the HOST .EXE that is loading your .DLL. Why can't your .DLL run under the .NET 4.0 CLR??
A guide to posting questions on CodeProject[^]
Dave KreskowiakI am using Microsoft.Dynamics.BusinessConnectorNet with this which is compiled in 2.0 version. My dll works fine in .net environment where i can set supportedruntime in appconfig. But when dll goes to JNI it is running under the latest .net framework i.e 4.0 installed in that system and giving the mixed mode assembly exception .
-
Again, no. The only way to do that is to specify it in the app.config of the HOST .EXE that is loading your .DLL. Why can't your .DLL run under the .NET 4.0 CLR??
A guide to posting questions on CodeProject[^]
Dave KreskowiakI am using Microsoft.Dynamics.BusinessConnectorNet with this which is compiled in 2.0 version.
My dll works fine in .net environment where i can set supportedruntime in appconfig.
But when dll goes to JNI it is running under the latest .net framework i.e 4.0 installed in that system and giving the mixed mode assembly exception . -
I am using Microsoft.Dynamics.BusinessConnectorNet with this which is compiled in 2.0 version. My dll works fine in .net environment where i can set supportedruntime in appconfig. But when dll goes to JNI it is running under the latest .net framework i.e 4.0 installed in that system and giving the mixed mode assembly exception .
Well, we've told you the only way to do it, and you've even said that you've tried it and it works ("supportedruntime in appconfig"). The only other option you have to to get an updated Dynamics library and compile a second version of your .DLL that works with the .NET 4.0 CLR.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak