'ModuleNotFoundError: No module named 'CalcTestNS'

I am trying to read a DLL file using pythonnet library. The DLL file was generated using .NET framework 5.0 using the simple code below.

using System;

namespace CalcProcess
{
    public class Calculate
    {
        public int Add(int a, int b)
        {
            return a + b;
        }

        public int Sub(int a, int b)
        {
            return a - b;
        }
    }
}

When trying to read object using the library as seen in the code below:

import sys

import clr

assembly_path = r"C:\Users\username\Source\Repos\CalcProcess\bin\Debug\net5.0"
sys.path.append(assembly_path)

#calling the dll file in the dll folder below
clr.AddReference("dll/CalcProcess")
from CalcProcess import Calculate

obj = Calculate()

print(obj.Add(1,2))

The line of code below gives the error in the topic below

from CalcProcess import calculate

Any idea why?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source