Change x86 to x64 dlls in production environment for ASP.NET application - asp.net

I have an ASP.NET application that I am currently developing in C#.
The application needs a set of reference (dlls) to work. At development phase I need to use the x86 (32 bits) libraries but when I put the application in production I need to substitute the libraries with the x64 (64 bits) version.
Is it correct and safe to deploy the sytem in my IIS7 (Server 2008) as it is in Visual Studio (so working with x86 libraries) and then change the x86 libraries with the x64 directly in production environment (by copy pasting)? If that is not the case may you please suggest a more clean way?

In all cases you should test/develop with the same version as you deploy on production. So in development you should compile for x64 if your production server is x64. Otherwise you have the risk of error when you go to production. For example you can use a x86 lib which you do not compile yourself. The you will only notice this on production, which is a little late.
The way to go is to make all environments the same.

Related

Running Kestrel in 64-bit mode with ASP.NET Core MVC web apps

With a ASP.NET Core MVC web app, is there a way to run the Kestrel web server in 64-bit (or AnyCPU) mode? If I change my app's target platform from the default x86 to either x64 or AnyCPU, it no longer runs, producing a System.BadImageFormatException when trying to start Kestrel (Microsoft.AspNetCore.Server.Kestrel).
ETA: To investigate further, I decompiled Microsoft.AspNetCore.Server.Kestrel. It's built for AnyCPU, but appears to contain a mix of MSIL and native x86 code for the libuv library, which is written in C. It's not clear why the only way to load it is from an assembly built for x86, with both AnyCPU and x64 producing the "bad image" error. One would expect to be able to load a AnyCPU assembly from another AnyCPU assembly, yet this is not the case. It's also puzzling that a AnyCPU assembly would contain some native x86.

Compiling 32bit app on 64bit machine

I want to convert my 32bit application to 64bit so I could compile it and keep working on it on my 64bit machine. How can it be done?
To compile at 64bit:
Inside Visual Studio go to Build > Configuration Manager
Then you can specify CPU by selecting the Platform column and choosing between X86 and x64.
Then you can explicitly compile at 64bit.
That said Any CPU should be good enough for you to keep working on it. My carry around is 64bit, but the buildserver can output the projects as either 32bit or 64bit depenedent on the release template.
Also dependent on your Visual Studio version, there is the Prefer 32bit flag which may be of use dependent on your exact requirements.

How to compile ASP .NET website on 32-bit machine & deploy it on 64-bit machine

I'm working on restructuring a website written in ASP .NET. I'm working on Vista machine with 2010. The intended deployment server is 64-bit machine running IIS.
Now, I know that exactly same code will work on both the machines, but I may have to compile the code differently for the deployment server. Can anyone guide me regarding correct settings for this & place to change these settings?
Thanks!
Just set "Any CPU" as a Platform in your project properties. You can access it through
Build->Configuration Manager...
And you site will work on both x32 and x64

How to configure an InstallShield 2009 project to run on 32- and 64-bit systems

I have a 32-bit application that I'm packaging with InstallShield 2009 Premier. I would like to be able to install it on 32- and 64-bit machines, but the InstallShield installer doesn't seem to be able to automatically detect that it's being run on a 64-bit machine and consequently redirect the creation of registry keys to HKLM\Software\Wow6432Node... and the creation of files to C:\Program Files (x86)... Despite my best googling, I can't seem to find out how to configure the InstallShield project to account for this.
Any ideas?
Since you have a 32-bit application, you need to leave its installer the way it is.
Wow6432Node and Program Files (x86) were specifically designed for 32-bit applications. On a 64-bit machine Program Files and HKLM\Software are for 64-bit applications only.
A mixed 32/64-bit installer can be used only for an AnyCPU application.

Compile ASP.NET to 64 BIT

My development machine is Win XP Pro 32 bit and production machine is Windows Server 2008 (64 Bit) with IIS 7. On my development machine I want to compile ASP.NET (Using aspnet compiler) to 64 bit byte code.
Can anyone please tell me how to do that? Please do not suggest any way to run 32 bit application on 64 bit environment.
I want 64 bit application to be compiled on 32 bit machine so that when it runs it will take full advantage of 64 bit O/S without any emulation.
Leave the target platform at AnyCpu and .NET will automatically run natively on 64bit when executed on a 64Bit operating system
Clarification:
(this started out as a comment but I thought it might be interesting for the question as well)
Actually you never compile to a special architecture. You always compile to IL.
That's something like Java Bytecode. And that bytecode is the same for 32 bit and 64 bit.
The Virtual Machine (.NET Framework) on the machine the code gets executed then compiles the IL to actual machine code while running (through the Just In Time compilation). So, no matter where you compile, you'll always end up in IL that's bit-ignorant.
The setting in .NET is only an instruction in IL that tells the JIT (Just in Time compiler) to specifically use 32bit/64 bit. By flipping that one bit in your assembly you could still execute it in AnyCpu or x64 without recompilation.
This setting is only used and needed in case you call out to native code that isn't bit-ignorant (when interacting with COM components or doing p/invoke calls)
There's an option in Visual Studio 2013 now to direct IIS Express (which is usually used for debug) to run in 64 bit mode.
It's at Tools -> Options -> Projects and Solutions -> Web Projects -> Use the 64 bit version of IIS Express…
.net apps will re-target themselves for the target machine environment assuming that you didn't specifically choose to compile in 32-bit mode. This can be found under the project build options.

Resources