Microsoft.Extensions.DependencyInjection Error - asp.net-core-2.2

Could anybody tell me what is this error?
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, bool throwIfCallSiteNotFound)
I have a Service and IService like ITest.cs and TestRepository , I register its in start up class
services.AddScoped<ITest, TestRepository>();
I use a Mongodb in database .

I found the solution, I forget to register my generic classes
services.AddTransient(typeof(IRepository<>), typeof(MongoDBRepository<>));

Related

Upgrade to Prism 8 is causing navigation errors

Environment
Xamarin Forms: 5.0.0.1709-pre4 (but also fails with 4.8.0.1687)
VS2019 16.8.3
XCode: 12.2
Prism NuGets
Prism.DryIoc.Extensions 8.0.48
Prism.Forms 8.0.0.1909
Prism.PluginPopups 8.0.31-beta
Shiny.Prism 8.0.48
Inner Exception from INavigationResult: DryIoc.ContainerException -> InvalidOperationException
code: Error.UnableToResolveFromRegisteredServices;
message: Unable to resolve Resolution root IRMobile.PageModels.LandingPageModel with passed arguments
[Constant(Prism.Navigation.ErrorReportingNavigationService,
typeof(Prism.Navigation.ErrorReportingNavigationService))]
from container with scope {Name=null}
with Rules with {TrackingDisposableTransients, UseDynamicRegistrationsAsFallbackOnly,
FuncAndLazyWithoutRegistration, SelectLastRegisteredFactory} and without
{ThrowOnRegisteringDisposableTransient, UseFastExpressionCompilerIfPlatformSupported}
with FactorySelector=SelectLastRegisteredFactory
with Made={FactoryMethod=ConstructorWithResolvableArguments}
with normal and dynamic registrations:
(DefaultDynamicKey(0), {FactoryID=317, ImplType=IRMobile.PageModels.LandingPageModel,
Reuse=TransientReuse, HasCondition})
Stack Trace from InnerException:
at DryIoc.Container.TryThrowUnableToResolve (DryIoc.Request request) [0x00058] in /_/src/DryIoc/Container.cs:1077
at DryIoc.Container.DryIoc.IContainer.ResolveFactory (DryIoc.Request request) [0x00072] in /_/src/DryIoc/Container.cs:1059
at DryIoc.Container.ResolveAndCacheKeyed (System.Int32 serviceTypeHash, System.Type serviceType, System.Object serviceKey, DryIoc.IfUnresolved ifUnresolved, System.Object scopeName, System.Type requiredServiceType, DryIoc.Request preResolveParent, System.Object[] args) [0x000c5] in /_/src/DryIoc/Container.cs:471
at DryIoc.Container.DryIoc.IResolver.Resolve (System.Type serviceType, System.Object serviceKey, DryIoc.IfUnresolved ifUnresolved, System.Type requiredServiceType, DryIoc.Request preResolveParent, System.Object[] args) [0x00042] in /_/src/DryIoc/Container.cs:430
at DryIoc.Resolver.Resolve (DryIoc.IResolver resolver, System.Type serviceType, System.Object[] args, DryIoc.IfUnresolved ifUnresolved, System.Type requiredServiceType, System.Object serviceKey) [0x00000] in /_/src/DryIoc/Container.cs:7809
at Prism.DryIoc.DryIocContainerExtension.Resolve (System.Type type, System.ValueTuple`2[System.Type,System.Object][] parameters) [0x0001c] in /_/external/Prism/src/Containers/Prism.DryIoc.Shared/DryIocContainerExtension.cs:294
App.xaml.cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// for RgPopups
containerRegistry.RegisterPopupNavigationService();
containerRegistry.RegisterPopupDialogService();
// Essentials
containerRegistry.Register<ISecureStorage, SecureStorageImplementation>();
containerRegistry.RegisterSingleton<IAppInfo, AppInfoImplementation>();
// page stuff
containerRegistry.RegisterForNavigation<NavigationPage>();
containerRegistry.RegisterForNavigation<IconNavigationPage>();
containerRegistry.RegisterSingleton<IPageBehaviorFactory, CustomPageBehaviorFactory>();
...
// Page and model registrations
containerRegistry.RegisterForNavigation<LoginPage, LoginPageModel>();
containerRegistry.RegisterForNavigation<LandingPage, LandingPageModel>();
}
I get this exeption when trying to navigate to a root master/detail page from a LoginPage
await NavigationService.NavigateAsync("/MainPage/NavigationPage/LandingPage")
and the constructor for the LandingPage is
public LandingPageModel(INavigationService navigationService, IMapper mapper, IDialogs dialogs, IPushManager pushManager) : base(navigationService, mapper)
I am fairly new to Prism so I'm sure I am missing something, a registration or maybe a NuGet package, but I'm not sure what it would be. I commented out the Registrations for Popup as I was getting the same error, but referring to Prism.Plugin.Popups.PopupPageNavigationService
As always, thanks for any help!
It looks like you are attempting to navigate to a page called LandingPage, but you haven't told the container what LandingPage is.
Every time you want to create a new view and navigate to it, you need to register it for Navigation inside your App.Xaml.cs file;
containerRegistry.RegisterForNavigation<LandingPage, LandingPageViewModel>();
This line registers the view and its corresponding ViewModel inside the container. Once the container knows about the view, the NavigationService can resolve the view you wish to navigate to using the literal name of the view LandingPage.
Now you can call
await NavigationService.NavigateAsync("LandingPage");
//or
await NavigationService.NavigateAsync("/MainPage/NavigationPage/LandingPage")
NOTE
Prism navigation has a couple of neat tricks built into it. It is Uri based, so every time you navigate to another view, passing the name of the view in the NavigateAsync method will stack the view on top of the others. This means that if you start at the URI NavigationPage/PageA, if you then say NavigateAsync("PageB") you will end up at NavigationPage/PageA/PageB.
Additionally, including the / character at the very beginning of the NavigateAsync argument completely resets the stack. So if you navigate to /PageC from NavigationPage/PageA/PageB, this resets the stack to just PageC

Asp.net Boilerplate - There is no argument given that corresponds to the required formal parameter

Used ASP.NET boilerplate to create Multi Page Web Application
(includes login, register, user, role and tenant management pages
https://aspnetboilerplate.com/Templates)
Getting below mention error while building the project. Kindly point me a direction to sort the mention issue.
Thank-you.
Error -
Severity Code Description Project File Line Suppression State
Error CS7036 There is no argument given that corresponds to the required formal parameter 'organizationUnitRepository' of 'AbpRoleManager.AbpRoleManager(AbpRoleStore, IEnumerable>, ILookupNormalizer, IdentityErrorDescriber, ILogger>, IPermissionManager, ICacheManager, IUnitOfWorkManager, IRoleManagementConfig, IRepository, IRepository)' test.Core C:\test\4.6.0\aspnet-core\src\test.Core\Authorization\Roles\RoleManager.cs 25 Active
Easily fixed - just add the required params yourself.
public class RoleManager : AbpRoleManager<Role, User>
{
public RoleManager(
RoleStore store,
IEnumerable<IRoleValidator<Role>> roleValidators,
ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors,
ILogger<AbpRoleManager<Role, User>> logger,
IPermissionManager permissionManager,
ICacheManager cacheManager,
IUnitOfWorkManager unitOfWorkManager,
IRoleManagementConfig roleManagementConfig,
IRepository<OrganizationUnit, long> organizationUnitRepository,
IRepository<OrganizationUnitRole, long> organizationUntiRoleRepository)
: base(
store,
roleValidators,
keyNormalizer,
errors, logger,
permissionManager,
cacheManager,
unitOfWorkManager,
roleManagementConfig,
organizationUnitRepository,
organizationUntiRoleRepository)
{
}
}
Looks like if you are trying to model your RoleManager after the one that designed to work with Abp your parameters don't match the ones that are required for the base class.
This link relates to the Sample they provide.
https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/test/Abp.Zero.SampleApp/Roles/RoleManager.cs
This link refers to the implementation of the AbpRoleManager class itself.
https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore/Authorization/Roles/AbpRoleManager.cs

Getting Error Using Microsoft.AspNet.Membership.OpenAuth

I am getting an error using the RegisterExternalLogin control from the Visual Studio templates. After choosing login from Twitter, Twitter seems to process the login ok and then tries to load the response page and then the error occurs.
The error seems to be related to EntityFrameworks after the login method being called from the Microsoft.Aspnet.Membership.OpenAuth dll but that's about all I know.
Does anybody know how to resolve this?
Here is the error message:
[MissingMethodException: Method not found:
'System.Data.Objects.ObjectContext
System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.]
Microsoft.AspNet.Membership.OpenAuth.EFOpenAuthMembershipDatabase.EnsureDatabaseCreated(DbContext
db) +0
Microsoft.AspNet.Membership.OpenAuth.EFOpenAuthMembershipDatabase.GetMembershipUserName(String
providerName, String providerUserId, Boolean updateLastUsed) +221
Microsoft.AspNet.Membership.OpenAuth.OpenAuthManager.Login(HttpContextBase
context, String providerName, String providerUserId, Boolean
createPersistentCookie) +128
Microsoft.AspNet.Membership.OpenAuth.OpenAuth.Login(String
providerName, String providerUserId, Boolean createPersistentCookie)
+198 FinModelControls.Account.RegisterExternalLogin.ProcessProviderResult()
+594
Having similar exception, submitted a Conect bug.
https://connect.microsoft.com/VisualStudio/feedback/details/811035/microsoft-aspnet-membership-openauth-is-not-compatible-with-entity-framework-6
Solution: Make sure you're using latest v 2.0.0 Microsoft.AspNet.Membership.OpenAuth package, not 1.0.1.

Convention based binding in Ninject 3.0

I'm trying to setup Ninject on my new project and I want to scan assembilies using convetions so that
IFoo
will automatically resolve to
IBar
All the samples and documentation describes using this approach
kernel.Scan(...)
while the Ninject 3 Kernel seems to use .Load instead. If I'm using Load for scanning then how do I configure scanning with conventions?
Edit
I was able to get it working using: https://github.com/ninject/ninject.extensions.conventions/wiki/What-is-configuration-by-convention
However, now I can't get my modules to load. I'm using the code below and getting the error below.
IKernel kernel = new StandardKernel();
kernel.Bind(x => x
.FromAssembliesMatching("Crt.*.dll")
.SelectAllTypes()
.BindAllInterfaces()
);
kernel.Load("*.dll");
return kernel;
Error:
Ninject.ActivationException was unhandled
Message=Error activating ITrainingEngine
More than one matching bindings are available.
Activation path:
1) Request for ITrainingEngine
Suggestions:
1) Ensure that you have defined a binding for ITrainingEngine only once.
Source=Ninject
StackTrace:
at Ninject.KernelBase.Resolve(IRequest request) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 380
at Ninject.ResolutionExtensions.GetResolutionIterator(IResolutionRoot root, Type service, Func`2 constraint, IEnumerable`1 parameters, Boolean isOptional, Boolean isUnique) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 263
at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 37
at Crt.BlackBox.Train.Program.Run() in C:\code\Crimson\CRT\readmission\src\Crt.BlackBox\Crt.BlackBox.Train\Program.cs:line 54
at Crt.BlackBox.Train.Program.Main(String[] args) in C:\code\Crimson\CRT\readmission\src\Crt.BlackBox\Crt.BlackBox.Train\Program.cs:line 24
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Use SelectAllClasses instead of SelectAllTypes

If a ASMX WebService needs a DLL where should it be put?

I'm using some 3rd party software that's failing. Their API is wrapped in a ASP web service.
The call stack tells me that it needs maybe MySQL.Data.DLL or something (not sure exactly) in the correct directory. So I'm wondering where that directory would be. The Web Server is IIS.
Here is the call stack:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at WebReports.Api.Data.SqlObject.CreateConnectionObject(String dbType, String dataConnStr)
at WebReports.Api.Data.SqlObject..ctor(PageInfo pageInfo, Int32 dataSourceId)
at WebReports.Api.Data.DataObjectBase.GetDataObject(PageInfo pageInfo, Int32 dataSourceId, String objectType, Boolean isSqlSpecific)
at WebReports.Api.Reports.Entity.get_DataSource()
at WebReports.Api.Reports.Entity.GetColumnProcess(String colName, Boolean isActual)
at WebReports.Api.Reports.EntityColumnsCollection.GetColumnProcess(String colNameFull, Boolean isActual)
at WebReports.Api.Common.PageInfo.GetMnemonicFromId(String id)
at WebReports.Api.Reports.KeyColumnCollection.SetColumnMnemonics()
at WebReports.Api.Reports.ReportEntityCollection.SetColumnMnemonics()
at WebReports.Api.Reports.ReportEntityCollection.LoadData(DataSet ds, Boolean readSchema)
at WebReports.Api.Reports.Report.get_Entities()
at WebReports.Api.Common.PageInfo.GetMnemonicFromId(String id)
at WebReports.Api.Reports.Cell.set_SaveText(String value)
at WebReports.Api.Reports.ReportCellCollection.LoadData(DataSet ds)
at WebReports.Api.Reports.Report.get_Cells()
at WebReports.Api.Reports.Report.UpdateVersion()
at WebReports.Api.Reports.Report.Validate(Boolean validateJoins)
at WebReports.Api.Reports.Report.LoadData(Boolean validate)
at WebReports.Api.Reports.Report.Load(String reportName)
Above this line is their API, so I can't inspect it:
at eWebReportsLETG.ReportURLService.GenerateReportURL(Int32[] list, String m_szWebReportsVirtualDirectory, String m_szWebReportsUrl, String ReportDir, String ReportName, String PkSpecialName, Boolean& Failed) in C:\dev\eWebReports\eWebReportsLETG\ReportURLService.asmx.cs:line 51
I needed to copy MySQL.data.dll to the bin directory of my web service application directory. I also added the config key to the web.config.

Resources