Cannot Resolve Symbol model

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 年 前
I am new to NopCommerce and also new to MVC and I am trying to work out a plug in for setting the Default Sort By

I want to have a configuration page where you can set your own default sort by and I've got the plug in actually working (thanks to 7Spikes) and am moving onto the Configure.cshtml and I am getting

cannot resolve symbol 'model' on the line

@model Nop.Plugin.Misc.DefaultSortBy.Models.MiscDefaultSortByModel


I'm sure it's something I blatantly missed :)
12 年 前
I changed it to

@model Nop.Plugin.Misc.DefaultSortBy.Models.MiscDefaultSortByModel

and it works (at least in the fact that it's *saying* there's an error - but now when i try to click the "Configure" like I get a big fat error LOL

The controller for path '/Admin/Plugin/ConfigureMiscPlugin' was not found or does not implement IController.
12 年 前
if somebody wants to take a look and tell me what I'm missing I put my plug in up here

http://www.backyardworkshop.com/DefaultSortBy.zip
12 年 前
There are a few problems with your plugin, the following steps will allow you to get it running:

1) You need to set the output path to the following (Project Properties > Build Tab > 'Output path' field > Save):
..\..\Presentation\Nop.Web\Plugins\Misc.DefaultSortBy\


2) You have the wrong name for your controller (file: Nop.Plugin.Misc.DefaultSortBy\Controllers\MiscDefaultSortByController.cs) This is causing your error: "The controller for path '/Admin/Plugin/ConfigureMiscPlugin' was not found or does not implement IController."

class MiscDefaultSortByController : Controller
should be
public class DefaultSortByController : Controller


3) Change the "Build Action" property of Nop.Plugin.Misc.DefaultSortBy\Views\MiscDefaultSortBy\Configure.cshtml to "Embedded Resource"


4) Change the access level for the DefaultSortBySettings class
from:
internal class DefaultSortBySettings : ISettings
to:
public class DefaultSortBySettings : ISettings


5) You have an error in the Configure action (file: Nop.Plugin.Misc.DefaultSortBy\Controllers\MiscDefaultSortByController.cs)
The following line in your code causes an error as the _SortBySettings object reference has not been instantiated
model.DefaultSortBy = _SortBySettings.DefaultSortBy;
Solution: Add a constructor to your controller and use DI/IoC to instantiate the object
public DefaultSortByController(DefaultSortBySettings sortBySettings)
{
    this._SortBySettings = sortBySettings;
}

6) Build the project and click the "Reload list of plugins" button on Admin > Configuration > Plugins.

7) Install the plugin if needed.

8) Click the Configure link for the plugin; you should see the text from you Configure.cshtml view.

.
12 年 前
Thanks for your help mb, but I did the things you mention and still get the error :( - I cleaned my project and rebuilt and even restarted my application and reloaded the plugin - also uninstalled and reinstalled the plug in and it still errors when I try to go to the Configure page

the plug in works - but there's no way to configure it so it's a bit limited (plus I need to learn how to do this) :)

here's the stack trace if it'll help

Stack Trace:


[HttpException (0x80004005): The controller for path '/Admin/Plugin/ConfigureMiscPlugin' was not found or does not implement IController.]
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +329886
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +232
   System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +49
   System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +13
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +124
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.Mvc.<>c__DisplayClass7.<BeginProcessRequest>b__6() +29
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +38

[HttpException (0x80004005): Execution of the child request failed. Please examine the InnerException for more information.]
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +110
   System.Web.Mvc.ServerExecuteHttpHandlerAsyncWrapper.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +98
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1529
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +77
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28
   System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +22
   System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +497
   System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +88
   ASP._Page_Administration_Views_Plugin_ConfigureMiscPlugin_cshtml.Execute() in c:\SoftwareDevelopment\nopCommerce_2.30_Source\Presentation\Nop.Web\Administration\Views\Plugin\ConfigureMiscPlugin.cshtml:10
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +272
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.StartPage.RunPage() +58
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +94
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +173
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
12 年 前
Touch "global.asax" file (more info here)
12 年 前
thanks for the link and the advise - I cleaned my project and added a blank line to the Global.asax file in the Presentation nop.web project - is that the right one? because it didn't make any difference :(
12 年 前
I am looking at some of the other Controllers and I don't know that I had the class name wrong - so can someone explain it to me? :)

My Plug in is called "DefaultSortBy" and I put it in as "Misc" - so shouldn't my Controller name be "MiscDefaultSortbyController"?

(I am looking at the FeedBecomeController, ExternalAuthTwitterController, ect as examples)
12 年 前
sorry to keep replying to myself ;)

Ok I changed my Controller back to MiscDefaultSortByController and also changed the

routes.MapRoute("Plugin.Misc.DefaultSortby.Configure", "Plugins/MiscDefaultSortBy/Configure",
                 new { controller = "MiscDefaultSortByController", action = "Configure" },
                 new[] { "Nop.Plugin.Misc.DefaultSortBy.Controllers" }

to reflect that (not sure that it was before or not

anyway short story long - I got it :)


now onto the next task - and that's displaying the ProductSortingEnum options in a drop down :)
12 年 前
I am sooooo close :)

two problems left

#1 it's not saving the value I choose in the Configure
#2 I'm not sure exactly how to call the saved value in the RouteProvider

I uploaded my current plug in to here if anyone wants to take a look :)

Thanks!
Jamie
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.