2
Vote

VS2012, .NET Framework 4.5, Prefer 32 bit - Gives "Failed to load DLL"

description

When VS2012 was released, there was a new option added for a couple different project types (currently I know that it is there for Console and WinForm applications). I use C# pretty much exclusively, so I am not sure if these options are available for other languages.
  • Create a new WinForm application using VS2012 targeting .NET Framework 4.5
  • Open the project's properties
  • Make sure the platform is set to "Any CPU"
  • Go to the Build tab
  • There is a new option called "Prefer 32-bit" which is checked (new meaning compared to VS2010)
Here is an article that talks about this option and what it means: http://blogs.microsoft.co.il/blogs/sasha/archive/2012/04/04/what-anycpu-really-means-as-of-net-4-5-and-visual-studio-11.aspx

If I build the application with "Prefer 32-bit" checked and then RIGHT-click on the [ApplicationName].exe file and select Assembly Information, I get the "error Failed to load DLL - Error: The given key was not present in the dictionary."

If I uncheck the "Prefer 32-bit" option and then rebuild the application and redo the other steps, Assembly Information loads the details without any error message.

Please respond to the issue if you need samples for repro cases.

comments

AAgeev wrote Oct 26, 2015 at 5:38 PM

Locally I solved that in such way:

Program.cs:
class Program
..
static void Main(string[] args)
{
..
if (!spanProcess)
{
//Environment.CurrentDirectory = Path.GetDirectoryName(filePath);
//replaced to 
Environment.CurrentDirectory = Path.GetDirectoryName(assemblyullName);
...
if (!assemblyullName.Contains(" "))
//psi.Arguments = args[0];
//replaced to
psi.Arguments = assemblyullName;
...