hi,
i have a big exe program that i wrote in c# (big means that i have a lot of class in it), i want to write a script in python that will check the program.

what is the right way to check the program, convert the c# program to dll and to create an instants of my classes, or to load the Exe program to the python ?

thanks,

Oron

hi,
i have a big exe program that i wrote in c# (big means that i have a lot of class in it), i want to write a script in python that will check the program.

what is the right way to check the program, convert the c# program to dll and to create an instants of my classes, or to load the Exe program to the python ?

thanks,

Oron

Ah, use IronPython.

With IronPython, you can load .NET .dll's using the clr module.
http://ironpython.net/

If you have a C# program with this code:

using System;

namespace SimpleDLL
{
    public class Simple
    {
        public string data;

        public Simple(string data)
        {
            this.data = data;
        }
    }
}

and you compile it as simpledll.dll

you can do this in IronPython (put the dll in the same folder as the .py file)

import clr

clr.AddReference("simpledll")

from SimpleDLL import Simple

s = Simple("Hello World")

If you want to just run an EXE in IronPython, you can do this:

import clr

from System.Diagnostics import Process
Process.Start("name_of_exe.exe")

If you want to work with a C# exe, I think that would be much harder, since you'll have to work with System.Reflection and stuff like that.

you can also use ctypes.

from ctypes import *
myDLL = cdll.LoadLibrary('nameOfDll.dll')

you can also use ctypes.

from ctypes import *
myDLL = cdll.LoadLibrary('nameOfDll.dll')

He wrote the .dll in C#.
cdll can only load dlls written in C or C++.

C# dlls are .NET assemblies, built with MSBUILD, which are extremely different.
I'm afraid IronPython is the only way for this situation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.