How to use custom python library that import dotnet dll

Hi,

I have created few month ago some robot test case that using a custom library in python.
That python script is a wrapper with a dll in .Net 4.8

This was working correctly and I was able to execute my test cases as expected.

The .Net library has moved to .Net 7.
From the python wrapper, after some modification, we are able to import the .Net library
But if I try to execute the same robot test cases, now, I have the following issue:

failed: ModuleNotFoundError: No module named ‘MyClass’

  • robot sample test case:

    *** Settings ***
    Library Collections
    Library …/core/wrapper/test_interface.py

    *** Test Cases ***
    Check Build Version
    test_interface.Get Version

  • python script to import dll

    import clr
    import numpy as np
    from time import sleep
    from robot.api.logger import info, debug, trace, console
    from robot.api.deco import keyword
    import logging

    dll = clr.FindAssembly(r"myDLL")
    clr.AddReference(dll)
    from myDLL import myClass

I’m using python 3.12 32 bits has the dlls are build in 32 bits, and i have the following package for ptython
numpy==2.1.3
pythonnet==3.0.4
robotframework==7.1.1

Can someone have some advise on my case ?

Thanks in advance

1 Like

Hi,

I got my answer, for a better code, I had moved the reference of the dll into init.py and robot do not manage it automatically as a python module.
I need to import init.py as library in the robot file and that works correctly