All. net programs are platform-independent. The key is to check whether. Net VM supports the x64 platform. Ms has provided. Net x64. In vs, the. NET program is compiled into anycpu by default, so this is OK.
However, one of my C # programs calls the COM component of word2007 and calls some WIN32API. The problem arises. When running Windows 2003x64, the component whose clsin is {xxxxxx} in the com class factory fails to be retrieved because of the following error: 80040154.
The reason is very simple. The default value of C # program is anycpu. On x64, the program runs in 64-Bit mode. The 64-bit program cannot load 32-bit DLL. However, word2007 only has 32-bit DLL, so the call fails. The solution is very simple. It forces the C # program to be compiled into x86, so that the 32-bit Word 2007 dll can be loaded smoothly.
The modification method is as follows:
Set this compiler option in the Visual Studio development environment
Open the properties page of the project.
Click the generate property page.
Modify the "Target Platform" attribute.
For more references, see the msdn http://msdn.microsoft.com/zh-cn/library/zekwfyz4.aspx