[IronPython] Getting type error when calling a .NET DLL interface.

Dave Fugate dfugate at microsoft.com
Mon May 4 09:10:32 PDT 2009


At first glance, I'd say there's no need for the "dssCatalog = IDSSCatalog(db)" line which doesn't work because you're attempting to instantiate an interface.  That is, if DSSDatabase truly implements IDSSCatalog; just call "db.MakeNewCatalog('')".

Dave

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Max Barry
Sent: Monday, May 04, 2009 7:28 AM
To: users at lists.ironpython.com
Subject: [IronPython] Getting type error when calling a .NET DLL interface.

Hi all,
I am trying to call an interface from DLL created in .Net to work with a IronPython script and am getting the following error when I run the code:

TypeError: Cannot create instances of IDSSCatalog

The trace is below:

Traceback (most recent call last):
  File ".\Tutorial\ShiftIntervalMaxValue.py", line 82, in RunApp  Process()
  File ".\Tutorial\ShiftIntervalMaxValue.py", line 97, in Process  dictgages = GetCatalogDictFromDSSRS(db,DSS_RS_FILTER)
  File ".\Tutorial\ShiftIntervalMaxValue.py", line 176, in GetCatalogDictFromDSS RS  ds = CatalogAsDataSet(db)
  File ".\Tutorial\ShiftIntervalMaxValue.py", line 198, in CatalogAsDataSet  dssCatalog = IDSSCatalog(db)
 TypeError: Cannot create instances of IDSSCatalog

Below is an example of the code that created the error:
import clr

def LoadTSMNet():
    import string,sys
    from os import path
    #from System.Reflection import Assembly      #Import .Net Assembly to import DLL

    mypath = path.dirname(sys.argv[0])
    tsmpath = path.join(mypath,"TimeSeriesMgrNet.dll")
    tsmpath = string.replace(tsmpath,'\\','\\\\')
    clr.AddReferenceToFileAndPath(tsmpath)
    #Assembly.LoadFile(tsmpath)

LoadTSMNet()
clr.AddReferenceByPartialName("TimeSeriesMgrNet")
import TimeSeriesMgrNet
from TimeSeriesMgrNet import IDSSCatalog, DSSDatabase

DSS_DATABASE_PATH = "C:/temp/myfile.dss"
db = DSSDatabase()
db.Name = DSS_DATABASE_PATH
db.Connect(False)
dssCatalog = IDSSCatalog(db)
dssCatalog.MakeNewCatalog('')
ds = dssCatalog.AsDataSet(True,'')
db.Disconnect()

IDSSCatalog is the interface and DSSDatabase implements the interface. Any ideas on why I am getting this error?

Thanks,
Max

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20090504/70698c88/attachment.htm>


More information about the Users mailing list