简体   繁体   中英

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

I was making a program that compiles ac# 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 ac# 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM