nopCommerce version: 4.1
Start the app from source code. In debug out put log I get these exception
'dotnet.exe' (CoreCLR: clrhost): Loaded 'j2o3nqrb.rzh'. Cannot find or open the PDB file.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'j2o3nqrb.rzh'. Cannot find or open the PDB file.
Exception thrown: 'Autofac.Core.Registration.ComponentNotRegisteredException' in Autofac.dll
Exception thrown: 'Autofac.Core.Registration.ComponentNotRegisteredException' in Autofac.dll
what the reason to cause this exception ?
please provide a list of steps to reproduce the issue
If I uninstall all plugins. I would not get the exception.
I just tried to reproduce the problem and launched a clean solution. It works like a charm without any errors.
@RomanovM have you install some official plugins ? clean solution would not get this issue.
I install some payment plugin I get this issue. It seem if plugin contain services or DependencyRegistrar have this problem. would you try to install some plugin and check again. Thank you
I'm experiencing same problem.
Same problem here
More details:
error happens to me if I have at least one plugin in installedPlugins.json (official or not).
It's throw in Nop.Core.Plugins.PluginDescriptor.Instance method:
```///
/// Get the instance of the plugin
///
///
///
public virtual T Instance
{
object instance = null;
try
{
instance = EngineContext.Current.Resolve(PluginType);
}
catch
{
//try resolve <--- ERROR CATCHED HERE
}
if (instance == null)
{
//not resolved
instance = EngineContext.Current.ResolveUnregistered(PluginType);
}
var typedInstance = instance as T;
if (typedInstance != null)
typedInstance.PluginDescriptor = this;
return typedInstance;
}
```
Example of exception thrown:
'Autofac.Core.Registration.ComponentNotRegisteredException' in Autofac.dll
("The requested service 'Nop.Plugin.Tax.FixedOrByCountryStateZip.FixedOrByCountryStateZipTaxProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.")
Exception thrown:
'Autofac.Core.Registration.ComponentNotRegisteredException' in Autofac.dll ("The requested service 'Nop.Plugin.Tax.FixedOrByCountryStateZip.FixedOrByCountryStateZipTaxProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency."
@AndreiMaz @RomanovM It does not compromise request execution but I think it could have a major impact in performance since it happens dozen times per request.
Hi,
I have same issue, downloaded source code via website. Compiled, installed new database, launched and then exceptions came out.
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll ("The 'AppId' option must be provided.")
The 'AppId' option must be provided.
Exception thrown: 'Autofac.Core.Registration.ComponentNotRegisteredException' in Autofac.dll ("The requested service 'Nop.Plugin.Widgets.GoogleAnalytics.GoogleAnalyticsPlugin' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.")
The requested service 'Nop.Plugin.Widgets.GoogleAnalytics.GoogleAnalyticsPlugin' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
Exception thrown: 'Autofac.Core.Registration.ComponentNotRegisteredException' in Autofac.dll ("The requested service 'Nop.Plugin.Widgets.NivoSlider.NivoSliderPlugin' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.")
The requested service 'Nop.Plugin.Widgets.NivoSlider.NivoSliderPlugin' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
Debug into NopEngine.cs .
I find the method try to get service using plugin type name.
add these code seems would fix it
public object Resolve(Type type)
{
if (type.IsSubclassOf(typeof(BasePlugin))) {
return null;
}
return GetServiceProvider().GetRequiredService(type);
}
Debug into NopEngine.cs .
I find the method try to get service using plugin type name.
add these code seems would fix itpublic object Resolve(Type type) { if (type.IsSubclassOf(typeof(BasePlugin))) { return null; } return GetServiceProvider().GetRequiredService(type); }
This fix improved debug performance by 1000%
I dunno if it鈥檚 the right place to fix it. I鈥檇 fix it on Nop.Core.Plugins.PluginDescriptor Instance method, as plugins are not registered in the service container anywhere.
But only @AndreiMaz knows this for sure. I only hope he鈥檒l get on this issue as is marked as closed.
On my side, I solved this using GetService(type) instead of GetRequiredService(type), which return null instead of throwing an error. I don't know if it's OK to do so, but I'm running this since two week without problems.
@Codefans-fan, @alecrt and @softkey87 Thank you for your help, we analyzed the situation and the debug log, and in the end we implemented a modular solution from the pieces you offered
Closed #3264
Most helpful comment
@RomanovM have you install some official plugins ? clean solution would not get this issue.
I install some payment plugin I get this issue. It seem if plugin contain services or DependencyRegistrar have this problem. would you try to install some plugin and check again. Thank you