2009-01-13 51 views
-2

这是我的代码:帮助中FileNotFoundException异常-python

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 " 

我TCdll是在C:\ test.I只是把它作为C:\ teest知道错误。

例外是这样的:

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) 

如何处理这个异常?

帮助需要立即

回答

4

你需要找出clr.AddReference如何映射到一个文件名。

编辑:

我想你问如何抓住从AddReference呼叫例外呢?

替换:

clr.AddReference("TCdll") 

有:

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