This question is related to sensible data that I cannot share, but the question is pretty simple. I'm working on PyCharm 2017.1.2, python 2.7.13.
I have a file in a specific format (kind of an encrypted XML, unparsable), that needs to be converted into Excel to modify some values and then export it back to this original format. For some security reasons, I just cannot go around this conversion. All good, I have an Excel add-in that I can use for this, inside two C# DLLs, that does 'import' into the Excel format and 'export' it back to the weird XML.
I cannot use IronPython either because the software I'm designing uses library IronPython just can't manage, so I'm stuck with good old Python 2.7.
I'm currently using the clr module from pythonnet to import the DLLs into my software. The import code (not sensible) looks like this :
import clr
import sys
sys.path.append('C:/My/Path/To/The/DLLs/Folder')
clr.AddReference('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
clr.AddReference('My.ClassLib.DLL')
clr.AddReference('My.ExcelImportExport.DLL')
import Microsoft.Office.Interop.Excel as Excel
try:
from My.ClassLib.DLL import XMLParser
import My.ExcelImportExport.DLL
from My.ExcelImportExport.DLL import DeviceSettingsUtility
except Exception, e:
print unicode(e)
Both DLLs I'm working with are located in the same folder. CLR has no problem adding the DLLs reference.
What is weird : everything works fine with the 'My.ClassLib.DLL' : I can access its classes and methods without any issues.
But as soon as I try import My.ExcelImportExport.DLL or the line after, I've got an ImportError: No module named My.ExcelImportExport.DLL. When, after adding reference with clr, I list all the assemblies, I see both My.ClassLib.DLL and My.ExcelImportExport.DLL, so the problem doesn't come from here. The problem as to come from the My.ExcelImportExport.DLL.
I've looked both DLLs with a decompiler and haven't found anything that makes the ClassLib.DLL work and would explain why the other one doesn't.
Finally, my question : What needs to be in the DLL (C# code) for clr to be able to import it?