Plugin never found

May 8, 2014 at 3:01 PM
Hi there,

First of all let me thank you for putting in the effort to make this framework. It's pretty cool that you did.

I've been trying to get this to work because I can really use it for an application we are building here at work, that needs to be highly extensible. However, I can't get my plugins to be recognized. I am not sure what the reason is, but if I loop through the Plugins, all it finds is the MvcPluginAppAdminPlugin.dll one, but not the one I made.

What I was wondering was, is the name of your project (and therefor your dll, leading in the discovery of the Plugin?

Example: I have added a project, did something wrong, and changed its name from DOKLAB.StoryCast.Cms.ImageSlide to ImageSlidePlugin, the dll however is still: DOKLAB.StoryCast.Cms.ImageSlide.dll

Does that matter to this framework? I've tried to run the admin app that you added, and that only sees itsself, nothing more. Any help in this matter would be highly appreciated.

Kinds regards,
Max.
May 8, 2014 at 4:06 PM
Ok, I have significantly progressed, but am still facing some problems. I am not getting my stylesheets, even if it is there in the code. I have made sure to add it as embedded resource and I can see the generated link in my resulting HTML, but when I click on it, I get a 404 error.

Any idea what is going wrong there?

Thanks again,
Max.
May 8, 2014 at 4:46 PM
Edited May 8, 2014 at 4:48 PM
I'm using your project as a starting point and I find it quite interesting. I have exactly the same problem of dragonspirit,the references to the javascript and css files return a 404 error., It is all there in the plugin dll, checked with resource explorer. I did some debugging in the AssemblyResourceProvider.cs and it seems to discover only the index.cshtml view. I am using .net 4.5.1
Coordinator
May 8, 2014 at 6:03 PM
I did reply to dragonspirit via email, but I guess that doesn't post into this discussion.

There are several issues you need to watch out for:
  1. Make sure .CSHTML, .CSS, and .JS files contained in a plugin dll are marked as "embedded resource" not "content". The default behavior when adding these files is to make them "content" so you MUST manually edit the property of the file and change it to "embedded resource". I get caught up on this from time to time due to forgetting to make that change.
  2. Make sure your plugin dll has the word "plugin" in its file name. The plugin framework doesn't look at every dll for plugins. It only looks for plugin dlls located in the bin folder of the site that contain plugin in the name, such as "adminplugin.dll" or "MyPlugin.ver3.dll"
  3. If you are manually making links to css or js files, they are going to be case sensitive.
May 8, 2014 at 8:15 PM
Edited May 8, 2014 at 8:41 PM
Hi thanks for your reply, probably the title of this discussion is a bit misleading, your 3 points are all satisfied and my plugin is found, I can see the plugin menu item attached to the main menu and clicking on it the view linked is called properly. If I inspect the html I can see also the references to the javascript file and css file registered in the plugin setup . i.e <script href=/plugins/myplugin/scripts/myjs.js/>, I get exaclty the same situation like your SamplePlugin, the only difference is that the web server is not able to find myjs.js file and returns a 404 error. If I open the link in the browser I get the same error. I understand that /plugins/myplugin/scripts/myjs.js is not physically present in the web folder but it should be discovered in the plugin dll as in SamplePlugin
Coordinator
May 8, 2014 at 8:46 PM
Edited May 8, 2014 at 8:51 PM
did you make a Scripts folder in your plugin project that the JS is contained in?

Is it able to load your css?
May 8, 2014 at 11:30 PM
Yes, /Scripts/myjs.js and /Content/mycss.css are both present in my plugin project and are correclty embedded in the dll as expected.
Coordinator
May 8, 2014 at 11:32 PM
The last thing I can think of is that you need handlers in your web.config:

<handlers>
  <add name="AspNetStaticFileHandler-CSS" path="*.css" verb="GET,HEAD" type="System.Web.StaticFileHandler"/>
  <add name="AspNetStaticFileHandler-JS" path="*.js" verb="GET,HEAD" type="System.Web.StaticFileHandler"/>
</handlers>
May 9, 2014 at 8:32 AM
Hi Matt,

That was what I was missing. I didn't have the handlers you are now describing so it didn't know what to do with the css files and js files I embedded. Now it works like a charm! Thanks, this really helped me.

Now I can start to work on the more difficult Plugin implementations, and I have plenty more to build ;)
May 9, 2014 at 10:27 AM
Edited May 9, 2014 at 10:34 AM
MattFromGA wrote:
The last thing I can think of is that you need handlers in your web.config:

<handlers>
  <add name="AspNetStaticFileHandler-CSS" path="*.css" verb="GET,HEAD" type="System.Web.StaticFileHandler"/>
  <add name="AspNetStaticFileHandler-JS" path="*.js" verb="GET,HEAD" type="System.Web.StaticFileHandler"/>
</handlers>
It worked!
I'm wondering why the web server needs this to find embedded resources. I've not seen this documented anywhere. Resources mapped on the file system worked normally without handlers declared in the web.config. I'll figure out later anyway, thanks very much for your help
Coordinator
May 9, 2014 at 2:00 PM
The reason the handlers are needed is that IIS only routes some urls into ASP.NET. Static files, like images, js, and css are handled directly by IIS, which means a url for .css will not be seen by ASP.NET by default.

There are generally 3 ways to handle this:
  1. Don't use an extension like css, js, or jpg.
  2. Add an entry into web.config that says "route all requests for every url through asp.net". This would work, but all static files would go through ASP.NET and depending on what IIS you are using this can slow down requests for real static files.
  3. Add the entries into web.config for only the specific extensions you want to route through asp.net
The nice thing about options #2 and #3 is that the urls look as expected and if you do have real static css and js, if its not processed by ASP.NET it will be handled and the real static file will be sent. So with the options I mentioned above, the web site can serve real css files and css files contained within a plugin dll.