Using the model in plugin in theme view (4.3)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
I'm working on a Plugin and Theme for nopCommerce 4.3. I use the model in plugin in theme view. I added a reference of model in my plugin to _ViewImports in theme. (@using Nop.Plugin.PluginName.Models.ModelName). And I added model in view. (@model ModelName) There are no errors in its operation but I'm getting a plugin reference error in VS. (The type or namespace name 'Plugin' does not exist in namespace 'Nop' (are you missing an assembly reference?)) How do i solve this?
3 年 前
Have you tried clean and build? check if it works and also check the namespace if the name is Plugin or Plugins.
3 年 前
I tried clean and build and checked that the namespace name is Plugin.
3 年 前
Can someone help me?
3 年 前
I'm having the same issue in nopcommerce 4.4
3 年 前
dinukasal wrote:
I'm having the same issue in nopcommerce 4.4


Does your _viewimports.cshtml look like this?


@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage<TModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Nop.Web.Framework

@using Microsoft.AspNetCore.Mvc.ViewFeatures
@using Nop.Web.Framework.UI
@using Nop.Web.Framework.Extensions
@using System.Text.Encodings.Web


Also, you referenced Nop.Web.Framework in your dependencies projects?

3 年 前
@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage<TModel>
Yes, my view imports is like follows,

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@*we remove the default InputTagHelper to prevent the checkbox duplicating: https://stackoverflow.com/questions/42544961/asp-net-core-custom-input-tag-helper-rendering-duplicate-checkboxes*@
@removeTagHelper Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Nop.Web.Framework
@addTagHelper *, MiniProfiler.AspNetCore.Mvc

@using System.Text.Encodings.Web
3 年 前
dinukasal wrote:
Yes, my view imports is like follows,


That's not a plugin _viewImports!

Look at any plugin, and you'll see how it should be (As with my example above.)
3 年 前
untiedshoes wrote:
Yes, my view imports is like follows,

That's not a plugin _viewImports!

Look at any plugin, and you'll see how it should be (As with my example above.)


It's the same in my plugin view imports file,


@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage<TModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Nop.Web.Framework

@using Microsoft.AspNetCore.Mvc.ViewFeatures
@using Nop.Web.Framework.UI
@using Nop.Web.Framework.Extensions
@using System.Text.Encodings.Web


And Nop.Web and Nop.Web.Framework is in dependency projects in the plugin.
3 年 前
This worked when I updated visual studio. It still shows errors in the Error list, but project runs
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.