Content:
1. Problem Introduction
2. Problem Solving
3. Cause Analysis
Recently, the development environment of the Department has been updated to WIN7 +. NET framework4 + VS2010, while experiencing new technologies and new environments, it brings us ways and means to improve efficiency, but also brings some compatibility issues. During the past few days, the project is studying SQLite in its spare time, during the experiment, I encountered a problem. When the code was compiled and executed, it was repeatedly interrupted due to an exception. It was found that SQLite was used later. the dll is compiled in the framework2.0 environment, and the current runtime environment is framework4.0. Therefore, a running exception occurs ,:
Some third-party components may be referenced in the future development process, and may be compiled in the old framework version, therefore, this article provides a solution and explains the cause of this problem.
After reading the relevant information, we recommend that you add the configuration in the config file on stackoverflow.com:
1 <startup useLegacyV2RuntimeActivationPolicy = "true">
2 <supportedRuntime version = "v4.0"/>
3 </startup>
This method is also described on MSDN, see http://msdn.microsoft.com/en-us/library/bbx34a2h (VS.100). aspx
However, the problem still persists after compilation using this method, but the problem can be clearly locked to the. net runtime environment.
1 <startup useLegacyV2RuntimeActivationPolicy = "true">
2 <supportedRuntime version = "v4.0"/>
3 <requiredRuntime version = "v4.0.30319"/>
4 </startup>
Run again to solve the problem. What is the cause?
The supportedRuntime label is used to specify the. framework runtime version that the application supports;
The requiredRuntime label specifies that the application only supports the runtime of the public language version 1.0. If you use version 1.1 or later, the application must use the <supportedRuntime> element;
Note:
<SupportedRuntime> must be used by applications compiled with version 1.1 or later. <RequiredRuntime> is required for applications that only support the running time of version 1.0.
Check the relevant information of the CLR Runtime version again and reference the following table showing the relations between the CLR running rules and versions:
Rules:
1. Applications compiled by CLR4.0 and later always run on the CLR version compiled by the application;
2. Applications compiled in versions earlier than CLR4.0 are preferentially run on the compiled CLR version. If this version does not exist, the latest version earlier than CLR4.0 is run;
Summary:
EXECompiledCLRVersion Number |
Install CLR 1.1 on the machine? |
Is CLR 2.0 installed on the machine? |
Is CLR 4.0 installed on the machine? |
Result |
1.1 |
Yes |
No |
No |
Load CLR 1.1 |
2.0 |
No |
Yes |
No |
Load CLR 2.0 |
1.1 |
No |
Yes |
No |
Load CLR 2.0 |
1.1 |
No |
No |
Yes |
Failed |
2.0 |
No |
No |
Yes |
Failed |
So far, we can clearly figure out the connection between each CLR version.
Summary:
Each version upgrade of Microsoft may cause some new problems. In the early years, from CLRv1.0 to CLRv2.0 also caused a lot of confusion. It may also be because too many organizations cannot cover all aspects, we hope that we can achieve seamless version connection in future version upgrades.
Thanks:
In this article, the analysis of the CLR version references the relationship between versions summarized by Dr. Zhang from the Microsoft net 4.0 team. Thank you for your support.
When reprinting, please indicate the source of this article: www.cnblogs.com/tmywu
Author: taomi tribe
E-mail: tommywu23@gmail.com