Я вызываю DLL C# из Python, а затем загружаю модуль Python v3.11 в National Стенд для испытаний приборов. Я получаю одни и те же исключения в Python и на тестовом стенде. Когда я запускаю программу только на C#, проблем нет, она работает так, как должна
Я прикрепил скриншот к ошибке на Python.
Код: Выделить всё
import pythonnet
import os
pythonnet.load("coreclr")
from clr_loader import get_coreclr
import clr
import sys
#USING PYTHONNET LIBRARY
class CSharpAsmblyRefs:
#assembly_ConfigMngr_path = (r"C:\\source\\repos\\Host\\Tools\\TestFramework.Test\\bin\\x64\\Debug\\net6.0-windows\\")
def __init__(self):
assembly_Config_path = (r"C:\\source\\repos\\Host\\Tools\\TestFramework.Test\\bin\\x64\\Debug\\net6.0-windows\\")
assembly_CSharpdll_path = (r"C:\\source\\repos\\Host\\Console.Test\\Host\\Common\\DiagTestClients\\ScriptingClientLib\\bin\\x64\\Debug\\net6.0-windows10.0.19041.0\\")
sys.path.append(assembly_CSharpdll_path)
cwd = os.getcwd()
clr.AddReference("ScriptingClientLib")
clr.AddReference("NGPV.Common.ProtoDefinition")
clr.AddReference("NGPV.Common.RPC")
clr.AddReference("NGPV.Common.TraceListener")
clr.AddReference("NGPV.Common.UIBase")
clr.AddReference("ScriptingCommander")
clr.AddReference("Diag")
from ScriptingClientLib import ScriptingClient
clr.AddReference("NGPV.Common.AppConfig")
#from NGPV.Common.AppConfig import ProductPaths
#self.pp = ProductPaths()
sys.path.append(assembly_Config_path)
clr.AddReference("System.Configuration.ConfigurationManager")
from System.Configuration import ConfigurationManager
scrptClient = ScriptingClient()
scrptClient.RunAsync("Initialize.csx")
def loadRefdlls(self):
clr.AddReference("ScriptingClientLib")
from ScriptingClientLib import ScriptingClient
clr.AddReference("NGPV.Common.AppConfig")
clr.AddReference("NGPV.Common.Helper")
#from NGPV.Common.AppConfig import ProductPaths
self._ConfigMngrRef = clr.AddReference("System.Configuration.ConfigurationManager")
from System.Configuration import ConfigurationManager
#self.pp = ProductPaths()
scrptClient = ScriptingClient()
scrptClient.RunAsync("Initialize.csx")
def importClasses_callRunAsyncFunc(self):
from ScriptingClientLib import ScriptingClient
#from NGPV.Common.AppConfig import ProductPaths
from System.Configuration import ConfigurationManager
self.scrptClient = ScriptingClient()
self.callRunAsync(scrptClient)
def callRunAsync(self):
scrptClient = ScriptingClient()
scrptClient.RunAsync("Initialize.csx")
sc = CSharpAsmblyRefs()
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/785 ... -func-from