How to build a 64 bit application on 32 bit OS? [c#] - c#

I have a application which implements Geckofx web browser control. I have 64 bit compiled geckofx.dlls(compiled from a 64 bit OS). But currently i don't have access to 64 bit OS and i want to compile the whole application with the 64bit geckofx.dlls targetting 64 bit OS. How can i do that from my 32 bit OS?
I need a good tutorial to do this. Do i need to download and install 64 bit compilers in my pc? if so, how? and how to check if i already have that compilers?

I don't think I've ever done this, but can't you just set the code generation ("platform target") as x64 in the project's "Build" configuration?
Or, in the command line: csc.exe /platform:x64?
As far as I know, the C# compiler (csc) is a 32bit application, it should be able to generate code for any supported platform

Related

Deploying 64 bit C# winform app on a 32 bit machine

I have developed a C# winform application using VS 2012 on a 64 bit machine, now I would like to deploy it on a 32 bit machine, but I get the error of the form "... is not a valid win32 application" whenever I try installing and running the exe file on the 32 bit machine. Please suggest me the best way to get around this situation. Thanks!
It sounds like the project was compiled specifically for x64.
Pure .NET projects can and should be compiled to "Any CPU" which means they will run on either x86 and x64. This is usually the default.
http://blogs.microsoft.co.il/sasha/2012/04/04/what-anycpu-really-means-as-of-net-45-and-visual-studio-11/

Where to find x64 version of Office Interop assemblies?

I am trying to run this project in my VisualStudio 2010.
it build and run fine on my 64 bit Machine.
NOTE:I have to change build Platform of my project to x86.
my problem is when I try to run compiled assembly (after moving Debug Folder to another 64 Bit machine) I couldn't run my project. my exe breaks down when I open it.
as per my understanding problem is because of three DLL used in project are 32 BIT and Machine is 64Bit.
NOTE: below is three DLL
Interop.Office.dll
Interop.VBIDE.dll
Interop.Word.dll
I googled much but couldn't found any solution?
one solution comes in my mind is manage to get 64BIT version of above DLL for that also I have googled much but couldn't get anything.
could you please help me to find solution for this problem? or is there any way to found 64BIT version of above DLL?
If you have to use 32 bit dlls, probably you cannot run your application, compiled on 64 bits.
So you need to compile all your project (as you did for debug) in the 32 bits mode before release to another pc.
You can ensure your dlls compiled right (32 bits only), using Microsoft CorFlags.exe utility.
If you'll find that dll is not 32bits, you can also try to change it with same utility (/32BITS falg).
More information:
The default version of Office is 32 bit version.
To get 64 bit versions of the assemblies you need to specifically install 64 bit office (see here.)
The 64 bit version of Office should be able to use your 32 bit program (using WoW)
but it's best if you create (and test) two versions of it: one for 32 bit and one for 64 bit.
Unfortunately this means two development environments as the 32 bit Office cannot be installed along side the 64 bit one.
Are you positive that the office interOps are the problem?
What is the error message you are receiving? You have stated that you are compiling with x86 platform build mode. Therefore your dlls will run as 32 bit processes even on the other 64bit machine and will therefore call the 32bit office dlls.
If you had of compiled as AnyCPU then I could see how the error you are getting relates to office dll bitness, because your application would start in 64bit (on a 64bit machine) and then attempt to call into the 32bit office dlls.
But I fail to understand how you're finding that the 32bit dlls are the problem on any 32 or 64bit machine since you are compiling to 32bit (x86). So your assembly manifest is telling the JIT compiler, "hey Im a 32bit process".
Remember, ngen aside, the bitness of your code isn't determined till it's run. Post compilation the code is just IL waiting to be compiled and it's the same IL regardless of whether you had a build platform of x86 or x64 or AnyCPU.
When it's run the runtime looks at the manifest and compiles it to the platform of choice... which in this case is x86... from what you have said.
So the problem is not that:
three DLL used in project are 32 BIT and Machine is 64Bit.
32bit dlls are used all over the place on 64bit machines. Visual Studio itself is a 32bit application and runs just fine on 64bit machine. The problem (IMHO) is either
Not the office dlls at all but something else... Office is installed on the other machine I assume.
You've accidentally changed the target platform of the last build you did before deploying to something other than x86.

Creating a 32 bit wrapper for a 64 bit dll. Is this possible?

I have a couple of dlls that are x64, with the x86 versions not being released yet. I want to use these in a x86 environment. There is no way to change any of the platforms of those factors.
I have tried searching the Internet, but to no avail. What I want to do is somehow create a x86 library that can communicate with the x64 ones. Is this possible at all? If so, how?
Preferably, the wrapper will be in C# code, though it has to be able to access C++ dlls. (The x64 libraries are written in unmanaged C++.)
You cannot do this within a single process. That's because a 32 bit process can only load 32 bit modules, and a 64 bit process can only load 64 bit modules.
The only way for your 64 bit code to call 32 bit code, and vice versa, is to use an out-of-proc solution. For example an out-of-proc COM server.

.net console app 32 vs 64 bit

Does a application in .NET need to be built in 64 bit to take full advantage of a machine with a 64 bit OS on it, or will it take advantage of it just as a 32 bit build. Basically, we have an issue with an out of memory exception and it was suggested to run the console app on a 64 bit box which "may" solve the issue. The question is can we just spin up a 64 box and throw the current app on it or do I need to rebuild the app in a 64 bit way.
If your app is configured to build for the "Any CPU" platform, then it'll run appropriately on either.
Just make sure it doesn't use any 32/64 bit specific stuff, or you'll run into problems.
MSDN docs here.
For some discussion on drawbacks, see here
If it's built for any platform (the default), it will run in 64 bit on 64bit operating systems.
That being said, there are still potential issues to watch for. If you interface with native code (via p/invoke, C++/CLI, or COM), then you will need to port that code to 64 bit. If the application is 100% managed, it just works.
"Any CPU" is your friend.
As an aside:
We had a particularly large Trie structure that exceeded the 2GB memory space of 32bit Windows. Because most of the structure comprised of object references, we found that the memory requirements of the app nearly doubled when moving to 64bit, requiring around 4gb. This is because the memory to store a reference is 64bits wide instead of 32.

C# PInvoking user32.dll on a 64 bit system

Is it wrong to pinvoke user32.dll on 64 bit Windows, from a 64 bit app? I've done this successfully a number of times and never had an error, but it seems contradictory. Should I look for user64.dll instead?
The name user32.dll is misleading. It's the 64 bit version of user32.dll you're calling. The 64 bit version is located at %windir%\System32\user32.dll.
A 32-bit version is included for compatibility with 32-bit applications. It's located at %windir%\SysWOW64\user32.dll. You can inspect them using the dumpbin utility:
System32\user32.dll:
FILE HEADER VALUES
8664 machine (x64)
SysWOW64\user32.dll:
FILE HEADER VALUES
14C machine (x86)
There is no user64.dll for the exact same reason you just described, .NET program can be agnostic to CPU architecture so the same code needs to work on x86 and x64.
If you take your program to x86 platform, it will still run without any modifications.
I guess that when they named user32.dll, they didn't have those scenarios in mind.

Categories

Resources