A bit off-topic question about embedding resources

Topics: General
Sep 10, 2013 at 2:47 PM
Hi,

I'm not that experienced yet with the whole architecture of Orchard, but it seems that Orchard is dynamically embedding code at runtime?

I actually look for a way to embed an image file from disk, into a separate .dll (as a resource) on runtime, so that I can use that image later on.

Someone knows if this is possible? I'm able to generate a .dll with help of the CodeDomProvider class, but I'm a bit stuck.

Hope someone knows a solution.

Thanks,
Daniel
Coordinator
Sep 10, 2013 at 7:22 PM
Not sure what you mean by "dynamically embedding code at runtime" but no, we're not doing anything that would resemble that. Embedding images into dlls sounds like a dreadful idea to me. Why would you want to do that? ASP.NET was doing it a long time ago, but there were a number of reasons for it, none of which applies to Orchard, as far as I can tell.
Sep 10, 2013 at 7:39 PM
Hi Bertrand,

Thanks for the reply.
Yeah, long story, another framework :(

It basically comes down to the fact that if I want to assign a thumbnail image to a 'template' (what also exists in Orchard) you need to set a property that can ONLY take a path to an embedded resource. So I thought that maybe it was possible to have some sort of UI that let's a user upload an image and then embed it inside a resource at runtime.

-Daniel-
Coordinator
Sep 10, 2013 at 7:41 PM
I'm sorry, I don't understand what you're referring to.
Developer
Sep 10, 2013 at 7:45 PM
What would be the benefit of having image as a resource in comparison to having image as a file on disk, accessible via URL, in a web application? I don't quite get it.
Developer
Sep 10, 2013 at 7:49 PM
Edited Sep 10, 2013 at 7:53 PM
plompd wrote:
So I thought that maybe it was possible to have some sort of UI that let's a user upload an image and then embed it inside a resource at runtime.
Sounds like a recipe for memory issues. Dlls cannot be unloaded from AppDomain, so each file uploaded and embedded this way will stay in memory until AppPool recycles. And this would be just the beginning of problems. Scary.
I'd rather focus on updating that existing logic to accept URLs or binary streams instead.
Sep 10, 2013 at 7:50 PM
The thing is that this CMS has default, embedded images in it's core system. So, yes, I also understand that it would be more useful to read it from disk, but it comes from the resources. So, for some reason that I don't know, I cannot assign an image that resides on disk. It needs the image to be inside a compiled assembly.

But I understand that this is not the right place to ask questions other than Orchard, but I just hoped someone had experience with this.

Thanks anyway,
Daniel
Sep 10, 2013 at 7:51 PM
@pszmyd: this is about a commercial, webforms based ASP.NET CMS, so not easy to update existing logic ;)
Developer
Sep 10, 2013 at 7:57 PM
Edited Sep 10, 2013 at 8:02 PM
plompd wrote:
@pszmyd: this is about a commercial, webforms based ASP.NET CMS, so not easy to update existing logic ;)
Ouch, that sucks. Anyway, I'd try to find a workaround to fit the image URL/stream in there somehow, even if using reflection and calling some non-public code is the only way. Still much less evil than embedding images.