Home > database >  Why isn't there a method to tell the compiler to directly read the content of an embedded resou
Why isn't there a method to tell the compiler to directly read the content of an embedded resou

Time:12-08

From this comment:

the resource manager is intended to be used for storing resources (such as images, strings, or other data) that are embedded in your application, not for running external programs or scripts.

I understand the purpose of it is for storing, but why not allow to run scripts? Perhaps external programs are potentially large, but I suppose scripts are small enough?

CodePudding user response:

It's not a question of "why is this not allowed?", it's more of a question of "why is this feature not implemented?", which is very different.

From the results from your other question you can see that it's possible to copy the contents of a embedded resource to a local file, and then call Process.Start to execute it. This works the same as the feature you are requesting, so executing an embedded resource is allowed but you have to do a bit of legwork to get it to work the way you want it to.

I don't know how MS decides what features are added to .net, but I assume this one isn't available directly from embedded resources is because of some combination of the following reasons:

  • It's not what embedded resources were designed for
  • If you need to do it, it's still possible to implement it yourself (as per your other question)
  • Encouraging developers to store and run executables as embedded resources sounds like it would be a security headache from a design standpoint
  • There's not much demand for it
  • They never thought about it
  • Related