title: How to delegate all method calls to C# DLL in Python
body: <p>I want to delegate all method call to C# DLL that we have written. I am using pythonnet to load the DLL file and call the methods from the DLL.</p>
  
  <p>This is my python class and it works fine,</p>
  
  <pre><code>import clr
  clr.AddReference('MyDll')
  from MyDll import MyLibrary
  
  
  class MyProxy:
      def __init__(self):
          self.lib = MyLibrary()
  
      def method1(self, first_arg, *args):
          self.lib.method1(first_arg, args)
  
      def method2(self, first_arg, *args):
          self.lib.method2(first_arg, args)
  </code></pre>
  
  <p>But I am not doing anything in python code except making a call to dll methods, so I don't want to write wrapper methods for all the methods in dll.</p>
  
  <p>The above approach allows me to call python methods like, <code>MyProxy().method1(first_arg, arg2, arg3, arg4)</code>, which in turns passes the <code>first_arg</code> as the first argument and <code>arg2, arg3, arg4</code> as an array in the second argument to <code>self.lib.method1(first_arg, args)</code>. </p>
  
  <p>This behavior is necessary for me because all of my C# methods have signature <code>method1(String first_arg, String[] other_args)</code></p>
  
  <p>How can I achieve this by only implementing <code>__getattr__</code> in my python class?</p>
  
  <p>I have tried the below approach, but it throws error "No matching methods found",</p>
  
  <pre><code>class MyProxy:
      def __init__(self):
          self.lib = MyLibrary()
  
      def __getattr__(self, item):
          return getattr(self.lib, item)
  </code></pre>
  
  <p><strong>Edit:</strong>
  I think, when I wrap a DLL method like this,</p>
  
  <pre><code>def method1(self, first_arg, *args):
      self.lib.method1(first_arg, args)
  </code></pre>
  
  <p>python takes care of converting other arguments except the first one to an array and pass that array to DLL method. It matches the signature of DLL method(<code>method1(String first_arg, String[] other_args)</code>), since python passes the second argument as an array.</p>
  
  <p>Can we do anything in <code>__getattr__</code> method to do the array conversion of other arguments except first one and pass on to DLL methods ?</p>