.NET:将EXE文件嵌入到我的项目中 [英] .NET: embed an EXE file into my project

查看:144
本文介绍了.NET:将EXE文件嵌入到我的项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这很奇怪,但是我需要将EXE文件(或汇编代码)嵌入到我的项目中,因此只能由应用程序启动(它无法在文件系统中创建EXE并启动

I know that is strange situation, but I need to embed an EXE file (or the assembly code) into my project, so it can be started only by the application (it can't create the EXE in the filesystem and start it)...

有可能吗?

编辑:

它不是.NET EXE。无论如何,我将Test.exe文件作为资源添加到我的项目中,并且做到了

It's not a .NET EXE. Anyway I added the Test.exe file as a resource to my project and I did this

   Dim exestr As Stream = Nothing
   Dim a As Assembly = Assembly.GetExecutingAssembly
   exestr = a.GetManifestResourceStream("Test.exe")  


推荐答案

我正在考虑创建一个 RAM磁盘 ,从.NET资源文件向其中写入您的exe文件,然后在其中执行该文件。什么都没碰到物理磁盘。

I'm thinking create a RAM disk, write your exe file/s to it from your .NET resource file, and execute the file there. Nothing touches physical disk.

我没有可编程RAM磁盘API的链接,但您很可能可以从程序中找到一些要操作的东西。另一个好处是病毒扫描程序仍然可以确认它的安全性。

I don't have a link for a programmable RAM disk API but you can likely find something to manipulate from your program. The other benefit is virus scanners can still acknowledge it for security.

我也在想,如果您的应用程序在磁盘上运行,那么就没有充分的理由说明有问题的可执行文件也不能在磁盘上。如果您是通过网络(下载)或其他方式通过管道传输它,请先保存到磁盘并在执行后擦除它

Also I'm thinking if your app is running on disk then there's no good reason why the executable in question can't be on disk too. If you're piping it in over the network (downloading) it or something, then save to disk first and erase it when done execution.

这篇关于.NET:将EXE文件嵌入到我的项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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