How to add a link to Photoshop CS4 COM in C #

I have a little problem with Photoshop CS4 automation. When I want to add a link to the COM API in my Visual Studio 2008 project, the Adobe Photoshop object library does not appear in the Add Links panel on the COM tab. However, the Illustrator CS4 Type library renders very well. Photoshop itself works great in both 32 and 64-bit tastes. Photoshop was installed along with all other Master Suite CS4 applications.

This did not work on both Windows 7 and Windows XP on two different machines + 1 virtual PC (Vmware workstation). I also tried it in VS2010 Beta 1 and in MS Word VB editor, but it did not work either.

Does anyone think? If you could add a link, what was your configuration?

+4
source share
2 answers

There is no need to create a virtual machine, there is a problem with some versions of Photoshop, since COM does not show to fix this launch of Photoshop as an administrator (only once), and this will fix the registry entries and then COM will be available.

+5
source

In the end, the solution was to use a Windows XP virtual machine with a standalone Photoshop installation (instead of the entire creativity kit). You can use it to create a dll that works on any Windows with any installation of Photoshop CS4 (stand-alone or creative package).

EDIT: Here is the whole process

Create a Windows XP virtual machine with your favorite virtualization solution (Vmware, VirtualBox, VirtualPC, etc.). Install Visual Studio 2008 and the standalone installation of Photoshop CS4 (all the creative costumes in my case did not work, but your mileage may vary). Open Visual Studio and create a new VB.NET or C # class library. Once this is done, right-click on the "reference" folder in the solution explorer and select the link. Go to the COM tab and find "Adobe Photoshop CS4 Type Library." This will add two new links: "Photoshop" and "PhotoshopTypeLibrary". Create a dummy function (although this might not be necessary) and create your own project. As a good measure, you can make sure that the compilation mode is set to “release”, but this is not required, debugging will work fine. Once your project is built, go to the project folder on your VM hard drive and find the bin \ release folder. There you will see 3 dlls: one of them is named after your project, one of which is called Photoshop.dll and the other is namde Interop.Photoshop.dll. Copy the last two on your development machine with Windows 7 x64. Then you can import them into your project by adding links and viewing these 2 dlls.

The very nice thing that I noticed was that, despite the fact that the dlls were compiled on a 32-bit virtual machine, they will still invoke the 64-bit version of Photoshop if your .NET program started in 64 mode bit.

Hope this helps!

+3
source

All Articles