Question

We use a 3rd party mixed mode assembly that interfaces with a printer device.

In one of our applications, the assembly functions correctly.

In another application, it was generating the following exception:

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

After doing some research, I discovered that I could add the following to the app.config file to resolve this problem:

<startup useLegacyV2RuntimeActivationPolicy="true">

(The application that works already had this setting in its app.config)

Although this did resolve the "Mixed mode assembly" issue, now I'm seeing a somewhat different problem:

External component has thrown an exception

The strange thing is that I have one application which works correctly and another application which does not. They both call the third party assembly via the same code (which is another one of our assemblies).

I tried creating a very simple test app which calls the third party assembly using the same code path, and it also fails with the "External component has thrown an exception" error.

I've compared the app.config files for all of the applications and they are essentially the same, and I've double checked that all of the build settings are the same for each. Both projects target .NET 4.0 and X86.

There is obviously something different about the two applications but I'm at a loss to identify what it is.

Development environment is Visual Studio 2010.

Does anyone have any suggestions on what other areas I could investigate?

Was it helpful?

Solution

@tsells was right: there was a missing dependency

The third party assembly in question depended on another DLL that was present in the first applications bin folder.

I copied all of the files from the working application's bin folder to the non-working application's bin folder, and it resolved the problem.

From there it was just a matter of deducing which DLL was missing and including it in the second applications project.

OTHER TIPS

When there are dependencies missing, you can use tools like CheckAsm for managed and Dependency Walker for unmanaged libraries to check for dependencies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top