Where to find x64 version of Office Interop assemblies? - c#

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.

Related

0xc000007b error in C# application

This question may be asked so many times. I searched for the solution too much. I got a solution (although that didn't work) to replace some .dll files.
Actually I made an application in Windows 7 Ultimate 64 bit, Visual Studio 2010, target Framework 3.5 with MS Access 2007 Database (Platform target x86). Then I tried to run this application (.exe file) on another machine having Windows 7 Ultimate 32 bit. But the error appeared.
As I got solution to replace those 5 dll files in \Windows\SYSWOW64 folder, but cannot find this folder on 32 machine. Even though I replaced/copied those 5 dlls to System32 folder. But the same error.
I also installed framework 4.0 on the target machine. But the same error.
Now how to resolve this error? Thanks...
Syswow64 is a folder just for 64 bit versions of Windows, where it stores files for 32 bit programs. It shouldn't exist on 32 bit Windows.
Try compiling for 32 bit Windows, then running on the other computer.
Several problems makes this happen (in my case)...
Most important to check for the VIRUSES;
Application is compiled in x64 and running on x86 platform;
If any dll, compiled in x64 platform, added to the x86 application;
These are some of those problems gives the error.
You need to change system target. On menu Build -> Configuration Manager, you can change the platform to x86 instead of x64.

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/

32 bit winform application doesn't run on 64 bit OS

I have two laptops.
1) BuildLaptop-> The laptop that I have coded the application. Windows 7 Ultimate 32-bit, Office 2007 for database
2)TestLaptop-> To test the application. Windows 7 ultimate 64 bit, Office 2007.
My application contains several dll files that built as AnyCPU and the application is also built as AnyCPU.
When I tried to test my application on TestLaptop it gave me an error:
Microsoft.ACE.OleDb.12.0 provider is not registered on your machine.
So I uninstalled Office from TestLapTop and installed the Office as on BuildLapTop.
Again same error. Then I tried to compile all dlls and also my application to x64. The application could not start. Then I tried to compile only application to x64 and dlls to anyCPU. The error occured again.
So help me how to get my application run on the TestLapTop?
You need to compile any project as /platform:x86 if it uses any 32-bit unmanaged resources (DLL's, etc).
I'm not sure based on your comment you may be experiencing this issue. If you have any Microsoft Office programs installed:
Word
Outlook
Excel
Powerpoint
Etc
If they are the 32 Bit Revision then you can't install a 64 Bit Access Database Engine it will give you the following exception:
This will force you to install the 32 Bit Revision onto your 64 Bit Machine. You may also require some additional configuration for the database in your ODBC Data Source through Administrative Tools.
Hopefully that clarifies at least your error you mentioned in comment. As for the compile, Sixlettervariables has a solution for that.
Hopefully that helps though.

Is it OK to manually write Wow6432Node entries from VS2010 Deployment Project?

I have a .NET component written in C# that needs to register some registry values under the HKLM hive. I'm expecting this component to be installed on both x86 (32-bit) and x64 (64-bit) boxes running the appropriate flavour of Windows. On 64-bit systems, I want to make sure the component can be used by both 32- and 64-bit hosting processes. I'm stuck with using Visual Studio's deployment projects for the time being.
What I want is for my installer, when run on 64-bit systems, to put its registry entries under HKLM/Software/Blablah, so that when running in a 64-bit process, my component can find its global configuration settings. However, if my component is hosted by a 32-bit process running on the same machine, then it will read from what it thinks is the same key, but which Wow64 will translate to HKLM/Software/Wow6432Node/Blablah.
Is it OK to author my 64-bit installer so that:
it is marked as a x64 installer
it writes the entries under HKLM/Software/Blablah for the benefit of 64-bit processes
it writes exact copies of those entries under
HKLM/Software/Wow6432Node/Blablah for the benefit of 32-bit processes on the same machine.
I'm guessing that because I've marked the installer as x64, I will be forced to author another separate installer specifically for 32-bit systems, which only writes to HKLM/Software/Blablah.
The normal practise is to have both 32 bit and 64 bit install packages. On the 32 bit machine you just run the 32 bit package, on the 64 bit machine you run both.
Trying to handle all the registry and file redirection yourself is a nightmare and it's much better to install a 32 bit package on a 64 bit machine and let the system do the redirection for you. You've got to produce the 32 bit package anyway for 32 bit machines, so it's no extra work.

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