I develop on a pretty big windows forms .net (C#) application with several assemblys. Originally each assembly was build for the Target Platfom "Any CPU".
Due to a problem with Crystal Reports on x64 machines we had to build the whole project for x86 target platform. I startet rebuilding some of our Projects for x86 and it worked just fine.
But with one I have the problem that when I try to use it as a reference in another Assembly, the other one won't load it giving following Error:
Could not load file or assembly #MyAssembly# or one of its dependencies. An attempt was made to load a program with an incorrect format.
When playing Around with Crystal in a sample project with more than one assembly I found out that this error occurs when the Projects are build for different target platforms. But this isn't the case here. I build every Project for X86 and just can't figure out where the problem is here.
You can try, to build your MainProject (Executable) with target platform "x86" or "x64", an all other projects you set to "Any CPU".
Related
In Visual Studio 2017 I created a Stand-Alone Code Analysis Tool project targeting 4.6.2. I used the templated code as-is except that I specified the .sln file for the workspace.OpenSolutionAsync() call.
The solution I am attempting to compile with this Roslyn method contains both projects where Platform=Any CPU, and projects where Platform=x64. The solution compiles fine in VS2017 when set to Mixed Platforms.
However, the OpenSolutionAsync() call generates several of these compile errors:
Msbuild failed when processing the file 'C:\MyProj.csproj' with message: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (2110, 5): There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\MyUnmanagedLibrary.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
Why is it complaining about x86 when the MyUnmanagedLibrary project has been set to build using Platform=x64 in the Configuration Manager? How do I resolve this? This code was working fine one day ago and to the best of my knowledge nothing has changed except that I copied code to a different directory on my PC.
The cause of this behavior was that some of my projects had an output path of bin\Debug\, and others had an output path of bin\x64\Debug. However, the build process performed when you call OpenSolutionAsync() appears to assume bin\Debug. It was finding old x86 versions of DLLs in bin\Debug\ folders instead of looking at the DLLs in bin\64\Debug\ folders. Once I changed all the projects' output paths to bin\Debug\, the OpenSolutionAsync() process worked fine.
Trying to use Sqlite in my VB.net app, thought it would be simple so I installed it via the NuGet package manager. Now i've lost a week to this hate to admit, I just can't make it work for the life of me.
When I set my build to x86, it say's it can't load SQLite.Interop.dll, when I set my build to x64 it can't find one of my custom controls within my project. I tried some solutions from other SO questions but none of them worked for me.
Can someone help me out here? It's getting pretty frustrating. Apparently their NuGet package is completely broken for me, so I downloaded just System.Data.SQLite.dll from the vendors website, referenced it in my project, set to Copy Always, and changed my build from AnyCPU to x86 (to match the DLL). Which results in an exception stating the referenced assembly cannot be found.
you also need to download the SQLite package from here http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
make sure you download abd install the x86 version even if your running x64.
We have two applications that use ILNumerics and have run into the same issue with both. We use the mkl_custom.dll and during development the application runs fine. The dll in use during development sits in the bin32 folder automatically generated when downloading the ILNumerics from nuget. However when we install the applications we get "Unable to load DLL 'mkl_custom': The specified module could not be found. (Exception from HResult: 0x8007007E".
Here is what we have tried:
Building the application in Any CPU, x86.
Switching the bin32 to include the bin64 dll's and viсе-versa.
Running dependency walker and including all dll's that are needed.
Changing path variable.
We are using ILNumerics 3.3.3.0.
One of the dependencies for mkl_custom is msvcr*.dll. Packing this dll manually may work on some operating systems but not all. Make sure the target system has c++ runtime redistributable package installed.
This installs the msvcr dll correctly. Hopefully this should fix the issue
I have a project that is build on Any CPU configuration, .Net Framework 2.0, vs2008 with 32bit version of SQLite dll used in it.
Well this works fine on my 32 processor environment, but when i ran this project on 64bit processor environment i experienced
"Could not load file or assembly 'System.Data.SQLite, Version=1.0.66.0, Culture-neutral,
PublicKeyToken=db937bc2d44ff139' or one of its dependencies.
An attempt was made to load a program with an incorrect format."
I even tried adding 64 bit dll on my project but it did not work.
I have tried all the solutions but that did not work for me. Since i am bound to build the project on 32 bit machine, i need a way to run this tool on my 64 bit environment too.
Any suggestions/comments/improvements means a lot for me.
Thanks in Advance.
Compile your application using x86 configuration.
When dealing with dlls like SQLLite that are compiled for x86, your process must be running in x86 mode.
I find these steps can be used to deal with sqlite.
Download NuGet
open cmd and type nuget install System.Data.Sqlite -- note it will create a folder in your current directory
copy dlls from net20 folders to your solution like so.
Add a reference to System.Data.SQLite.dll
Make sure you copy both SQLite.Interop.dlls to your output dir
Hope it helps.
My solution contains a lot of project, when switching from AnyCPU(32bit) to x64 I get alot of Metadata file X could not be found?
To build all projects in x64 I use the Configuration Manager where I set it to release and x64.
Sometimes the trouble is caused by references between projects where the project dependencies are not updated. You can confirm them under Project -> Project Dependencies for each project giving trouble.