python import .dll compiled by .net

886 Views Asked by At

i used jscript.net to create a .dll file. as a test, i can successfully call the function hello() in another jscript.net program, which compiled as .exe.

BUT my question is: how can i call the function in python?

this dll can be successfully loaded by using ctypes.windll.LoadLibrary("power.dll"). however, the name of function can't be found...

i have done some tests of my dll file.

i used "dumpbin /all" to check my dll, but i can't find any usable funciton names. it is odd...

the code of my dll file in jscript.net
""""""""""""""""""""""

import System;
import System.Console;
import System.IO;

package power{

public class testp {

        function hello (){

        var time_1 = DateTime.Now;

        for (var i =0; i<10000; i++){

            Console.WriteLine ("hello world!");

        };

        var time_2 = DateTime.Now;

        Console.WriteLine (time_2-time_1);

        };

    };

};

""""""""""""""""""""""

1

There are 1 best solutions below

0
On

Yes, you can consume any DLL in python if you make the code COM-exposed. I only skimmed through it, but this tutorial seems to give a good example of how to do this:

http://www.codeproject.com/Articles/73880/Using-COM-Objects-in-Scripting-Languages-Part-2-Py