Cannot choose between multiple constructors with equal length 1 on type 'System.String' - string

I am getting the following error when trying to resolve a type:
Cannot choose between multiple constructors with equal length 1 on type 'System.String'. Select the constructor explicitly, with the UsingConstructor() configuration method, when the component is registered.
The type has 1 constructor that takes an IRepository and an ILog so I don't really know where the System.String is coming in to the picture. I'm perplexed. Does anyone have any idea what the problem is?
Here is the stack trace:
at Autofac.Core.Activators.Reflection.MostParametersConstructorSelector.SelectConstructorBinding(ConstructorParameterBinding[] constructorBindings)
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c_DisplayClass2.b_0()
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c_DisplayClass2.b_0()
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
at SomeCompany.ComponentModel.Composition.AutofacIocContainer.Resolve(Type type) in c:\SomeCompany.Core\ComponentModel\Composition\AutofacIocContainer.cs:line 17
at SomeCompany.Commands.CommandFactory.Create(String name) in c:\SomeCompany.Core\Commands\CommandFactory.cs:line 28
at SomeCompany.Web.Controllers.CommandsController.Post(String id, String request) in c:\SomeCompany.Web\Controllers\CommandsController.cs:line 49
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)

This has nothing to do with multiple constuctors on your own code!
Autofac automatically creates objects for the constructor of your subject when you don't set them explicitly yourself.
However, when your constructor has a String parameter, it can not create a string, as String does not have a parameterless constructor! [1]
You need to set all strings on the constructor of your subject explicitly. You can also use NamedParameters and give Strings an explicit value.
Good luck!
[1] http://msdn.microsoft.com/en-us/library/system.string%28v=vs.110%29.aspx

If you have a database-definition file (.dbml), check for modifications to the code that you didn't make. In my case, the following method
public JudicialDataContext(string connectionString) : base(connectionString, mappingSource)
{
OnCreated();
}
was changed to this:
public JudicialDataContext(string connection) : base(connection, mappingSource)
{
OnCreated();
}
I have no idea why it did this, or what it is trying to accomplish by doing this, or why this change would even be necessary. But discarding the change and recompiling overcame this error.

Related

Azure API Management returning "Setting 'config.db.connection' could not be found."

We have exposed some Azure Functions through Azure API Management. The functions work when called directly and the endpoints in Api Management also used to work. Now when we call the api management endpoints they return
[ConfigurationErrorsException: Setting 'config.db.connection' could not be found.]
Microsoft.Azure.ApiManagement.Infra.Configuration.SettingsProviderExtensions.GetSetting(ISettingsProvider provider, String name) in e:\Checkin package\AAPT\APIM\Infra\Infra\src\Infra\Configuration\SettingsProviderExtensions.cs:19
Microsoft.WindowsAzure.ApiManagement.Proxy.Api.Settings.get_SqlConnectionString() in D:\Checkin-Master\AAPT\APIManagement\Proxy\Api\Service\Settings.cs:43
Microsoft.Azure.ApiManagement.Gateway.IoC.Modules.c.b__0_0(IComponentContext c) in D:\Checkin-Master\AAPT\APIManagement\Proxy\Gateway.IoC\Modules\SqlConfigurationModule.cs:38
Autofac.c__DisplayClass10`1.b__f(IComponentContext c, IEnumerable`1 p) +10
Autofac.Builder.c__DisplayClass1`1.b__0(IComponentContext c, IEnumerable`1 p) +14
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
Microsoft.Azure.ApiManagement.Gateway.IoC.Modules.c.b__0_4(IComponentContext c) in D:\Checkin-Master\AAPT\APIManagement\Proxy\Gateway.IoC\Modules\ConfigurationModule.cs:116
Autofac.c__DisplayClass10`1.b__f(IComponentContext c, IEnumerable`1 p) +10
Autofac.Builder.c__DisplayClass1`1.b__0(IComponentContext c, IEnumerable`1 p) +14
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.Core.Activators.Reflection.c__DisplayClass2.b__0() +25
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +174
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +44
[DependencyResolutionException: An exception was thrown while executing a resolve operation. See the InnerException for details. ---> Setting 'config.db.connection' could not be found. (See inner exception for details.)]
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +112
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +109
Autofac.Core.Container.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +14
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
Autofac.ResolutionExtensions.Resolve(IComponentContext context) +75
Microsoft.Azure.ApiManagement.Gateway.Host.SystemWeb.GatewayStartup.Configuration(IAppBuilder app) in D:\Checkin-Master\AAPT\APIManagement\Proxy\Gateway.Host.SystemWeb\GatewayStartup.cs:75
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +160
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
Owin.Loader.c__DisplayClass12.b__b(IAppBuilder builder) +66
Owin.Loader.c__DisplayClass1.b__0(IAppBuilder builder) +123
Microsoft.Owin.Host.SystemWeb.c__DisplayClass2.b__0(IAppBuilder builder) +71
Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action`1 startup) +462
Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action`1 startup) +40
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +70
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +523
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +220
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +303
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +658
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +89
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189
Where is this db.connection setting that is missing?
I guess you were using consumption sku. Apim had a bug in upgrade. This should not be happening anymore.

Sitecore Logs - Azure Search

Currently I'm seeing the following a lot in my logs, I'm using Sitecore 8.2 rev 2 with azure. The issue only started recently when I added some new indexes to the site for a new microsite. Any ideas of where to start investigating, I've raised with Sitecore too?
ManagedPoolThread #17 22:03:10 ERROR Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Jobs.Job.ThreadEntry(Object state)
Nested Exception
Exception: System.AggregateException
Message: One or more errors occurred.
Source: mscorlib
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, ParallelOptions parallelOptions, Action`2 body)
at Sitecore.ContentSearch.AbstractSearchIndex.PerformUpdate(IEnumerable`1 indexableInfo, IndexingOptions indexingOptions)
Nested Exception
Exception: System.InvalidOperationException
Message: Sequence contains no elements
Source: System.Core
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at Sitecore.ContentSearch.Azure.CloudSearchUpdateContext.Delete(IIndexableId id)
at Sitecore.ContentSearch.SitecoreItemCrawler.Update(IProviderUpdateContext context, IIndexableUniqueId indexableUniqueId, IndexEntryOperationContext operationContext, IndexingOptions indexingOptions)
at Sitecore.ContentSearch.AbstractSearchIndex.<>c__DisplayClass93_2.<PerformUpdate>b__0(IndexableInfo info, ParallelLoopState parallelLoopState)
at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object )
For those with the same issue,
The patch is Sitecore.Support.158988 found here:
https://github.com/SitecoreSupport/Sitecore.Support.158988
Versions cover Sitecore 8.2 update 1 and update 2.
164633 The CloudSearchUpdateContext.Delete(IIndexableId) fails with an exception in case the search index does not contain any matching documents.
Thanks.
Looks like there is a patch for this from Sitecore, hopefully this will resolve the issue.

Net Core 2.0 Microsoft.Extensions.Configuration.ConfigurationBinder.BindInstance(Type type, Object instance, IConfiguration config) is not thread safe

Platform: NetCore 2.0
Issue location: getting IOptionsSnapshot in service constructor.
Description: Under loading testing with high pressure I had an exception (very rarely): "Collection was modified; enumeration operation may not execute."
It happens in class\function Microsoft.Extensions.Configuration.ConfigurationBinder.BindInstance(Type type, Object instance, IConfiguration config) line 269
if(config != null && config.GetChildren().Any())
Regarding trace log it happens in linq function Any(). Looks like ConfigurationBinder is not thread safe here.
Any thoughts how it could be fixed?
Trace logs:
[2017-12-22T09:37:38.3955213Z] Level=Error, Category=Autofac, Id=qq,
Message= Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PlaybackService (ReflectionActivator), Services = [XXXXXXXXXXXXXXXXXXXXXXXXXX.IPlaybackService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope --->
An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = IntegrationService (ReflectionActivator), Services = [XXXXXXXXXXXXXXXXXXXXXXXXXX.IIntegrationService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope --->
An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TokenRepository (ReflectionActivator), Services = [XXXXXXXXXXXXXXXXXXXXXXXXXX.ITokenRepository], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope --->
An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptionsSnapshot`1[XXXXXXXXXXXXXXXXXXXXXXXXXX.DXXXXConfig], XXXXXXXXXXXXXXXXXXXXXXXXXX.ICertificateRepository)' on type 'TokenRepository'. --->
Collection was modified; enumeration operation may not execute. (See inner exception for details.) --->
Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = IntegrationService (ReflectionActivator), Services = [XXXXXXXXXXXXXXXXXXXXXXXXXX.IIntegrationService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope --->
An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TokenRepository (ReflectionActivator), Services = [XXXXXXXXXXXXXXXXXXXXXXXXXX.ITokenRepository], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope --->
An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptionsSnapshot`1[XXXXXXXXXXXXXXXXXXXXXXXXXX.DXXXXXXConfig], XXXXXXXXXXXXXXXXXXXXXXXXXX.ICertificateRepository)' on type 'TokenRepository'. --->
Collection was modified; enumeration operation may not execute. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.) --->
Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TokenRepository (ReflectionActivator), Services = [XXXXXXXXXXXXXXXXXXXXXXXXXX.ITokenRepository], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope --->
An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptionsSnapshot`1[XXXXXXXXXXXXXXXXXXXXXXXXXX.DXXXXConfig], XXXXXXXXXXXXXXXXXXXXXXXXXX.ICertificateRepository)' on type 'TokenRepository'. --->
Collection was modified; enumeration operation may not execute. (See inner exception for details.) (See inner exception for details.) --->
Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptionsSnapshot`1[XXXXXXXXXXXXXXXXXXXXXXXXXX.DXXXXConfig], XXXXXXXXXXXXXXXXXXXXXXXXXX.ICertificateRepository)' on type 'TokenRepository'. --->
Collection was modified; enumeration operation may not execute. (See inner exception for details.) --->
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.SparseArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d_3.MoveNext()
at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.SparseArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d3.MoveNext()
at System.Linq.Enumerable.DistinctIterator`1.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at Microsoft.Extensions.Configuration.ConfigurationBinder.BindInstance(Type type, Object instance, IConfiguration config)
at Microsoft.Extensions.Configuration.ConfigurationBinder.BindProperty(PropertyInfo property, Object instance, IConfiguration config)
at Microsoft.Extensions.Configuration.ConfigurationBinder.BindNonScalar(IConfiguration configuration, Object instance)
at Microsoft.Extensions.Configuration.ConfigurationBinder.BindInstance(Type type, Object instance, IConfiguration config)
at Microsoft.Extensions.Configuration.ConfigurationBinder.Bind(IConfiguration configuration, Object instance)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at lambda_method(Closure , Object[] )
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() — End of inner exception stack trace —
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) — End of inner exception stack trace —
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) — End of inner exception stack trace —
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) — End of inner exception stack trace —
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Microsoft.Extensions.Internal.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>cDisplayClass5_0.<CreateControllerFactory>gCreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d_14.MoveNext() — End of stack trace from previous location where exception was thrown ---... MESSAGE Truncated=True DUE TO EXCEEDING MaxAllowedCharacterLength=10000, ActualCharacterLength=11707

Orchard CMS - Sudden 404 during development

I was getting close to completing my first site using Orchard CMS, and when I went to enable the 'blog' module I saw an error page. I wish I had paid more attention to it, instead I closed it and restarted my site.
Now, I get 404 errors and I can access the front or back end of my site. I'm at a loss.
I found these in the error logs but I really don't know where to go from here...
2014-01-01 19:58:09,140 [11] Orchard.Environment.DefaultOrchardHost - A tenant could not be started: Default
Autofac.Core.DependencyResolutionException: None of the constructors found with 'Orchard.Environment.AutofacUtil.DynamicProxy2.ConstructorFinderWrapper' on type 'Orchard.Blogs.Routing.ArchiveConstraint' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Autoroute.Services.IPathResolutionService pathResolutionService' of constructor 'Void .ctor(Orchard.Autoroute.Services.IPathResolutionService)'.
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:line 118
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Resolving.InstanceLookup.b_0() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 64
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Lifetime\LifetimeScope.cs:line 270
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 64
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 119
at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c__DisplayClass2.<CanSupplyValue>b__0() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\AutowiringParameter.cs:line 62
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ConstructorParameterBinding.cs:line 114
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:line 122
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 64
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Lifetime\LifetimeScope.cs:line 270
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 64
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 119
at Autofac.Features.Collections.CollectionRegistrationSource.<>c_DisplayClass4.<>c_DisplayClass6.b_1(IComponentRegistration cr) in c:\Projects\OSS\autofac\Core\Source\Autofac\Features\Collections\CollectionRegistrationSource.cs:line 75
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Autofac.Features.Collections.CollectionRegistrationSource.<>c_DisplayClass4.b_0(IComponentContext c, IEnumerable1 p) in c:\Projects\OSS\autofac\Core\Source\Autofac\Features\Collections\CollectionRegistrationSource.cs:line 75
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 68
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 61
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 119
at Autofac.Core.Registration.ExternalRegistrySource.<>c__DisplayClass8.<RegistrationsFor>b__3(IComponentContext c, IEnumerable1 p) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Registration\ExternalRegistrySource.cs:line 80
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 68
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 61
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 119
at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c_DisplayClass2.b_0() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\AutowiringParameter.cs:line 62
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ConstructorParameterBinding.cs:line 114
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:line 122
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Resolving.InstanceLookup.b__0() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 64
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Lifetime\LifetimeScope.cs:line 270
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 64
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 119
at Autofac.Core.Registration.ExternalRegistrySource.<>c__DisplayClass8.<RegistrationsFor>b__3(IComponentContext c, IEnumerable1 p) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Registration\ExternalRegistrySource.cs:line 80
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 68
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 61
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 85
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Lifetime\LifetimeScope.cs:line 232
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) in c:\Projects\OSS\autofac\Core\Source\Autofac\ResolutionExtensions.cs:line 736
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\ResolutionExtensions.cs:line 343
at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\ResolutionExtensions.cs:line 197
at Orchard.Environment.ShellBuilders.ShellContextFactory.CreateShellContext(ShellSettings settings) in d:\Builds\OrchardFull\src\Orchard\Environment\ShellBuilders\ShellContextFactory.cs:line 78
at Orchard.Environment.DefaultOrchardHost.CreateShellContext(ShellSettings settings) in d:\Builds\Or
Grant all users NTFS write permission on the Orchard.Web folder. This might help -- I had a similar error when permissions were not set.
Also, make sure that AppPool user (or Network service - if that's who owns your application pool) is dbo in the database that you are connecting to.
AppPool user name is "IIS AppPool\" -- you add this user as windows user in SQL server, and then user/role mapping give him dbo permissions for required database.

web api internal error 500

I am using the laatest version of web api.
I am returning a IQuerable value and i am getting this error:
iisexpress.exe Error: 0 : Operation=QueryableAttribute.ActionExecuted, Status=200 (OK), Exception=System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Web.Http.OData.Builder.EdmTypeBuilder.CreateStructuralTypeBody(EdmStructuredType type, IStructuralTypeConfiguration config)
at System.Web.Http.OData.Builder.EdmTypeBuilder.CreateEntityTypeBody(EdmEntityType type, IEntityTypeConfiguration config)
at System.Web.Http.OData.Builder.EdmTypeBuilder.CreateEdmTypeBody(IStructuralTypeConfiguration config)
at System.Web.Http.OData.Builder.EdmTypeBuilder.<GetEdmTypes>d__0.MoveNext()
at System.Linq.Enumerable.<OfTypeIterator>d__aa`1.MoveNext()
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector)
at System.Web.Http.OData.Builder.EdmModelHelperMethods.BuildEdmModel(String containerNamespace, String containerName, IEnumerable`1 entityTypeConfigurations, IEnumerable`1 entitySetConfigurations)
at System.Web.Http.OData.Builder.ODataModelBuilder.GetEdmModel()
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.GetEdmModel()
at System.Web.Http.HttpActionDescriptorExtensions.<>c__DisplayClass1.<GetEdmModel>b__0(Object _)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Web.Http.HttpActionDescriptorExtensions.GetEdmModel(HttpActionDescriptor actionDescriptor, Type entityClrType)
at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
at System.Web.Http.Tracing.Tracers.ActionFilterAttributeTracer.<>c__DisplayClass4.<OnActionExecuted>b__1()
at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEnd(ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action`1 beginTrace, Action execute, Action`1 endTrace, Action`1 errorTrace)
iisexpress.exe Error: 0 : Operation=InteractionDataController.ExecuteAsync, Exception=System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Web.Http.OData.Builder.EdmTypeBuilder.CreateStructuralTypeBody(EdmStructuredType type, IStructuralTypeConfiguration config)
at System.Web.Http.OData.Builder.EdmTypeBuilder.CreateEntityTypeBody(EdmEntityType type, IEntityTypeConfiguration config)
at System.Web.Http.OData.Builder.EdmTypeBuilder.CreateEdmTypeBody(IStructuralTypeConfiguration config)
at System.Web.Http.OData.Builder.EdmTypeBuilder.<GetEdmTypes>d__0.MoveNext()
at System.Linq.Enumerable.<OfTypeIterator>d__aa`1.MoveNext()
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector)
at System.Web.Http.OData.Builder.EdmModelHelperMethods.BuildEdmModel(String containerNamespace, String containerName, IEnumerable`1 entityTypeConfigurations, IEnumerable`1 entitySetConfigurations)
at System.Web.Http.OData.Builder.ODataModelBuilder.GetEdmModel()
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.GetEdmModel()
at System.Web.Http.HttpActionDescriptorExtensions.<>c__DisplayClass1.<GetEdmModel>b__0(Object _)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Web.Http.HttpActionDescriptorExtensions.GetEdmModel(HttpActionDescriptor actionDescriptor, Type entityClrType)
at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
at System.Web.Http.Tracing.Tracers.ActionFilterAttributeTracer.<>c__DisplayClass4.<OnActionExecuted>b__1()
at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEnd(ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action`1 beginTrace, Action execute, Action`1 endTrace, Action`1 errorTrace)
at System.Web.Http.Tracing.Tracers.ActionFilterAttributeTracer.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecuted(HttpActionContext actionContext, HttpResponseMessage response, Exception exception)
at System.Web.Http.Filters.ActionFilterAttribute.<>c__DisplayClass2.<System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync>b__0(HttpResponseMessage response)
at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass41`2.<Then>b__40(Task`1 t)
at System.Threading.Tasks.TaskHelpersExtensions.ThenImpl[TTask,TOuterResult](TTask task, Func`2 continuation, CancellationToken cancellationToken, Boolean runSynchronously)
Can someone explain me what the problem is ?
I was getting this same error. I traced it down to when ODataModelBuilder calls GetEdmModel(). I'm using ODataConventionModelBuilder and I'm declaring EntitySets to create my model. In my case, I have a parent class with a child collection. I tried different types of collections, IList, List, ICollection, IEnumerable, and I continued to get this error. I know this isn't the best solution, but I declare the child collection as object. I assign the collection as IEnumerable using Linq. I'll keep looking into this, but at least I can continue with my project. I'll have to keep researching the ODataConventionModelBuilder. I hope this at least points you in the right direction.
-Jason
This seems to be a known issue in WebApi.OData package (0.1.0-alpha-120815). See http://aspnetwebstack.codeplex.com/discussions/394626

Resources