ICLRRuntimeInfo into my dll - possible? - c#

I have a mixed mode 2.0 dll, and a 4.0 dll. I want to supply this
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
to my dll. Without an app.config (or changing machine.config) is this even possible?

You cannot supply this information just for single assembly - the entire application will be executed either on top of 2.0 or 4.0 runtime host.
If the question is how to support v2.0 and v4.0 in application without app.config - see Embedding supportedRuntime into exe file

Related

Get Rid of Basic App.config File In .Net 4.8 Application [duplicate]

I have a WinForms app that should be really easy to deploy with just and .exe file. It uses framework 2.0, and so it does not work on Windows 8 by default. If I include a .config file with the following parameters, it works fine on W8:
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
However, now I have to deploy two files and this is not acceptable. Is there some thing I can do to "embed" those parameters into the exe itself?
I have tried using WinZip self extractor, but it's not an option either, because I cannot customize its interface.
.NET executable contains small piece of native code, which is intended to load appropriate CLR version into a process.
Loader calls shim (MSCOREE.DLL, .NET executable has native dependency from this DLL) to load CLR (CLRCreateInstance in v4).
Content of <startup> configuration element is processed by the shim.
This means, you can't process <startup> element in managed code, because there's no CLR (and any managed code) at this moment. The only way is to write your own CLR host. I think, it is much easier to ship your application with config file, or build a version for .NET 4/4.5.

Exception with crystal reports

I am developing application which uses SAP Crystal Reports for reporting with Visual Studio 2013 Professional.
I downloaded and install package from SAP site, install that. Report is prepared using wizard (this works correctly). Problem is if I following step in source code:
myCrystalReport.SetDataSource(myDataSet);
myDataSet is filled with required data. Displayed error is:
An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll
Additional information: Could not load file or assembly
'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports
for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI
4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies.
During installation folder dotnet1 were not created. There is only folder dotnet.
Do somebody know how can be this problem resolved?
Thank you.
I had the exact same problem. My solution was to add this xml to the app.config file inside the <configuration> level:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
See also:
CRVS2010- crdb_adoplus.dll not found
Could not load file or assembly crdb_adoplus.dll
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>
</configuration>
Due to mixed mode assemblies has changed this problem will occur so it is recommended to you use above code into app.config file.
you have use below code in app.config and also have to set .net profile 4 client to .net profile 4 or 4.5 in project property.
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
All above solution not working in my project and application goes in break mode. i solve this problem by adding following lines in app.config inside the configuration.
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>

Can I specify supportedRuntime (or any other config parameter) without a .config file in .net?

I have a WinForms app that should be really easy to deploy with just and .exe file. It uses framework 2.0, and so it does not work on Windows 8 by default. If I include a .config file with the following parameters, it works fine on W8:
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
However, now I have to deploy two files and this is not acceptable. Is there some thing I can do to "embed" those parameters into the exe itself?
I have tried using WinZip self extractor, but it's not an option either, because I cannot customize its interface.
.NET executable contains small piece of native code, which is intended to load appropriate CLR version into a process.
Loader calls shim (MSCOREE.DLL, .NET executable has native dependency from this DLL) to load CLR (CLRCreateInstance in v4).
Content of <startup> configuration element is processed by the shim.
This means, you can't process <startup> element in managed code, because there's no CLR (and any managed code) at this moment. The only way is to write your own CLR host. I think, it is much easier to ship your application with config file, or build a version for .NET 4/4.5.

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime

I got this exception after runing an execuable in command line execution:
"Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."
After search this issue on internet, I found one of the way out is to configure App.Config file.
That works fine in VS2010 but still generates same error in command mode.
So is there any way to resolve this by using command line as generating newer version of .dll is impossible.
Thanks!
You can also try useLegacyV2RuntimeActivationPolicy="true"
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
Make sure you have configured both the App.config and the ProgramName.exe.config file.
For example:
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
Another solution can be to recompile all mixed(C++/CLI) assemblies you are dependent on for .NET 4.0. It is often not possible if these assemblies are third party.

FileLoadException with .NET 4

I'm trying to build an application using the OpenNURBS toolkit (see here) and I'm getting a FileLoadException with the following message while debugging:
Mixed mode assembly is built against
version 'v2.0.50727' of the runtime
and cannot be loaded in the 4.0
runtime without additional
configuration information.
The OpenNURBS toolkit is the only non-System assembly in the project at this point, so I know the problem is with that file. Where and what are these supposed configuration options? Any help would be appreciated.
You need to add the following config to the app.config file:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
For details:
<startup> Element # MSDN

Categories