问题
I use around 15-20 legacy 32-bit C++ COM DLLs in my web app, some of these 32-bit DLLs have 3rd party dependencies which are further DLL's COM or native.
I am considering moving to Windows Azure which I understand is a 64-bit platform. Can anyone advise whether my 32-bit DLLs will work? (I know that it is now possible to regsvr32 them).
With a week or two’s work I could recompile my DLLs to 64-bit however this is not possible for the 3rd party dependencies as I don’t have the source.
I understand that Windows Azure uses 64-bit so I am wondering what would be the best approach here to migrate my app?
i.e. should I move the 32-bit DLLs over and rely on WoW64 – will this even work? I don’t mind a small performance hit.
Or would be it better to recompile my 64-bit apps and somehow use the 32-bit DLLs?
回答1:
The answer is yes. Windows Azure is just like a normal Windows Server 2008 x64, and it has 32-bit subsystem. The only limitation here is that the web role and worker role hosting process is 64 bit.
With this in mind, you will have to do some sort of interop between 64-bit host process and 32-bit DLLs. Of course, inproc COM objects will not work in this case. It is hard to give more specific advise here without knowing details:
- What type of COM interfaces (automation compatible or not)?
- What kind of marshaling they support (inproc only or out-of-proc)
- If marshaling works across processes, do you have control on how to register objects (inproc or out-of-proc).
- How easy is it to create managed wrapper for your object (like a custom C++/CLI interop assembly that is hosted by 32-bit process and able to communicate to 64-bit host using either WCF or COM automation)
I don't know if it would work, but another option to consider is try to coerse your application pool to run as 32 bit process. You will need to run in IIS mode with full trust and run this as your role startup task:
appcmd apppool set /apppool.name: /enable32BitAppOnWin64:true
You will have to determine name of application pool your app will be used. And again, I'm not sure that would work at all, but I guess it worth a try, because if it works it would be the easiest option for you.
回答2:
This lab "Advanced Web and Worker Roles" in the Windows Azure Training Kit covers using a Legacy COM dll in Azure.
来源:https://stackoverflow.com/questions/5443399/32-bit-legacy-com-dlls-on-windows-azure