Add clr reference to WordPerfect dll using python
Question: After trying several variations on the theme of clr.AddReference, I am still
unable to add a reference to the "wpwin14.dll", which is the interop reference
for WordPerfect X4. I am using Eclipse on Windows, and other clr calls work
fine, so I assume my IronPython/IDE setup is fine. I have successfully added
that file name to Visual Studio for a project in VB.NET, so I believe that
file is the correct file to use.

The simple code I am using is this:

    
    
    import clr
    clr.AddReferenceToFile("wpwin14.dll")
    

I have also tried clr.AddReferenceToFileAndPath using the full path on my
machine. I have also tried these commands from the IronPython command line.

Just in case the wpwin14.dll file was not appropriate for the .NET reference,
I converted the associated wpwin14.tlb file into a dll, using the tlbimp
command. That did not work either.

The error message I get is this: IOError: System.IO.IOException: Could not add
reference to assembly wpwin14.dll

Am I missing something basic here?


Answer: Probably the easiest way to interact with the COM library would be to use
something like the following

    
    
    from System import Activator, Type
    shell = Activator.CreateInstance(Type.GetTypeFromProgID('Shell.Application'))
    

Just replace Shell.Application with the ProgID for the WordPerfect application
COM object. IronPython will take care of the method resolution when you start
calling methods.

