How to switch VS Project from 32bit to 64bit? - wpf

I am having trouble moving my WPF project from 32 bit to 64 bit. I recently realized I need my program to be able to use more than 2gb of memory.
What I did was I changed my project's platform target from Any CPU (with preferred 32 bit checked) to x64.
I then got an error stating “XXX” does not exist in the namespace “XXX" and realized it was probably because I did not change the CPU target for my other libraries.
Then when I launched the program in my developer machine, it works perfectly fine using both visual studio and Click Once installing after deploying. However, when I test the deployed executable using a few different 64 bit machine, the program starts behaving erratically with some functions not working properly.
I have no idea how to debug since it works perfectly fine in my developer machine but not on any other computer? Am I not changing the target platform correctly?

The assembly ITSELF built by youself when targeting "Any CPU", but you should check out every third-party assemblies that used in your project if they are targeting "x86". If you change the target of your own project to "x64", make sure all of the dependencies are for "Any CPU" or "x64".

Related

PINTERFACE_REFERENCE and MinGW W64

I'm trying to compile my working 32-Bit DLL project which communicates with USB-Devices to a 64-Bit Windows-DLL.
The sources compile fine with MinGW32 but if I try to build them with MinGW W64 I get an error within hidclass.h:
hidclass.h|132|error: unknown type name ‘PINTERFACE_REFERENCE’
I can't find anything about PINTERFACE_REFERENCE so I'd be glad for every hint about this.
Building it in 32-Bit is not an option because it will be used within Java via JNI and I have to support both 32- and 64-Bit JVMs.
I know that I could do minor changes to my code and switch to Microsofts Visual C++ compiler using VisualDDK and the Windows Driver Kit but I'd love to continue using my free toolchain since it works flawless for 32-Bit builds and I don't have to think about licensing issues.

How to create an application which contains 32bit and 64bit binaries, and runs the appropriate of them on the OS?

I made an application, and i had to compile a 32bit and a 64bit version of it. I saw some application, like ProcessExplorer acting as follows. On 32bit OS it runs a 32bit app, but on a 64bit OS it extracts a 64bit version of the same exe and this will be executed. So how can i make such an application from my app? What settings should i make in Visual Studio?
Process explorer works like this:
You download a single 32 bit executable.
When you run that executable on a 32 bit OS, that's it.
When you run that executable on a 64 bit OS, the 32 bit process detects that on startup and to disk extracts a 64 bit executable that is stored as a resource in the 32 bit process. And then it runs that 64 bit executable.
There aren't any settings in Visual Studio that would automate that process for you. You'd have to write that part for yourself. You could have a build process that built the 64 bit version first. And then you could compile that executable into a resource which you link into your 32 bit process. Which is what you ship.
I myself am not convinced it's worth all the effort. Personally I'd be inclined to ship two different executables, but I guess only you know your own requirements.
Why not get the installation program to install the appropriate version depending on the OS and give that executable the same name for either OS?

Flash ocx "Class not registered" on Windows 7 x64

I have a WPF app that uses Flash10c.ocx developed on a 32 bit machine. I didn't have to register the ocx on my dev machine, I just installed the latest flash, added a reference and started coding. When testing on a 64 bit system I get ye old "Class not registered" which I think mean I need to regsvr the ocx. Is it Ok to just copy the 32 bit ocx (I'm pretty sure its 32 bit as its located in C:\Windows\System32\Macromed on the dev system) to a 64 bit system and register it?
Update: regsvr32 /i flash10c.ocx errors out with "The module flash10c.ocx las loaded but the call to DllRegisterServer failed with error code 0x80004005"
Update 2: I've given up on this and decided to run Flash on 32 bit systems only. If anyone has a better answer I'd like to hear it but I'm marking the current suggestion as answered to give due credit for the effort.
The reason it's not working for you is that your WPF application is running as 64-bit.
A .NET application is able to run as 32-bit or 64-bit; and the CLR is JITing your app to whatever architecture the application is running on - in this case 64-bit.
Except you now want your 64-bit application to load a 32-bit dll. This is not possible. A 64-bit process can only load 64-bit dlls. A 32-bit process can only load 32-bit dlls. No amount of fiddling with COM object registration will change this; it's not a question of missing registry entries.
Adobe Flash only comes as a 32-bit dll. Adobe does not now (and hopefully will never) have a 64-bit version.
In order for your WPF .NET application to load the 32-bit flash dll, it needs to be running as 32-bit process. There is a way, in Visual Studio's build configuration, to force your .NET application to only target x86, rather than Any CPU.
The choices of CPU targets are:
Any CPU
x86
x64
Itanium
Flash, for what it's worth, doesn't have an Itanium version, either.
See StackOverflow: Visual Studio “Any CPU” target for more discussion about target cpus.
May be the flash installer is meant to be only for 32 bit OS. Hence it did not install properly on a 64 bit machine. The error means that you will need to manually register the ocx but will it register successfully that's a totally different question.
Edit 1: here is Adobe's statement of support for 64-bit systems (there is none) (I assume you are using 64 bit browser on a 64 bit machine)
Edit 2: Another forum message about Flash on 64-bit Windows.

How to cross-compile 64bit DLL with VS 2005 on 32bit computer?

Using Visual Studio 2005, I wrote a simple DLL in C that uses the Windows API to send UDP datagrams and that is hooked into a third-party program. On a 64 bit machine, it does not work at all, as the third-party code was compiled for 64 bit in this case. So I need to ship two versions of the same DLL - one for 32 bit, one for 64 bit.
However, I did not manage to get Visual Studio (running on a 32 bit machine) to spit out a DLL that is not identical to the 32 bit version - it seems the 'machine' setting in the project properties is simply ignored. A colleague told me VS 2008 simply refuses to cross-compile in this scenario. Is this really not possible at all?
Right click the project in the Solution Explorer then go Properties / Configuration Manager / Active Solution platform: <New...> / x64 / OK / Close. Then select x64 in Platform, OK, and you're good to go.

How to get xp_pcre to run on a 64 bit system?

For many years we have been using xp_pcre for regular expressions in sql server:
xp_pcre - Regular Expressions in T-SQL
I've just migrated to a new 64 bit vista development machine and have installed xp pcre. Unfortunately when i try to use the sprocs I get the following error: Could not load the DLL xp_pcre.dll, or one of the DLLs it references. Reason: 193(%1 is not a valid Win32 application.).
Has anyone had any success installing xp_pcre on a 64 bit machine running vista? Any advice? Thanks in advance,
Shane
Since it's a compiled DLL, you would probably have to recompile it to get a 64 bit DLL, that could be run on your 64 bit machine. Since nothing at that page has been updated since 2005, it's unlikely there is an already a prebuilt version for 64 bit. However, since the source code is included, you could, if you have VS for C++, with a 64 bit compiler, compile it yourself and try to get it working that way.

Resources