I've been trying to write some code to interact with Photoshop, both by adding a COM reference and by late binding. It took me a while to realise that the code did work, but not with the 64-bit version of Photoshop.
The exception I get with 64-bit Photoshop is as follows:
COMException was unhandled
Retrieving the COM class factory for component with CLSID {D9389EDE-AEF8-4092-9377-075E94B7CB9A} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Is it possible for my application to communicate with the 64-bit version of Photoshop? Or is it limited to just communicating with the 32-bit version?
I've come across this in one of my numerous attempts to find a solution, but I don't see how I could put the CLSCTX_ACTIVATE_64_BIT_SERVER
flag into use with either a COM reference or late binding, well, supposing that it is the solution.
The exception occurs here:
Type photoshopType = Type.GetTypeFromProgID("Photoshop.Application");
if (photoshopType != null)
{
object photoshop = Activator.CreateInstance(photoshopType);
.NET application executables (.exe) will always run in the native bitness of the running processor architecture if marked for AnyCPU, which compiles down to MSIL. So any MSIL assembly running on a 64-bit platform will run 64-bit, and on a 32-bit platform will run 32-bit.
In your case you'd either want to compilre for AnyCPU, but if you must force a 64-bit interop use x64. This won't work on a 32-bit machine, of course. This will natively read from the 64-bit view of the registry (including InProc
You must also be careful of how pointers are marshaled. Be sure to use IntPtr for handles if writing your own interop proxy.
Couple of things to check for using COM from/to different environments:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With