call a viewcomponant from plugin error in 4.6

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
dears
i am trying to upgrade nopcommerce from 4 to 4.6 and i am using custom plugin
and need to upgrade it too.
whene i am trying to call its component from Nop.Web
it rais error
InvalidOperationException: A view component named 'PayTabsViewComponent' could not be found. A view component must be a public non-abstract class, not contain any generic parameters, and either be decorated with 'ViewComponentAttribute' or have a class name ending with the 'ViewComponent' suffix. A view component must not be decorated with 'NonViewComponentAttribute'.

my ViewComponent is
 [ViewComponent(Name = "PayTabsViewComponent")]
    public class PayTabsViewComponent : NopViewComponent
    {}

and my code in view is
@await Component.InvokeAsync("PayTabsViewComponent")

how he can get this component from plugin as i didnt had the referance of this plugin inside Nop.Web.
how to fix this?
thanks
1 year ago
This should be
@await Component.InvokeAsync("PayTabs")
1 year ago
Dear Yidna
thanks for your help but still error :(
InvalidOperationException: A view component named 'PayTabs' could not be found. A view component must be a public non-abstract class, not contain any generic parameters, and either be decorated with 'ViewComponentAttribute' or have a class name ending with the 'ViewComponent' suffix. A view component must not be decorated with 'NonViewComponentAttribute'.

let me tell u that
@await Component.InvokeAsync("PayTabs")

i am using it inside custom view not nopcommerce core view
i am using it instead of nopcommerce checkout view.
1 year ago
jciibrahim wrote:
i am using it inside custom view not nopcommerce core view

Yes

Oh also
[ViewComponent(Name = "PayTabs")]

But this maybe not required
Nop.Plugin.Payments.CheckMoneyOrder uses a View Component

See also
        public Type GetPublicViewComponent()
        {
            return typeof(CheckMoneyOrderViewComponent);
        }
1 year ago
Please see this post.
1 year ago
thanks romanov
but in my case it wont work i am calling the viewcomponent from plugin and if i used its namespace inside nop.web it will cause cycle.
how to fix?
1 year ago
dear Yidan
thanks for help
but still same error i had tried GetPublicViewComponent and     [ViewComponent(Name = "PayTabs")]
please help :(
1 year ago
jciibrahim wrote:

if i used its namespace inside nop.web


I cannot understand what you are trying to do.
1 year ago
dear RomanovM,
i am talking about
@await Component.InvokeAsync(typeof(PayTabsViewComponent))

as if i want to access PayTabsViewComponent i need to use the refrence of the plugin
@using Nop.Plugin.Payments.PayTabs.Components

to use it inside Nop.Web
and this will cause a cycle as plugin already had a refrence for Nop.Web so please help.
1 year ago
Hello,

Are you using plugin's PayTabsViewComponent in nop.web project's view file?
You can't use plugin component in nop.web view files. If you want to use then you need to add reference for this.
Please know me which purpose you have to use this component file in nop.web. And which view file on you have to use.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.