AnyCPU .NET Project Associates a Library with a Specific Platform

Possible duplicate:
Download x86 or x64 assembly

I am trying to compile any .NET.NET project, but I need to link the SQLite library, which has different versions for x86 and x64 platforms. Changing only the DLL versions to x64 does not help, the application does not start, I need to recompile the code using x64 help. When I add x86 and x64 links, they cannot compile due to conflicts. I can not compile the application using x86, because one of the system COM libraries that I use does not work under WOW64.

All 32-bit VSS applications (requesters, providers, and writers) must run as native 32-bit or 64-bit applications. Running them under WOW64 is not supported

http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/eadf5dcd-fbd1-4224-9a56-b5843efebb15/

therefore, I need to build any CPU project, but the only solution to this problem that I see at the moment is to duplicate projects for x86 and x64. Anything better?

UPDATE

When I reference the x64 libraries in the project, but try to load the x86 libraries, I get the following exception.

The located assembly manifest definition does not match the assembly reference.

+5
source share
1 answer

The main problem was that I used different versions of SQLite for x86 and x64. I added a method

static private Assembly SQLitePlatformSpecificResolve(object sender, ResolveEventArgs args)
{
    string platform = Environment.Is64BitProcess ? "x64" : "x86";
    string assemblyName = new AssemblyName(args.Name).Name;
    string assemblyPath = Path.Combine(
        Environment.CurrentDirectory, "SQLite", platform, assemblyName + ".dll");

    return !File.Exists(assemblyPath) ? null : Assembly.LoadFrom(assemblyPath);
}

And install an event handler

AppDomain.CurrentDomain.AssemblyResolve += SQLitePlatformSpecificResolve;

at the application’s main entry point. Now it downloads the x86 assembly for x86 and x64 platforms on 64-bit platforms respectively.

Thank.

+6
source

All Articles