5

It seems the default running environment of Visual Studio is 32 bit. And I need to run one of my application in 64 bit mode. I did the change in project property like 'Platform Target' to 64 bit. But now am not able to run my application. I got an error like "Could not load file or assembly 'MyProject' or one of its dependencies. An attempt was made to load a program with an incorrect format."

Then I tried with a new blank WebApplication. Still in there also showing the same error. I remove all the reference dll files and added the dependencies from this path "C:\Windows\Microsoft.NET\Framework64". But unfortunately Still am getting same error.

I changed the Application Pool property of my IIS (Enable 32-Bit Application = True). Then tried to run in Local IIS Web Server but that too didn't worked.

Am using Windows 7, 64 bit OS and Visual Studio 2010. And when using the following c# code to find the running environment

using (RegistryKey registryKey = 
    Registry.LocalMachine.OpenSubKey(@"SOFTWARE\R-core\R"))
{
    var envPath = Environment.GetEnvironmentVariable("PATH");
string rBinPath = (string)registryKey.GetValue("InstallPath");
string rVersion = (string)registryKey.GetValue("Current Version");
rBinPath = System.Environment.Is64BitProcess 
        ? rBinPath + "\\bin\\x64" :rBinPath + "\\bin\\i386";
    Environment.SetEnvironmentVariable(
        "PATH",
    envPath + Path.PathSeparator + rBinPath);
}

The value of System.Environment.Is64BitProcess is always false I didn't want to follow the 64 bit path, if the running environment is 32 bit. So how to force VS to run in 64 bit mode?

Here I shared the error response page I got. Please help me to solve this issue Thank you.

Error Response Page

6
  • 1
    The Enable 32-Bit Application must be set to false if you targeted 64 bits during build ? Commented Jun 24, 2014 at 11:57
  • I tried by setting the Enable 32-Bit Application = False first, but i didn't get the expected outcome. Then i tried by changing that value to True also. Commented Jun 24, 2014 at 12:01
  • Try with a fresh empty web app. Target x64bits. Set Enable 32-Bit Application = False. Check it's the right pool for your app. It's should be ok. Commented Jun 24, 2014 at 12:07
  • Oh Sorry NicoD, That I already tried... As i mentioned in my question, I created a new Empty Web App, then Change the Platform Target to x64 without changing any other settings and tried to run, but failed. Then i changed the dependencies and tried still not get the expected outcome. Then i changed the Enable 32-Bit Application, likewise one by one i tried by changing all the settings.. But didn't succeeded Commented Jun 24, 2014 at 12:17
  • But you publish the app or modified the properties in visual studio to launch the app from IIS ? Commented Jun 24, 2014 at 12:41

2 Answers 2

1

Here's step by step a procedure which is ok from my VS2013, on a 64Bits OS

  • Create a blank app : New project type WebApplication > WebForm (or else) > no authentication

  • Target x64 : for the Debug mode from drop down list

    • Choose configuration manager
    • Choose platform new and select x64 as target platform
  • From the properties of your project, in the web tab

    • Choose Local IIS instead of IIS Express
    • Create Virtual Directory => The virtual directory was successfully created
  • Launch the app in debug mode from visual studio

Sign up to request clarification or add additional context in comments.

Comments

0

This is the steps to debug your application in x64 bit environment in Visual Studio.

  1. In the Project Properties 'Build' Tab change the setting 'Platform Target = x64'

  2. And for web application in the 'Web' Tab Select the Option 'Use Local IIS Web Server'

  3. Then click 'Create Virtual Directory'

  4. Make sure your IIS application pool setting 'Enable 32-Bit Applications = False' (By default it is false only).

Then debug.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.