none
Windows .NET exe on 64 bit RRS feed

  • Question

  • Hi,

    I have developed a .NET Windows exe in C# 2.0. It refrences two other projects (class libraries) onw is written in C#.NET 2.0 and other is in VC++.NET 2.0.

    On my machine, i have VC++ SP1 installed and my machine is 32 bit Windows OS SP2. Here is the problem :

    When i run this exe on a  64 bit Windows Vista, i get the following error when the exe tries to load the VC++.NET dll.

    Could not load file or assembly 'myAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    I have installed VC++.NET 2005 SP1 (x86) on this 64 bit Vista machine.

    What is the issue ?  Any ideas

    Thanks
    Kulvinder Singh
    Wednesday, April 16, 2008 5:54 AM

Answers

  • I think the vc++ dll is not compiled for x64.

     

    Please check the compilation debug configuration of all projects.

     

    .NET projects

    "anycpu" option. (DEFAULT)

    That application run as 32 bit process in 32 bit os. And 64 bit process in 64 bit os.

    "x86" option.

    That application run as 32 bit process in 32 bit os. And 32 bit process in 64 bit os (WOW mode).

    "x64" option

    That application wont run in 32 bit os. Run as 64 bit process in 64 bit os.

     

    VC++ Projects does not have anycpu option.

    "x86" option. (DEFAULT)

    That application run as 32 bit process in 32 bit os. And 32 bit process in 64 bit os (WOW mode).

    "x64" option

    That application wont run in 32 bit os. Run as 64 bit process in 64 bit os.

     

    If u compiled your .NET application with anycpu option. It will run as a 64 bit process. But the VC++ dll is a 32 bit so it will not load into the 64 bit process. so your application gives the above error.

     

    Soultion for the problem.

    1. You have two versions of VC++ dll one for 32 bit (x86) and another for 64 bit(x64). Deploy only the version based on the platform. Please ensure the pointer references and integer values in the vc++ project because they are expanded to 64 bit.

     

    2. Compile the .NET project as "x86". This will make your application run on all the platform with out any changes. but you have to consider the 64 bit os benefits.

     

    Regards

    Prakahs

    Wednesday, April 16, 2008 7:01 AM

All replies

  • I think the vc++ dll is not compiled for x64.

     

    Please check the compilation debug configuration of all projects.

     

    .NET projects

    "anycpu" option. (DEFAULT)

    That application run as 32 bit process in 32 bit os. And 64 bit process in 64 bit os.

    "x86" option.

    That application run as 32 bit process in 32 bit os. And 32 bit process in 64 bit os (WOW mode).

    "x64" option

    That application wont run in 32 bit os. Run as 64 bit process in 64 bit os.

     

    VC++ Projects does not have anycpu option.

    "x86" option. (DEFAULT)

    That application run as 32 bit process in 32 bit os. And 32 bit process in 64 bit os (WOW mode).

    "x64" option

    That application wont run in 32 bit os. Run as 64 bit process in 64 bit os.

     

    If u compiled your .NET application with anycpu option. It will run as a 64 bit process. But the VC++ dll is a 32 bit so it will not load into the 64 bit process. so your application gives the above error.

     

    Soultion for the problem.

    1. You have two versions of VC++ dll one for 32 bit (x86) and another for 64 bit(x64). Deploy only the version based on the platform. Please ensure the pointer references and integer values in the vc++ project because they are expanded to 64 bit.

     

    2. Compile the .NET project as "x86". This will make your application run on all the platform with out any changes. but you have to consider the 64 bit os benefits.

     

    Regards

    Prakahs

    Wednesday, April 16, 2008 7:01 AM
  • I am not a programmer, but have an application developed in 1997 that refuses to open using Vista 64 bit platform.  How can I fix this problem?  It was written in Delphi with Borland Tables.  My customers can't run (open) the executable if they are using any 64 bit platform.  Is this an easy or difficult fix?  I need to find a programmer who can do this for me.  Thanks for your help.
    Saturday, November 28, 2009 3:49 AM