COM接口Photoshop兼容性问题

发布于 2024-11-06 07:14:47 字数 968 浏览 1 评论 0原文

我们正在为 Photoshop 编写一个简单的 .NET C# COM 应用程序,该应用程序设计为在从 CS2 到 CS5 以及之间的所有版本上运行。相同的应用程序也以 JavaScript 形式存在,并且它适用于所有上述版本,因为我们避免了实现特定于版本的功能。

我们遇到的问题与 COM 接口有关。例如,如果我们的应用程序是使用 Photoshop CSx 中的 Interop.Photoshop DLL 编译的,则它无法在 Photoshop CSy 上运行。这似乎是因为注册表 CLSID 特定于每个版本的 Photoshop,如果在安装了与我们编译的版本不同的 Photoshop 版本的系统上运行,则导致我们的应用程序无法找到正确的 COM 接口 DLL(假设两个应用程序是 32 位)。

如果这确实是问题所在,我们想知道是否可以使用 CSy CLSID 重新注册 Photoshop 版本 CSx 的 COM 接口,而忽略版本之间功能可能不同的事实。

更具体的信息如下:

我们的主要 Photoshop.Application CLSID 位于注册表中:HKEY_CLASSES_ROOT\Photoshop.Application\CLSID 此 CLSID 必须与构建我们的应用程序所针对的 CLSID 相匹配。例如,CS5 和 CS5.1 之间的此 ID 不同。

今天我们唯一的解决方案是为特定版本的 Photoshop 构建特定版本的应用程序,而这只有在我们安装了该特定应用程序版本的情况下才可能实现。

我们收到的错误代码是 0x80040154,“检索 CLSID {116EE066-135E-4F63-8D0E-78F62705FBFC} 的组件的 COM 类工厂失败”。该应用程序是使用 CS5.1 构建的,但在 CS5.04 上运行,导致找不到 COM 接口。此 CLSID 特定于 CS5.1。总之,我们需要重新注册 COM 接口以匹配 CS5.04 的 CLSID,以便能够在该特定版本上运行我们的应用程序。这可能还是有其他方法?

非常感谢我们能就此事获得任何帮助或提示。

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 CSx 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷港 2024-11-13 07:14:47

更改 COM 类和接口的 GUID 是一项硬性要求,它可以避免 DLL Hell。调用您现在正在处理的正常问题:版本地狱。当您尝试使用计算机上未安装的代码块版本时,您会收到诊断消息,而不是随机的无法诊断的故障。您无法可靠地重新注册,这可能会严重扰乱客户的机器。

是的,您可以按照 Javascript 的方式进行操作:使用后期绑定。您不使用互操作库。如果你使用4之前的版本,在C#中做起来是非常痛苦的,你必须使用反射。但使用 VB.NET 或 C# 版本 4 的 dynamic 关键字很容易做到。这篇知识库文章展示了使用旧方法在 C# 中进行后期绑定。使用dynamic关键字,您可以按照现在编写的方式编写代码,而不是对象创建语法。任何类型的版本不匹配问题仍然会导致异常,但仅限于属性或方法调用,并且仅限于运行时,而不是编译时。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文