This is most likely an error which occurs due to syntax error. Check your curly braces and make sure fields and methods are not accidently out of the scope of their class.
I've encountered some similar errors in the views before. What worked for me was deleting the files in the obj, bin and packages folders — then restarting and rebuilding the solution just in case.
Hello,
Now I have encountered this issue when I run the application
info: EPiServer.Framework.Initialization.InitializationEngine[0]
Initialization started
fail: EPiServer.Framework.Initialization.InitializationEngine[0]
Initialize action failed for 'Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=12.5.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'
System.InvalidOperationException: Unable to resolve service for type 'EPiServer.Marketing.KPI.Dal.KpiDatabaseContext' while attempting to activate 'EPiServer.Marketing.KPI.Dal.BaseRepository'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters,
Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters,
Boolean throwIfCallSiteNotFound)
So added the solution as suggested in this blog post https://kunalshetye.com/posts/add-a-b-testing-to-cms12/
But this line services.AddABTesting(_configuration.GetConnectionString("EPiServerDB")); gives error for AddABTesting() method. Anybody know if it's predefined within IServiceCollection or need to create new method?
Hey
epiServices.AddScoped<KpiDatabaseContext>(e.Services, x =>
{
return new KpiDatabaseContext(x.GetRequiredService<IConfiguration>(), "EPiServerDB");
});
episervices here is EPiServer.ServiceLocation.ServiceLocationExtensions.
Hope this helps!
We used upgarde-assistant tool to upgrade project from CMS 11 to 12 and fixed errors in code files. But there are some errors pointed out in view files as shown in below image and those line number within error message doesn't match to line numbers in view.
Please help if anybody is aware what is causing these errors.