AutoCAD 2020 removed useLegacyV2RuntimeActivationPolicy in acad.exe.config

AutoCAD 2020 removed useLegacyV2RuntimeActivationPolicy in acad.exe.config

hierholzer
Participant Participant
1,264 Views
2 Replies
Message 1 of 3

AutoCAD 2020 removed useLegacyV2RuntimeActivationPolicy in acad.exe.config

hierholzer
Participant
Participant

Hello,

 

I noticed an System.TypeInitializationException in one of our dlls from our AutoCAD extension.

 

The error message is:

 

TypeInitializationException: The type initializer for 'xxx' threw an exception. 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.

 

I found out that the entry

 

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>

 

in the acad.exe.config file has been removed with AutoCAD 2020. If I add these lines again into the acad.exe.config I get no error message and everything works like before.

 

What is the reason that this has been removed?

Can I add this entry again without causing problems?

 

Thank you for your help.

 

Best regards,

Alex

0 Likes
Accepted solutions (1)
1,265 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted solution

The reason of that <startup useLegacy.... /> being removed is the latest versions of AutoCAD .NET API are all built on .NET Framework 4.xx, which implement different code activation policies, especially the code execution security policy.

 

If your DLL is quite old (built on .NET 2.xx) and requires to use legacy policy, then you need to add that into acad.exe.config (as you already did and it worked). But you need to be aware, it might compromise AutoCAD security. In spite of the saying of "if it is not broken, do not fix it", possible security breach itself is considered "broken". So, you may want to rebuild the DLL with AutoCAD matching .NET framework (4.xx), if you have the code.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

hierholzer
Participant
Participant

Thank you very much for your help and clarification.

 

Unfortunately we don't have the code for the affected assemblies. But maybe we can obtain an updated version from the respective distributors. As long as this process runs we have to use the legacy policy in acad.exe.config.

 

Thank you once more.

 

Best regards,

Alex