etfovac / lv-net-dll-py

Access a .NET DLL (with LabVIEW classes) in Python

Home Page:https://etfovac.github.io/lv-net-dll-py/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.NET DLL (with LabVIEW classes) in Python License: MIT DOI

Access a .NET DLL (with LabVIEW classes) in Python

    ca_obj = ClientApp1Lib.ClientApp1Lib.ClientApp1()  
    # alas, it calls "new" which triggers file search popup window (known LabVIEW class issue)  
    # so start with a non initialized obj ref and use Create.vi to initialize the LabVIEW class ref
    ca_obj = AssemblyLib.ClientApp1Lib.ClientApp1  
    ca_Type = clr.GetClrType(AssemblyLib.ClientApp1Lib.ClientApp1) # get type  
    print(ca_Type.FullName, "\t", ca_Type)  
    # GetUninitializedObject to avoid constructor and 'new' issue  
    ca_obj = System.Runtime.Serialization.FormatterServices.GetUninitializedObject(ca_Type)  
    print(ca_obj.IsValid(), "\t", ca_obj) # False
    ca_obj = AssemblyLib.ClientApp1Lib.ClientApp1.Create(ca_obj, ca_obj)
    print(ca_obj.IsValid(), "\t", ca_obj) # True

Note: For more on the constructor node issue in VS see 'new' triggers browsing to lvclass file on disk

Dependency

ClientApp1.dll (my InteropAssembly example)

References

ConsoleApp_RA_e0/Program.cs (my C# Console example)
How to call a dynamic library (pythonnet wiki)
python for net how to explicitly create instances of csharp classes (stackoverflow qa)

About

Access a .NET DLL (with LabVIEW classes) in Python

https://etfovac.github.io/lv-net-dll-py/

License:MIT License


Languages

Language:Python 100.0%