title: Calling C# code from python using pythonnet
body: <p>Following is the C# code. How do I call the GenericMethod() inside the NonGenericClass from Python using pythonnet?</p>
  
  <pre><code>namespace CSharpTestCode
  {
      public interface Person
      {
      }
  
      public class Employee : Person
      {
      }
  
      public class TempGenericClass&lt;T&gt;
      {
      }
  
      public class NonGenericClass
      {
          public static T GenericMethod&lt;T&gt;(TempGenericClass&lt;T&gt; tempGeneric) where T : class, Person
          {
              return null;
          }
      }
  }
  </code></pre>
  
  <p>Python code that I tried:</p>
  
  <pre><code>import clr
  clr.AddReference(r'\Documents\visual studio 2015\Projects\SamplePythonApp\CSharpTestCode\bin\Debug\CSharpTestCode.dll')
  from CSharpTestCode import *
  
  genericMethod = NonGenericClass.GenericMethod(TempGenericClass[Employee]())
  </code></pre>
  
  <p>Error that I got:</p>
  
  <pre><code>Unhandled Exception: System.ArgumentException: GenericArguments[0], 'CSharpTestCode.TempGenericClass`1[CSharpTestCode.Employee]', on 'T GenericMethod[T](CSharpTestCode.TempGenericClass`1[T])' violates the constraint of type 'T'. ---&gt; System.Security.VerificationException: Method CSharpTestCode.NonGenericClass.GenericMethod: type argument 'CSharpTestCode.TempGenericClass`1[CSharpTestCode.Employee]' violates the constraint of type parameter 'T'.
     at System.RuntimeMethodHandle.GetStubIfNeeded(RuntimeMethodHandleInternal method, RuntimeType declaringType, RuntimeType[] methodInstantiation)
     at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
     --- End of inner exception stack trace ---
     at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
     at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
     at Python.Runtime.MethodBinder.MatchParameters(MethodInfo[] mi, Type[] tp)
     at Python.Runtime.MethodBinder.Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, MethodInfo[] methodinfo)
     at Python.Runtime.MethodBinder.Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, MethodInfo[] methodinfo)
     at Python.Runtime.MethodObject.Invoke(IntPtr target, IntPtr args, IntPtr kw, MethodBase info)
     at Python.Runtime.MethodBinding.tp_call(IntPtr ob, IntPtr args, IntPtr kw)
  </code></pre>