在程序中,使用Microsoft.SqlServer.Management.Common空間下的ServerConnection類時,在創建它的實例時出現了如標題所示的錯誤。查找了一些資料,有人說是config文件配置有問題。在我的config文件中有如下配置:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> <requiredruntime version="v4.0.30319" /> </startup>
<configSection>
<Section name="MM" type="....."/>
</configSection>
<MM>
<any name="ss"/>
</MM>
如果把這段配置去掉就可以正確創建ServerConnection對象。或者把configSection的配置卻掉也能正常運行。請問這是什么原因造成的?
我添加上面的配置原因是用于解決“mixed mode"異常的。因為在使用smo的事務管理時,當調用ServerConnection.BegionTransaction()方法時,總是出現異常”Mixed mode assembly........"。到底smo的事務管理是如何使用的?
參考資料:http://objectmix.com/csharp/119948-sqlclient-system-typeinitializationexception-real-head-scratcher.html
- 2 回答
- 0 關注
- 1413 瀏覽
添加回答
舉報
0/150
提交
取消