I'm trying to use code from a C# .dll in Python.
The class has the constructor protected, so the only way to get the instance is by calling the static method Instance (see source code sample below).
In python, I'm using clr library to load the .dll, and I tried to invoke the instance like this:
import clr
clr.AddReference("Common.Namespace")
from CommonNamespace import Common
instance = Common.Instance
but I get the following error:
TypeError: Exception has been thrown by the target of an invocation.
I'm trying to resolve this for quite some time - with different approaches as well - but without any luck...
Sample of the source code from my .dll:
namespace CommonNamespace
{
public class Common
{
private static Common instance;
public static Common Instance
{
get
{
if (Common.instance == null)
Common.instance = new Common();
return Common.instance;
}
}
protected Common()
{
}
}
}
Could somebody help me?
Thank you!
Note: I want to call a static method of a non-static class, while the constructor is protected