从.net可执行文件调用.net可执行文件 [英] Calling a .net executable from a .net executable

查看:134
本文介绍了从.net可执行文件调用.net可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个.net应用程序"A"(但没有可用的源代码).我有一个带有源代码的C#应用​​程序"B".我需要在单击按钮时从A调用B.

如果是,请您分享一些想法.

在此先感谢
Venkat

Hi All,

I have a .net application "A" (but no source code available). I have a c# application "B" with source code. I need to call B from A on click of a button.

If yes, could you please share some ideas.

Thanks in Advance
Venkat

推荐答案

请参见 Process.Start [ ^ ]-它允许您从程序中执行任何可执行文件.
See Process.Start[^] - it allows you to execute any executable from within your program.


还有另一种方法,通常是一种更好的方法.与本机* .DLL和* .EXE不同,在.NET中,*.DLL和* .EXE之间没有主要区别(惊奇!).当然,不能从Shell以* .EXE形式启动库,但正好相反:您可以像普通库一样使用* .EXE(惊奇!):以静态方式引用它或使用Reflection动态加载以找到入口点您想要的(不仅是标准"入口点).

此操作将大不相同:可执行文件的代码将在同一进程中运行;新过程将不会创建.

—SA
There is another way, often a better way. Unlike native *.DLL and *.EXE, in .NET there is no principal difference between *.DLL and *.EXE (surprise!). Of course, a library cannot be started from Shell as *.EXE, but the opposite is perfectly legitimate: you can use *.EXE like a normal library (surprise!): reference it statically or load dynamically using Reflection to find an entry point you want (not only "standard" entry point).

This operation will be quite different: the code of executable will run in the same process; new process will not be created.

—SA


这篇关于从.net可执行文件调用.net可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆