开发者

COM interface Photoshop compatibility issue

开发者 https://www.devze.com 2023-03-04 16:00 出处:网络
We\'re writing a simple .NET C# COM applicaton for Photoshop, which is designed to run on all versions from CS2 to CS5 and everything in between. The same application also exists in JavaScript form an

We're writing a simple .NET C# COM applicaton for Photoshop, which is designed to run on all versions from CS2 to CS5 and everything in between. The same application also exists in JavaScript form and it works with all aforementioned versions, as we've avoided to implement version specific functionality.

The problem we've run into is related to the COM interface. For instance, if our application is compiled with the Interop.Photoshop DLL from Photoshop CSx, it does not run on Photoshop CSy. This seems to be because the registry CLSID is specific to each version of Photoshop, causing our application to not find the correct COM interface DLL, if run on a system where a different version of Photoshop than what we compiled for is installed (assuming both applications are 32 bit).

If this is indeed the problem, we are wondering if it would be possible to re-register the COM interface of Photoshop version C开发者_StackOverflowSx with the CSy CLSID, ignoring the fact that functionality may differ between versions.

More specific information follow:

Our primary Photoshop.Application CLSID is located here in the registry: HKEY_CLASSES_ROOT\Photoshop.Application\CLSID This CLSID must match the CLSID for which our application was built for. For instance, this ID differs between CS5 and CS5.1.

Our only solution today is to build specific versions of our application for specific versions of Photoshop, and this is only possible if we have that specific application version installed.

The error code we are getting is 0x80040154, "Retrieving the COM class factory for component with CLSID {116EE066-135E-4F63-8D0E-78F62705FBFC} failed". This application was built with CS5.1 but run on CS5.04 which resulted in the COM interface to not be found. This CLSID is specific to CS5.1. In conclusion, we need to re-register the COM interface to match the CLSID of CS5.04 to be able to run our application on that specific version. Is this possible or is there another way?

Any help or hint we can get on the matter is extremely appreciated.


Changing the GUIDs of COM classes and interface is a hard requirement, it avoids DLL Hell. To invoke the normal problem you are dealing with right now: Version Hell. When you try to use a version of a chunk of code that's not installed on the machine you get a diagnostic message instead of random undiagnosable failure. You cannot reliably re-register, that can seriously mess up your customer's machine.

Yes, you can do it the way Javascript does it: use late binding. You don't use the interop library. It is very painful to do in C# if you use a version earlier than 4, you have to use reflection. But easy to do with VB.NET or with C# version 4's dynamic keyword. This KB article shows late binding in C# using the old way. With the dynamic keyword you can write the code you way you have it written now, other than the object creation syntax. Any kind of version mismatch problem will still cause an exception but only at the property or method call and only at runtime, not compile time.

0

精彩评论

暂无评论...
验证码 换一张
取 消