2

I have a C# WPF application built in VS 2010 with Target Platform set to x86. This exe calls on a Managed DLL with target platform ANYCPU. The Managed DLL has a reference to a C++ DLL which is compiled with Common Language Runtime Support (/clr) option.

On .NET 3.5 the app works perfectly with on any OS. It works fine on Win 7 as well, on both 32bit and 64 bit.

Now that I have converted the application and its DLLs to target .NET 4. If it is run on a .NET less than 4, it throws an error that .NET 4 is required which is the expected result.

The converted app works fine on my development system and on any system that has .NET 4 + .NET 3.5. So far so good!

However, on systems with ONLY .NET 4 (ie Win 8) or win 7 without .NET 3.5, I get the error: Could not load file or assembly 'x' or one of its dependencies. The specified module could not be found.

'x' is the C++ dll compiled with Language Runtime Support (/clr) option.

So, in short the problem only happens on systems with .NET 4 only.

Any advice would be appreciated. Thank you, - Kam

Kam B
  • 21
  • 3

2 Answers2

0

.NET 4 has back compatibility with all previous versions. So it doesn't seem the problem is in the platform version. Might it be folder's security? Try to check its permissions.

Alex Isayenko
  • 649
  • 8
  • 7
  • Thanks for your answer. I do have admin right for the folder. I don't think that is the problem. – Kam B Feb 26 '12 at 04:05
0

There was a change in native code loading policies since .NET 4. To resolve this, please add the App.config file to your .exe project with the following contents:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
  </startup>
</configuration>

This discussion may also help: What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?

Community
  • 1
  • 1
ogggre
  • 1,895
  • 18
  • 18