VBA C#DLL没有注册 [英] VBA C# DLL no registration

查看:93
本文介绍了VBA C#DLL没有注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个C#.NET dll,我想从VBA中运行它而无需注册它。
我已经找到了解决方法,它可以完美地工作,但是仅当使用Framework NET 3.5组装时或更老。
使用Framework 4.0时,出现错误此程序集是由比当前加载的运行时新的运行时构建的,无法加载。
有人可以帮助我吗?

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?

推荐答案

所以,我找到了解决方案。

So, i've found the solution.

默认情况下,Excel使用1.1框架,如此处所述。
如果您查看Windows注册表,

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\

您可以看到目标版本是v1.1 .....
因此,解决方案是制作一个Excel.exe.config文件以强制使用框架版本4,如此处

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>

这篇关于VBA C#DLL没有注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆