I am calling the C# dll from python and then loading the python module in National Instruments Test Stand. I am getting the same exceptions in python and in Test Stand. When I run the program in C# only there isn’t a problem, it works the way it shouldenter image description here
I attached a screenshot of the error in 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()
I am not sure what to try to find what is causing the problem. I would appreciate any suggestions on what it could be. I know that python strings are UTF-8 and C# is UTF-16 but I tried reading a C# string in Python and it worked. I’m not sure if it creates a problem though in the path.combine function.
Thanks
VCU is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.