nop 2.0 Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi guys,

As promised we did dig into the problem.
The real problem is not that easy to explain but we will give our best.

Problem:

In short it is related to how MVC works and partly to the plugin framework in nopCommerce.
When a new plugin is dropped in the Plugins folder and is installed into nopCommerce, even if the plugin has registered routes for its controllers, these routes will not be working as the MVC framework couldn't find the new controller types and couldn't instantiate the requested controller. That's why you get these nasty errors i.e "Controller does not implement IController" or even a more descriptive one "We're sorry, there is no Web page matching your request".

So here is what is actually going on.

1. When you start your nopCommerce application the MVC framework cashes all controller names in a file located in your ASP.NET Temporary folder. The location may differ but you can check in one of these locations:

C:\Users\<User Name>\AppData\Local\Temp\Temporary ASP.NET Files\root
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\

In the root folder there will be many other folders with fancy names like 03b0be9d or 54c3dd3a but you need to order them by date modified and open the latest one (this should be the one of your currently running application). Inside it there will be another folder with similar name and you need to open it as well. Now in the UserCache folder you will see a file MVC-ControllerTypeCache.xml.
This file contains all MVC registered assemblies and controllers in them and is used by MVC to resolve controller names.

On my machine the location looks like this (I use IIS Express):
C:\Users\<UserName>\AppData\Local\Temp\Temporary ASP.NET Files\root\54c3dd3a\99892c19\UserCache\MVC-ControllerTypeCache.xml

2. Now if you drop your new plugins to the Plugins folder and install them, you will notice that the newly installed plugin assembly and controllers are missing in the MVC-ControllerTypeCache.xml file.
That’s why MVC couldn't instatiate your controllers and you get these errors.
Note: Even manually restarting your web server(application) doesn't help this .xml file to be updated!

Solution:

It looks like forcing a kind of a restart(recompiling) of the application will lead to updating the MVC-ControllerTypeCache.xml file with the latest plugins installed.
There are many ways to force a restart(recompiling) in your web application as the ASP.NET engine watches for changes in several places i.e the bin folder of the application. But the simplest and easiest way is just to make a small change in the Global.asax file.
You can do this by opening the file in Notepad and simply add a blank space at the end of the file and then save it.
The Global.asax file is located in the main folder of your application(the same folder where the Web.config file is).
Make sure the Global.asax file has an updated date modified.

You should now be able to open the routes in your plugins.

Hope this helps!
12 years ago
Thanks for the solution! Maybe, a 'Restart application' button (admin area) should also rewrite Global.asax file (just open and save without changes). It'll allow store owner to do it in admin area without any manual work.
12 years ago
a.m. wrote:
Thanks for the solution! Maybe, a 'Restart application' button (admin area) should also rewrite Global.asax file (just open and save without changes). It'll allow store owner to do it in admin area without any manual work.


Hi Andrei,

Yes, this will be very useful especially for normal users(not developers) as they will probably not have access to their Global.asax file.
Actually they shouldn't even care that such file exists :)
They just want to drop a plugin(or even better if they could upload a .zip file with the plugin via the administration panel), install it and start using it.

Thanks
12 years ago
7Spikes wrote:
Hi guys,


Solution:

It looks like forcing a kind of a restart(recompiling) of the application will lead to updating the MVC-ControllerTypeCache.xml file with the latest plugins installed.
There are many ways to force a restart(recompiling) in your web application as the ASP.NET engine watches for changes in several places i.e the bin folder of the application. But the simplest and easiest way is just to make a small change in the Global.asax file.
You can do this by opening the file in Notepad and simply add a blank space at the end of the file and then save it.
The Global.asax file is located in the main folder of your application(the same folder where the Web.config file is).
Make sure the Global.asax file has an updated date modified.

You should now be able to open the routes in your plugins.

Hope this helps!


Thanks a lot 7Spikes, it works perfectly :-)
12 years ago
What about just killing the contents of the temp files folder? I've found many situations where old controls get cached in there and cause run time and even build errors.
12 years ago
After wasting about 4 hours searching for a solution to this problem, I ran into this forum. Thanx alot for the solution! I always thought changing the Web.config would reload the application, but apparently it doesn't work for this kind of problems..
12 years ago
I am trying to follow your instructions on installing the slider extensions plugin by Nope templates with no success, as i cant see the homeslider plugins under the config>plugin section. Is it due to nop 2.20 , i even changed the supported version to : 2.20 , just to check if the plugins comes up in the admin section. I also tried restarting the application by saving the global.asx..
12 years ago
Hi guys,

You have downloaded an older version of the plugin.
The older versions are not compatible with nop 2.2.

All our plugins will support nopCommerce 2.2 and will be available for download later today from our website.
Please keep in mind that you need to change the Global.asax file after installing the plugins.
Just follow the instructions in the Help and you will be fine.


Hope this helps!
12 years ago
How can we delete posts in the forum? We don't see a delete button :)
12 years ago
creative3k wrote:
I am trying to follow your instructions on installing the slider extensions plugin by Nope templates with no success, as i cant see the homeslider plugins under the config>plugin section. Is it due to nop 2.20 , i even changed the supported version to : 2.20 , just to check if the plugins comes up in the admin section. I also tried restarting the application by saving the global.asx..


You cannot install it, and it is not listed in the plugins list in the administration because it does not support nopCommerce 2.2.

We are making the plugins available for nopCommerce 2.2 today.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.