Embedding a C# dll into a Python script

Posted on 2011-04-27
Last Modified: 2012-06-21
This question concerns an alternate approach to my currently open question.

I have a C# dll that consists of a number of classes, plus a user form.  I'm embedding the dll into a Python script that starts as follows:

from ctypes import *
y = cdll.LoadLibrary("c:\\Projects\\Front Counter\\fc_main\\FC_Main\\bin\\Debug\\FC_Main.dll")

I'm not sure where to go from here.  Basically, I can't call a method directly (e.g., y.<some method>) because all the methods are contained within classes in the dll.

How can I implement the Python script so that I can access the methods, properties, etc. of the dll?

Thanks in advance...
Question by:cshore12
    LVL 7

    Assisted Solution

    This SO answer seems to have some good information:

    It would appear as though you either need to use a .net-wrapped Python, such as IronPython, or make some changes to your current C# DLL such that you expose it as a COM object so that you can import it natively in to Python.

    Assisted Solution

    Yeah, I've already seen this reference and it's about 3/4 Greek to me.  Perhaps you can expand on it somewhat.

    Accepted Solution

    I've been convinced that the GIS application that this refers to is too complex for either of the suggestions you made.  Thanks anyway!

    Author Closing Comment

    jdavistx provided a link that I was already familiar with, and which was difficult to follow.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now