views:

405

answers:

1

This is my code:

try:
    import clr, sys
    from xml.dom.minidom import parse
    import datetime
    sys.path.append("C:\\teest")
    clr.AddReference("TCdll")
    from ClassLibrary1 import Class1
    cl = Class1()
except ( ImportError ) :
    print "Module may not be existing "

My TCdll is in C:\test.I just gave it as C:\teest to know the error.

Exception is this:

   Traceback (most recent call last):
      File "C:/Python25/13thjan/PSE.py", line 8, in <module>
        clr.AddReference("TCdll")
    FileNotFoundException: Unable to find assembly 'TCdll'.
       at Python.Runtime.CLRModule.AddReference(String name)

How to handle this exception ??

Help needed immediately

+4  A: 

You need to find out how clr.AddReference maps to a file name.

EDIT:

I think you're asking how to catch the exception from the AddReference call?

Replace:

clr.AddReference("TCdll")

with:

try:
    clr.AddReference("TCdll")
except FileNotFoundException,e:
    print "Failed to find reference",e
    sys.exit(1)
Douglas Leeder