# Use COM from .Net¶

COM was intended to provide a unified access model across different programming languages. While this might not be perfect, it usually works pretty well.

## Problems with COM from .Net¶

Unfortunately, Microsoft has decided to go a different path when accessing .Net assemblies providing COM interop from another .Net language. You will not be able to add a COM reference, but will be forced to add an assembly reference instead. This might work in many cases, but often enough it doesn’t. As it turns out, it does not work for PDFCreator.

PDFCreator relies on different files being present in the folder where the executables are located (helper applications, native libraries etc.). When adding an assembly reference from your project, the assembly files will be copied to your build folder and thus detached from the rest of PDFCreator. This will result in errors, i.e. that PDFCreator.exe or Ghostscript can’t be found.

We do not know why Microsoft took that decision, but it is there since the very first version of COM in .Net, so it most likely will stay this way and we have to live with it.

## Avoid the problems with late binding¶

Fortunately, you can trick the .Net detection by using late binding and the dynamic keyword.

First, you have to get the type using the PDFCreator ProgID. You can then create an instance of that type using the Activator. You can then use all methods of the COM interface.

Type queueType = Type.GetTypeFromProgID("PDFCreator.JobQueue");
dynamic queue = Activator.CreateInstance(queueType);

queue.Initialize();

Type queueType = Type.GetTypeFromProgID("PDFCreator.JobQueue");