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?
Asked
Active
Viewed 1,409 times
2
-
Oh dear, that is not a helpful answer. It uses a .NET 1.0 technique, one that did not yet permit determining what CLR version to load. Selecting the tlb files from the v4.0.30319 folder accomplishes nothing. That it works for a 3.5 assembly is an accident, a common one today since most machines don't have a .NET 1.x version installed anymore. Woe be you if it does. Don't do this. – Hans Passant Feb 03 '16 at 12:56
1 Answers
3
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>

Community
- 1
- 1

quicksilv86
- 105
- 11