November Happy Hour will be moved to Thursday December 5th.

Single assembly plugin - fails to load embedded resources in IIS

Vote:
 

Hello EPI developers,

I have a problem with an EPiServer plugin that Im currently working on. The plugin is a single assembly plugin, meaning that all files are embedded as resources and delivered in a single .dll. When the plugin is loaded in the dev server in Visual Studio everythings works fine. When loaded in a website in the local IIS, .aspx and .ascx are loaded, but not other static files as .js or .css. I get a file not found error. Ive used reflector on the plugin dll and all resources are included correctly.

What can be the cause of this problem? Any thoughts?
// Jonas

#37169
Feb 23, 2010 11:46
Vote:
 

A commonly-used solution is to create a Virtual Path Provider to serve up the embedded resources and ship it with your DLL.

There are some good posts knocking around about this to get you started - it worked for me, by the way.

Dan Matthews wrote about it first (I think) here: http://blogs.interakting.co.uk/post/EPiServer-plugin-in-a-single-assembly.aspx

Johan Olofsson wrote a similar piece with a nice enhancement here: http://labs.episerver.com/en/Blogs/Johano/Dates/2008/6/EPiServer-PlugIns-in-one-single-dll/

 

#37175
Feb 23, 2010 12:21
Vote:
 

Hi Ben,
Thanks for takeing some time to answer this one. The first blog post that you've included is the one that is the base for my solution. I have a virtual path provider that works fine with all files when runned from Visual Studio dev server. If i put the same plugin in an IIS website it only works with user controls and pages but not with other static content like js or css.

// Jonas

#37178
Feb 23, 2010 12:40
Vote:
 

Are you using the GetWebResourceUrl method to get the embedded resource URLs? It worked for me when referring to embedded static image resources. You have to get the namespace arguments right, but if you want to access an image called test_image.gif on a page called MyActionWindow in as assembly called MyPlugins the code would look something like:

string url = Page.ClientScript.GetWebResourceUrl(typeof(MyActionWindow), "MyPlugins.test_image.gif");

(NB: This assumes that all the files are sitting in the root directory of the project)

I hate to admit this, but the JS and CSS on my action window was embedded into the HTML [hangs head in shame...]

Would also take care with the Url argument that you use on the class's GuiPlugIn attribute - this caused me grief too...

[GuiPlugIn(
DisplayName = "Action window plugin",
Area = PlugInArea.ActionWindow,
Url = "~/App_Resource/MyPlugins.dll/MyPlugins.MyActionWindow.ascx"
)]

Hope this helps in some way and sorry if I'm stating the obvious - good luck finding your CSS and JavaScript files...

 

#37179
Feb 23, 2010 13:05
Vote:
 

Jonas, if you (or anyone else for that matter) knows a way to fix this problem, could you please send me a mail at johnsson.markus@gmail.com.

Cheers!

#46484
Dec 14, 2010 17:36
Vote:
 

Allan Thraen has a good post for easier  single assembly plugins. I've used it to load .js content in a single assembly custom property.

 

http://labs.episerver.com/en/Blogs/Allan/Dates/2009/2/Even-easier-single-assembly-modules/

#46490
Dec 15, 2010 8:27
Vote:
 

This is off-topic, but single assembly plugins can be a pain to troubleshoot if you're having trouble making them work on your site (let alone the pain of creating them). I've personally given up on a few of these modules as I was not able to make them work in my environment.

Yes; I know, done correctly it should just work. It has not always done so for me, so I won't use single assembly modules unless I get the source code too (and even then I hesitate.)

/Steve

#46496
Dec 15, 2010 9:10
Vote:
 

The problem with "static" resources not loading, like *.js, *.gif et.c., is most likely the <location> from where the resources are delivered dont specify the EPiServer.Web.StaticFileHandler but the standard System.Web.StaticFileHandler.

You can either add the required <location>-settings for your path, or simply make use of one of the paths already setup like this in EPiServer, for example the /utils location. A simple approach would be to register (and reference) your ressources with a path like /util/MyStuff/MyFile.js

/johan

#46498
Dec 15, 2010 10:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.