VBA C# DLL no registration

牧云@^-^@ 提交于 2019-12-24 16:34:07

问题


I have made a C# .NET dll which i would like to run from VBA without register it. I've found the solution there and it works perfectly, but only when the assembly is made with the Framework NET 3.5 or older. With Framework 4.0, i'm getting the error "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded".. Someone could help me please?


回答1:


So, i've found the solution.

By default, Excel uses the 1.1 framework as explained here. If you have a look into the Windows Registry,

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Policy\AppPatch\YOUR_FRAMEWORK_VERSION\excel.exe\

you can see the targeted version is v1.1..... So, the solution is to make an Excel.exe.config file that forces Framework version 4, as explained here

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


来源:https://stackoverflow.com/questions/35174557/vba-c-sharp-dll-no-registration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!