IronPython and instances of COM objects

I am using IronPython 2.0 in the SharpDevelop 3.1 console window. I am trying to reference and use the CDO Redemption replacement library.

The standard use of the library is to instantiate an RDOSession object, and then use the methods of that object to navigate the RDO object model.

I registered the Redemption COM dll and referenced it from the project that created the interop assembly for it. In the IronPython console window, I do the following: import clr clr.AddReferenceToFileAndPath (r'd: \ SharpDevelop Projects \ TestPython \ TestPython \ obj \ Debug \ Interop.Redemption.dll ') Import Redemption

It still works. The next step would be to get the RDOSession object and instantiate it. If this worked, I would think so:

session = Redemption.RDOSession ()

However, this gives an error: TypeError: cannot create instances of RDOSession

So my question (or was): how to instantiate an object as an RDOSession?

However, I simply answered my question, trying to explain it. I will continue the answer because, although it is almost stupid to do this, it may be useful to someone else.

When I went to enter the string "session = Redemption.RDOSession ()", callTip came up with "RDOSession" and also "RDOSessionClass" right below it. I don’t know how the latter was created, but it sounded like an object that can be realistic (if that word).

→> session = Redemption.RDOSessionClass ()

<P → →

Here it is. The Logon method call worked as a member of a new session object.

Thanks stackoverflow!

+3
1

:

session = Redemption.RDOSessionClass()
0

Source: https://habr.com/ru/post/1708265/


All Articles