[.net] Using a C# dll in CLI / C++ VS 2010

Started by
3 comments, last by Wrathnut 12 years, 9 months ago
Hi,

I have a dll created in C# that I am trying to use in my visual studio 2010 project. When I try to access a function from the DLL I get this exception thrown:


ystem.IO.FileLoadException was unhandled
Message=Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
Source=OpenLayers.Base
StackTrace:
at q.a(Boolean A_0)
at q.a()
InnerException:


The DLL is built against an older version of the .NET framework.
I have seen some posts on the internet that say to modify a configuration file.(LINK-> MSDN Posting ) But it seems that this configuration file is only generated if you are creating a VB or C# program. Does anyone know how to modify this 'additional configuration information' for the CLI / C++ framework in VS 2010?

Any insight or help would be greatly appreciated!

Thanks!
Advertisement
Write
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>[/quote]into filename.exe.config file, where "filename" is name of your executable.
Martin,

Thanks for the response. There doesn't seem to be a config file with the project name generated from VS 2010. I finally able to get the app.config file created within the IDE. Although the compiler throws out these warnings:


Message 1 Could not find schema information for the attribute 'useLegacyV2RuntimeActivationPolicy'. C:\Users\user\Documents\Visual Studio 2010\Projects\Traveling Magnetics 2\Traveling Magnetics 2\app.config 4 12 Traveling Magnetics 2

Message 2 Could not find schema information for the element 'supportedRuntime'. C:\Users\user\Documents\Visual Studio 2010\Projects\Traveling Magnetics 2\Traveling Magnetics 2\app.config 5 6 Traveling Magnetics 2

Message 3 Could not find schema information for the attribute 'version'. C:\Users\user\Documents\Visual Studio 2010\Projects\Traveling Magnetics 2\Traveling Magnetics 2\app.config 5 23 Traveling Magnetics 2


It seems like these attributes are not supported at all. I tried to compile are run it anyway, but still received the same error when trying to use the DLL.
Just a long shot but have you tried manually creating a text file with the appropriate .exe.config file name with the stated content?
Oddly enough that seems to be working. Thanks everyone for the help!!

This topic is closed to new replies.

Advertisement