开发者

How to add a large file to a resource in c# project?

开发者 https://www.devze.com 2023-02-19 19:11 出处:网络
I was making a program that compiles a c# script to create an EXE application using Microsoft.CSharp.CSharpCodeProvider. In the process of making the EXE, it embeds a file programatically and the EXE

I was making a program that compiles a c# script to create an EXE application using Microsoft.CSharp.CSharpCodeProvider. In the process of making the EXE, it embeds a file programatically and the EXE reads that resource when it's executed on a later process. When I'm trying to add a large file and compiles it, the compiler 开发者_运维问答throws an error like "Unable to add resource. Insufficient memory" or something like that. Is there any way to add a large file in a c# project resource?


Don't embed resources that large in an executable. It won't only bomb the compiler, it bombs your program too. Anything larger than ~500 megabytes is trouble on a 32-bit operating system, there won't be hole in the address space large enough to fit it. You can get insight in the way it is divvied up between code and data with SysInternals' VMMap utility.

Since you're using CodeDom, you can use the /linkresource compiler option to keep the file out of the executable. You might still have a problem at runtime but that's another problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消