如何通过 .NET Windows 窗体应用程序创建 .NET 可执行文件?
正如标题中所述,我想开发一个 .NET 中的 Windows 窗体应用程序,它能够在运行时创建另一个 .NET 命令行或 Windows 窗体可执行文件让我将其保存到磁盘。
如果可能的话,您有什么想法以及如何进行吗?
#Region“更多信息”
我想创建一个表单,用户可以在其中定义可执行文件的路径和图标/图像的路径< /强>。
当他/她按下构建按钮时,程序会创建一个新的.NET exe,用户可以将其保存到磁盘上。
该exe的图标是在创建过程中选择的图标,启动时它会启动在创建过程中选择的进程并退出。
几乎是一个迷你启动器
#EndRegion
非常感谢, 马可
As described in the title I would like to develop a Windows Forms Application in .NET that is capable of creating at run-time another .NET command line or windows form executable and let me save it to disk.
Do you have any ideas if it is possible and how to proceed?
#Region "Some more info"
I would like to create a form where the user can define a path of an executable and a path for an icon/image.
When he/she presses the build button the program create a new .NET exe that the user can save to the disk.
This exe's icon is the icon selected in during creation and when launched it starts the process selected during creation and exit.
Practically a mini launcher
#EndRegion
Thanks a lot,
Marco
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
绝对 - 您可以使用
CSharpCodeProvider
类并让它在磁盘上生成程序集。当然,这是假设您已经拥有想要构建的 C# 代码(例如用户输入的代码)。其他语言也有类似的提供程序 - 或者您可以使用在执行时决定CodeDomProvider.CreateProvider
如果您没有要编译的 C# 代码,可能仍然有方法可以实现您想要的操作 - 但您需要具体说明什么你想要这个新的可执行文件执行的操作。
Absolutely - you can just use the
CSharpCodeProvider
class and get it to generate an assembly on disk. That's assuming you've got C# code you want to build, of course (e.g. code that the user typed in). There are similar providers for other languages - or you can decide at execution time usingCodeDomProvider.CreateProvider
If you don't have C# code to compile, there are probably still ways of doing what you want - but you'll need to be specific about what you want this new executable to do.
当然。查看 CSharpCodeProvider 类。
Sure. Have a look at the CSharpCodeProvider class.
我看到有两种方法:
I see two ways for this: