使用Python在编译的exe中调用C#函数
嘿,伙计们,我有一个用C#编写的已编译exe,有没有办法用python脚本调用exe中的方法和函数 exe是使用ILSpy进行反向工程的,我知道函数名,所以我知道它们的位置和调用的内容 下面是我正在尝试做的一个例子:使用Python在编译的exe中调用C#函数,c#,python-3.x,code-injection,C#,Python 3.x,Code Injection,嘿,伙计们,我有一个用C#编写的已编译exe,有没有办法用python脚本调用exe中的方法和函数 exe是使用ILSpy进行反向工程的,我知道函数名,所以我知道它们的位置和调用的内容 下面是我正在尝试做的一个例子: public static class Program { public const bool IsServer = true; public static Dictionary<string, string> LaunchParameters = n
public static class Program
{
public const bool IsServer = true;
public static Dictionary<string, string> LaunchParameters = new Dictionary<string, string>();
public static void LaunchGame(string[] args)
{
LaunchParameters = Utils.ParseArguements(args);
using Main main = new Main();
try
{
SocialAPI.Initialize();
LaunchInitializer.LoadParameters(main);
main.DedServ();
}
catch (Exception e)
{
DisplayException(e);
}
}
private static void DisplayException(Exception e)
{
try
{
using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", append: true))
{
streamWriter.WriteLine(DateTime.Now);
streamWriter.WriteLine(e);
streamWriter.WriteLine("");
}
Console.WriteLine("Server crash: " + DateTime.Now);
Console.WriteLine(e);
Console.WriteLine("");
Console.WriteLine("Please send crashlog.txt to support@terraria.org");
}
catch
{
}
}
}
公共静态类程序
{
public const bool IsServer=true;
public static Dictionary LaunchParameters=new Dictionary();
公共静态void启动游戏(字符串[]args)
{
LaunchParameters=Utils.ParseArguements(args);
使用Main=newmain();
尝试
{
SocialAPI.Initialize();
LaunchInitializer.LoadParameters(主);
main.DedServ();
}
捕获(例外e)
{
显示例外(e);
}
}
私有静态void显示异常(异常e)
{
尝试
{
使用(StreamWriter StreamWriter=newstreamwriter(“client crashlog.txt”,append:true))
{
streamWriter.WriteLine(DateTime.Now);
streamWriter.WriteLine(e);
streamWriter.WriteLine(“”);
}
WriteLine(“服务器崩溃:+DateTime.Now”);
控制台写入线(e);
控制台。写线(“”);
Console.WriteLine(“请将crashlog.txt发送到support@terraria.org");
}
抓住
{
}
}
}
我想做的是从python脚本中调用上述类的LaunchGame()
方法
谢谢你的建议 这回答了你的问题吗?