Im using a 3rd party dll for some operations, the instance of the class is static and from time to time is crashing. I was thinking if there is a way to reinstantiate the class via Reflection.
I used DotPeek to check the library and it looks something like this:
public class C_SomeWrapper
{
private static C_SomeWrapper _instance;
public C_SomeWrapper()
{
InitStuff();
}
void InitStuff()
{
}
public void Destroy()
{
C_SomeWrapper._instance = (C_SomeWrapper)null;
}
public static C_SomeWrapper Instanse
{
get
{
if (C_SomeWrapper._instance == null)
C_SomeWrapper._instance = new C_SomeWrapper();
return C_SomeWrapper._instance;
}
}
}
When i reference to it i do :
C_SomeWrapper _wrapper=C_SomeWrapper.Instanse
Since is crashing i would like to Destroy() and re-instantiate the constructor.
I was thinking maybe is posible to acces _instance
and make it null via Reflection.
Id like to mention that just Destroy() doesnt work so probably i need to call the constructor and to InitStuff()
Any toughts on if its posible or not or maybe some alternatives
Thanks