如何在 C# 中添加对 Photoshop CS4 COM 的引用

发布于 2024-07-27 16:34:40 字数 414 浏览 4 评论 0原文

我在 Photoshop CS4 自动化方面遇到了一些问题。 当我想要在 Visual Studio 2008 项目中添加对 COM API 的引用时,Adobe Photoshop 对象库没有显示在“COM”选项卡下的“添加引用”面板中。 然而,Illustrator CS4 类型库显示得很好。 Photoshop 本身可以完美运行,无论是 32 位还是 64 位版本。 Photoshop 与 Master Suite CS4 的所有其他应用程序一起安装。

这在 Windows 7 和 Windows XP 上都不起作用,在 2 台不同的机器 + 1 台虚拟 PC(Vmware 工作站)上。 我也在VS2010 Beta 1和MS Word VB编辑器中尝试过,但在这里也不起作用。

有人有什么想法吗? 如果您能够添加参考,您的配置是什么?

I'm having a little problem with Photoshop CS4 automation. When I want to add a reference to the COM API in my Visual Studio 2008 project, the Adobe Photoshop Object Library doesn't show up in the "Add References" panel under the "COM" tab. However, the Illustrator CS4 Type library show up just fine. Photoshop itself run perfectly, both in the 32 and 64 bit flavor. Photoshop was installed along with every other app of the Master Suite CS4.

This didn't work on both Windows 7 and Windows XP, on 2 different machine + 1 virtual PC (Vmware workstation). I also tried it in the VS2010 Beta 1 and the MS Word VB editor, but it didn't work here either.

Anybody has any thought? If you were able to add a reference, what was your configuration?

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

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

发布评论

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

评论(2

放肆 2024-08-03 16:34:40

无需创建虚拟机,某些版本的 Photoshop 存在问题,COM 不显示,要更正此问题,请以管理员身份运行 Photoshop(仅一次),这将更正注册表项和 COM然后就可以使用了。

There is no need to create a Virtual Machine, there is a problem with some versions of Photoshop in as much the COM does not show, to correct this run Photoshop as Administrator (just the once) and this will correct the registry entries and the COM will then be available.

乱了心跳 2024-08-03 16:34:40

最后,解决方案是使用独立安装 Photoshop(而不是整个创意套件)的 Windows XP 虚拟机。 您可以使用它生成可在任何安装了 Photoshop CS4(独立版或创意套件)的任何 Windows 上运行的 dll。

整个过程

编辑:这是使用您最喜欢的虚拟化解决方案(Vmware、VirtualBox、VirtualPC 等)创建 Windows XP 虚拟机的 。 安装 Visual Studio 2008 和独立安装的 Photoshop CS4(整个创意套装在我的情况下不起作用,但您的情况可能会有所不同)。 打开 Visual Studio 并创建新的 VB.NET 或 C# 类库。 完成此操作后,右键单击解决方案资源管理器中的“引用”文件夹,然后选择添加引用。 转到 COM 选项卡,然后搜索“Adobe Photoshop CS4 类型库”。 这将添加两个新引用:“Photoshop”和“PhotoshopTypeLibrary”。 创建一个虚拟函数(尽管可能不是必需的)并构建您的项目。 作为一个好的措施,您可以确保编译模式设置为“release”,但这不是必需的,调试可以正常工作。 构建项目后,转到 VM 硬盘上的项目文件夹并查找 bin\release 文件夹。 在那里您将看到 3 个 dll:一个以您的项目命名,一个名为 Photoshop.dll,另一个名为 Interop.Photoshop.dll。 将最后两个复制到装有 Windows 7 x64 的开发计算机上。 然后,您可以通过添加引用并浏览到这 2 个 dll 将它们导入到您的项目中。

我注意到的一件非常甜蜜的事情是,尽管 dll 是在 32 位 VM 上编译的,但如果您的 .NET 程序在 64 位模式下运行,它们仍然会调用 64 位版本的 Photoshop。

我希望它有帮助!

In the end, the solution was to use a Windows XP Virtual Machine with a standalone installation of Photoshop (instead of the whole creative suite). You can use it to generate a dll that work on any Windows with any installation of Photoshop CS4 (standalone or the creative suite).

EDIT : Here is the whole process

Create a Windows XP virtual Machine with your favorite virtualisation solution (Vmware, VirtualBox, VirtualPC etc). Install Visual Studio 2008 and a standalone installation of Photoshop CS4 (The whole creative suits haven't worked in my case, but your mileage may vary). Open Visual Studio and create either a new VB.NET or C# class library. Once this is done, right click on the "reference" folder in the solution explorer, and select add reference. Go to the COM tab, and search for "Adobe Photoshop CS4 type library". This will add two new references : "Photoshop" and "PhotoshopTypeLibrary". Create a dummy function (altough it may not be required) and build your project. As a good mesure, you can make sure that the compile mode is set to "release" but this is not required, debug will work fine. Once your project is builded, go to your project folder on your VM hard drive and look for the bin\release folder. There you will see 3 dll : one named after your project, one named Photoshop.dll and another namde Interop.Photoshop.dll. Copy the two last on your developpement machine with Windows 7 x64. You can then import them in your project by adding a references and browsing to those 2 dll.

A very sweet thing I noticed was that altough the dll were compiled on a 32 bit VM, they would still call the 64 bit version of Photoshop if your .NET program runned in 64 bit mode.

I hope it help!

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