且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用C#执行.sql脚本

更新时间:2023-01-23 10:07:25

^ ]由 ^ ]:

为了使用CLR 2.0混合模式程序集,您需要修改App.Config文件以包括:
Solution found on SO[^] written by Reed Copsey[^]:

In order to use a CLR 2.0 mixed mode assembly, you need to modify your App.Config file to include:
<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>


关键是useLegacyV2RuntimeActivationPolicy标志.这将导致CLR使用最新版本(4.0)来加载您的混合模式程序集.没有这个,它将无法工作.

请注意,这仅对混合模式(C ++/CLI)程序集有效.您可以加载所有托管的CLR 2程序集,而无需在app.config中指定.


干杯!


The key is the useLegacyV2RuntimeActivationPolicy flag. This causes the CLR to use the latest version (4.0) to load your mixed mode assembly. Without this, it will not work.

Note that this only matters for mixed mode (C++/CLI) assemblies. You can load all managed CLR 2 assemblies without specifying this in app.config.


Cheers!