Plugin Views won't load

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
My views won't load for my plugin that I'm developing. I have them as an embedded resource, but it keeps looking for them in the standard folder locations.

I created a new Product Template. I have:
@using Nop.Plugin.Misc.ProductDesigner


and I'm calling a controller action with:
@Html.Action("Designer", "MiscProductDesigner")


The debugger hits the "Designer" action in the controller, but when it returns the view:
Return View("Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer")


(Again, my views are set as an Embedded Resource, and the view structure in the project looks like:
Nop.Plugin.Misc.ProductDesigner
--Views
----MiscProductDesigner
------Designer.vbhtml

I get:

The view 'Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Themes/DarkOrange/Views/MiscProductDesigner/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.cshtml
~/Themes/DarkOrange/Views/MiscProductDesigner/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.vbhtml
~/Themes/DarkOrange/Views/Shared/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.cshtml
~/Themes/DarkOrange/Views/Shared/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.vbhtml
~/Views/MiscProductDesigner/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.cshtml
~/Views/MiscProductDesigner/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.vbhtml
~/Views/Shared/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.cshtml
~/Views/Shared/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.vbhtml
~/Administration/Views/MiscProductDesigner/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.cshtml
~/Administration/Views/MiscProductDesigner/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.vbhtml
~/Administration/Views/Shared/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.cshtml
~/Administration/Views/Shared/Nop.Plugin.Misc.ProductDesigner.Views.MiscProductDesigner.Designer.vbhtml
11 years ago
I've stepped through code, and when it gets to finding the embedded views in the EmbeddedViewTable (EmbeddedViewTable.cs lines 46-49), my plugin assembly is not listed in table of Views. Is there anything I might be missing that is preventing my plugin assembly from being loaded in there?
11 years ago
esutter wrote:
I've stepped through code, and when it gets to finding the embedded views in the EmbeddedViewTable (EmbeddedViewTable.cs lines 46-49), my plugin assembly is not listed in table of Views. Is there anything I might be missing that is preventing my plugin assembly from being loaded in there?

After each project build, clean the solution before making changes. Some resources will be cached and can lead to developer insanity.
11 years ago
Thank you for your response.

I have done clean, and rebuild, and even manually deleted leftover DLLs and ASP.NET Temporary files. Would the very fact that I'm developing the plugin with VB.NET have anything to do with it? I know the property pages between VB and C# projects are a tad different, and I just wonder if there's something in the project architecture itself that's not making the assembly visible to the Embedded Views Table?
11 years ago
esutter wrote:
Would the very fact that I'm developing the plugin with VB.NET have anything to do with it?

I don't think so. I'll have a look at the plugin if you could share your solution.
11 years ago
That's very kind of you.

Do you want just the plugin project, or the entire solution with the nopcommerce source? I don't mind sharing it, there's no real code in it right now, not much more than a VB version of the blank plugin project.
11 years ago
Hi Eric,

After some investigation I found out that it's really a VB.NET issue. Have a look at \Presentation\Nop.Web.Framework\EmbeddedViews\EmbeddedViewResolver.cs file (GetEmbeddedViews method). Embedded views aren't loaded because C# and VB.NET generate distinct embedded resource paths. In a C# project embedded resources names follow this convention (RootNampeSpace).(Path).(FileName).(Extension) where Path is the folders path in which this resource exist Root/Folder/SubFolder/.../ResourceFile .In A VB.NET project embedded resources names follow this convention (RootNampeSpace).(FileName).(Extension) and the resource path does not affect its name.

Please find more info here
11 years ago
That's excellent, Andrei.  Based on that, I've got it working, but...

Do you foresee any problems with changing line 29 to:
if (!key.Contains(".cshtml") && !key.Contains(".vbhtml")) continue;


Then, in my controller I do
Return (View("Nop.Plugin.Misc.ProductDesigner.Designer", model))


I think I'm going to put my views in the Shared folder during development so that I can make quick changes in there during debug sessions without having to clean and build for each change to the view, then move them back to the plugin for deployment.
11 years ago
I suppose another option could be to name my views:

Designer.views.vbhtml
Configure.views.vbhtml

This wouldn't require any code changes to the nopCommerce code.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.