VBA C# DLL no registration

2019-08-15 02:41发布

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?

标签: c# vba dll
1条回答
虎瘦雄心在
2楼-- · 2019-08-15 03:13

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>
查看更多
登录 后发表回答