Isaac Bolinger
Isaac Bolinger

Reputation: 7388

Can I use code to load a stream of my choosing into an assembly's manifestresourcestream?

I'm calling a library in a separate appdomain (this library has a memory leak and this was the way I solved it). The library has an option to either specify the manifest resource name for the file it needs or else specify a file path.

Up until now, I've just passed the file path string from the main appdomain where my program is to the sandboxed library appdomain. However, I want to move to using embedded resources instead so I don't have to make sure to include all these files and send them to their proper directories in the installer project.

Of course, the library is looking in the assembly that's running it (the sandbox appdomain) for the embedded resources. I need to know if there's a way to add resources to the mainfestResourceStream at runtime. If there is, I could just pass a stream object across appdomains, add it to the resource stream, then call the library.

So, is it possible to add resources at runtime to an assemblys manifestResourceStream?

Thanks!

Upvotes: 0

Views: 67

Answers (1)

competent_tech
competent_tech

Reputation: 44941

I doubt that is possible, but even if it were, I would think it would be easier to just extract the resources (as needed) from your assembly into a specific file location, then pass that location to the assembly that needs it.

This way you get the benefit of not having to ship the files and the ease of using files.

Forgot: what we usually do in this situation is extract the files to a well-known temporary directory, then, on application startup, we always clear this directory to ensure that if the app is updated, we aren't using old resources.

Upvotes: 1

Related Questions