System.Web.HttpcontextBase problems in Orchard 1.8 (possibly due to Visual studio 2015) - stack-overflow

I'm running a website on Orchard 1.8.
I tried Visual Studio 2015 RC and built my Orchard project using this version. Since then, my error logs are flooded with the Autofac errors saying that System.Web.HttpContextBase cannot be resolved (see stacktrace below).
I reverted back to VS2013 (i did not uninstall VS2015) but the errors didn't go away. I'm not sure if this is even the problem...
My test environment to which I deployed the solution also started having the same problems.
Could this be related to the .NET version which is installed? (4.6 local, 4.5.2 remote)
Also, this seems to be causing stack overflow exceptions which are a huge problem at the moment. Any leads are highly appreciated!
2015-06-08 13:34:54,921 [25] Orchard.Exceptions.DefaultExceptionPolicy - (null) - An unexpected exception was caught
(null)
Autofac.Core.DependencyResolutionException: A delegate registered to create instances of 'System.Web.HttpContextBase' returned null.
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 70
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:line 122
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Autofac.Features.Collections.CollectionRegistrationSource.c__DisplayClass4.b__0(IComponentContext c, IEnumerable`1 p) in c:\Projects\OSS\autofac\Core\Source\Autofac\Features\Collections\CollectionRegistrationSource.cs:line 75
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 69
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 69
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:line 122
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\InstanceLookup.cs:line 79
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Autofac.Features.Collections.CollectionRegistrationSource.c__DisplayClass4.b__0(IComponentContext c, IEnumerable`1 p) in c:\Projects\OSS\autofac\Core\Source\Autofac\Features\Collections\CollectionRegistrationSource.cs:line 75
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 69
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Activators\Delegate\DelegateActivator.cs:line 69
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 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, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 123
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Resolving\ResolveOperation.cs:line 85
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) in c:\Projects\OSS\autofac\Core\Source\Autofac\Core\Lifetime\LifetimeScope.cs:line 232
at Autofac.Features.LazyDependencies.LazyRegistrationSource.c__DisplayClass5`1.c__DisplayClass7.b__4() in c:\Projects\OSS\autofac\Core\Source\Autofac\Features\LazyDependencies\LazyRegistrationSource.cs:line 85
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at Orchard.ContentManagement.DefaultContentManager.New(String contentType) in C:\projects\web\src\Orchard\ContentManagement\DefaultContentManager.cs:line 95
at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in C:\projects\web\src\Orchard\ContentManagement\DefaultContentManager.cs:line 219
at Orchard.ContentManagement.ContentGetExtensions.Get[T](IContentManager manager, Int32 id, VersionOptions options) in C:\projects\web\src\Orchard\ContentManagement\ContentExtensions.cs:line 160
at Orchard.Settings.CurrentSiteWorkContext.Get[T](String name) in C:\projects\web\src\Orchard\Settings\CurrentSiteWorkContext.cs:line 13
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Orchard.Environment.WorkContextImplementation.FindResolverForState[T](String name) in C:\projects\web\src\Orchard\Environment\WorkContextImplementation.cs:line 0
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Orchard.Environment.WorkContextImplementation.GetState[T](String name) in C:\projects\web\src\Orchard\Environment\WorkContextImplementation.cs:line 27
at Orchard.ContentPermissions.Security.AuthorizationEventHandler.Complete(CheckAccessContext context)
at Orchard.Events.DelegateHelper.c__DisplayClass14_0`2.b__0(Object target, Object[] p) in C:\projects\web\src\Orchard\Events\DelegateHelper.cs:line 116
at Orchard.Events.DefaultOrchardEventBus.TryInvokeMethod(IEventHandler eventHandler, Type interfaceType, String messageName, String interfaceName, String methodName, IDictionary`2 arguments, IEnumerable& returnValue) in C:\projects\web\src\Orchard\Events\DefaultOrchardEventBus.cs:line 80
at Orchard.Events.DefaultOrchardEventBus.TryNotifyHandler(IEventHandler eventHandler, String messageName, String interfaceName, String methodName, IDictionary`2 eventData, IEnumerable& returnValue) in C:\projects\web\src\Orchard\Events\DefaultOrchardEventBus.cs:line 53

As fixed in this commit for 1.9, i was able to pick out some of the parts of the commit and was able to fix the error.

I had this error showing up when running the command "feature enable Orchard.Packaging" after a build in Visual Studio 2015.
I went back to VS 2012, made a fresh build of the project and ran again the same command "feature enable Orchard.Packaging", it started working.
Finally I was able to run the command "package create...". Modules and Themes started being updated agan.

Related

Visual Studio Docker HTTPS setup fails

I am trying to get a project running with the new visual studio 2019 on mac.
However, I am getting the following error.
Application startup exception: Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = KestrelServer (ReflectionActivator), Services = [Microsoft.AspNetCore.Hosting.Server.IServer], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptions`1[Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions], Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.ITransportFactory, Microsoft.Extensions.Logging.ILoggerFactory)' on type 'KestrelServer'. ---> error:2006D080:BIO routines:BIO_new_file:no such file (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.IOptions`1[Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions], Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.ITransportFactory, Microsoft.Extensions.Logging.ILoggerFactory)' on type 'KestrelServer'. ---> error:2006D080:BIO routines:BIO_new_file:no such file (See inner exception for details.) ---> Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file
at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)
at Internal.Cryptography.Pal.CertificatePal.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, String fileName, String password)
at Identity.API.Program.<>c.<BuildWebHost>b__1_3(ListenOptions listenOptions) in /Users/pp/www/amritaDEV/appraisals/Amrita/src/Services/Identity/Identity/Program.cs:line 56
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions.Listen(IPEndPoint endPoint, Action`1 configure)
at Identity.API.Program.<>c.<BuildWebHost>b__1_0(KestrelServerOptions options) in /Users/pp/www/amritaDEV/appraisals/Amrita/src/Services/Identity/Identity/Program.cs:line 54
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 Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.CreateServiceContext(IOptions`1 options, ILoggerFactory loggerFactory)
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.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
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.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
Application startup exception
I have been doing: https://github.com/aspnet/AspNetCore.Docs/issues/6199
and i completed the steps but got the following error. Something with the certificates, names or places maybe?
I am on Visual Studio 8. Visual Studio 7 didn't have HTTPS problem for localhost

get fatal error: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException'

Sometimes we get error System.OutOfMemoryException . complete error is
FATAL 2017-12-24 17:01:45,360 [39 ] Abp.AbpBootstrapper - System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at Abp.Modules.AbpModule.FindDependedModuleTypes(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 108
at Abp.Modules.AbpModule.AddModuleAndDependenciesRecursively(List1 modules, Type module) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 143
at Abp.Modules.AbpModule.FindDependedModuleTypesRecursivelyIncludingGivenModule(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 124
at Abp.Modules.AbpModuleManager.FindAllModuleTypes(List1& plugInModuleTypes) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 86
at Abp.Modules.AbpModuleManager.LoadAllModules() in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 67
at Abp.Modules.AbpModuleManager.Initialize(Type startupModule) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 40
at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 146
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at Abp.Modules.AbpModule.FindDependedModuleTypes(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 108
at Abp.Modules.AbpModule.AddModuleAndDependenciesRecursively(List1 modules, Type module) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 143
at Abp.Modules.AbpModule.FindDependedModuleTypesRecursivelyIncludingGivenModule(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 124
at Abp.Modules.AbpModuleManager.FindAllModuleTypes(List1& plugInModuleTypes) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 86
at Abp.Modules.AbpModuleManager.LoadAllModules() in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 67
at Abp.Modules.AbpModuleManager.Initialize(Type startupModule) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 40
at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 146
we use ASPNetBoilerplate, AngularJs and entity framework
looks like you've misconfigured ABP dependencies. FindDependedModuleTypesRecursivelyIncludingGivenModule() method recursively loads dependent modules and it might go into infinite loop. check all the [DependsOn(typeof(XXXX))] attributes!

Swagger issue with Autofac

I'm struggling with an issue due Autofac and Swagger. When I try to reach the Swagger UI I have this exception:
500 : { "message": "An error has occurred.", "exceptionMessage":
"None of the constructors found with
'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type
'MRV.EntregaChaves.PEC.Api.Areas.HelpPage.XmlDocumentationProvider'
can be invoked with the available services and parameters:\r\nCannot
resolve parameter 'System.String documentPath' of constructor 'Void
.ctor(System.String)'.", "exceptionType":
"Autofac.Core.DependencyResolutionException", "stackTrace": " at
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext
context, IEnumerable1 parameters)\r\n at
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1
parameters)\r\n at Autofac.Core.Resolving.InstanceLookup.Execute()\r\n
at
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope
currentOperationScope, IComponentRegistration registration,
IEnumerable1 parameters)\r\n at
Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters)\r\n at
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration
registration, IEnumerable1 parameters)\r\n at
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters)\r\n at
Autofac.Core.Container.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters)\r\n at
Autofac.ResolutionExtensions.TryResolveService(IComponentContext
context, Service service, IEnumerable1 parameters, Object&
instance)\r\n at
Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext
context, Service service, IEnumerable1 parameters)\r\n at
Autofac.ResolutionExtensions.ResolveOptional(IComponentContext
context, Type serviceType, IEnumerable1 parameters)\r\n at
Autofac.ResolutionExtensions.ResolveOptional(IComponentContext
context, Type serviceType)\r\n at
Autofac.Integration.WebApi.AutofacWebApiDependencyScope.GetService(Type
serviceType)\r\n at
Autofac.Integration.WebApi.AutofacWebApiDependencyResolver.GetService(Type
serviceType)\r\n at
System.Web.Http.Services.DefaultServices.GetService(Type
serviceType)\r\n at
System.Web.Http.ServicesExtensions.GetService[TService](ServicesContainer
services)\r\n at
System.Web.Http.ServicesExtensions.GetDocumentationProvider(ServicesContainer
services)\r\n at
System.Web.Http.Description.ApiExplorer.GetApiDocumentation(HttpActionDescriptor
actionDescriptor)\r\n at
System.Web.Http.Description.ApiExplorer.PopulateActionDescriptions(HttpActionDescriptor
actionDescriptor, IHttpRoute route, String localPath, Collection1
apiDescriptions)\r\n at
System.Web.Http.Description.ApiExplorer.ExploreDirectRoute(HttpControllerDescriptor
controllerDescriptor, CandidateAction[] candidates, IHttpRoute
route)\r\n at
System.Web.Http.Description.ApiExplorer.InitializeApiDescriptions()\r\n
at System.Lazy1.CreateValue()\r\n--- End of stack trace from previous
location where exception was thrown ---\r\n at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at
System.Lazy`1.get_Value()\r\n at
System.Web.Http.Description.ApiExplorer.get_ApiDescriptions()\r\n at
Swashbuckle.Swagger.SwaggerGenerator.GetApiDescriptionsFor(String
apiVersion)\r\n at
Swashbuckle.Swagger.SwaggerGenerator.GetSwagger(String rootUrl, String
apiVersion)\r\n at
Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage
request, CancellationToken cancellationToken)\r\n at
System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage
request, CancellationToken cancellationToken)\r\n at
System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage
request, CancellationToken cancellationToken)\r\n at
System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage
request, CancellationToken cancellationToken)\r\n at
System.Web.Http.HttpServer.<>n__FabricatedMethod9(HttpRequestMessage ,
CancellationToken )\r\n at
System.Web.Http.HttpServer.d__0.MoveNext()" }
http://localhost:18184/swagger/docs/v1
I was able to solve the issue fallowing the official github respository Swashbuckle.
The problem was due OWIN. I miss installed the package Swashbuckle.Core.

Security Exception with medium trust, ninject and entity framework

I keep getting this exception whenever I try running my project in medium trust. The project is MVC Forum, and even though I don't need to run any of my own sites in medium trust, I figure I better make it work in the medium trust environment anyway.
I'm using Ninject for DI (the DLL that works in medium trust), and that works - the MVC controllers are loaded with constructor injection as expected.
The "funny" thing is that the method (in my code) that fails, take 2 arguments, these are both loaded from the database using entity framework, so I have no idea why this fails, when entity framework clearly already work in other parts of the code.
What is the reason behind this exception? It's like looking for the famous needle in a haystack.
Here's the stacktrace:
[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
System.Security.CodeAccessPermission.Demand() +46
System.Data.Common.Internal.Materialization.Translator.DemandMemberAccess() +50
System.Data.Common.Internal.Materialization.Shaper`1..ctor(DbDataReader reader, ObjectContext context, MetadataWorkspace workspace, MergeOption mergeOption, Int32 stateCount, CoordinatorFactory`1 rootCoordinatorFactory, Action checkPermissions, Boolean readerOwned) +165
System.Data.Common.Internal.Materialization.ShaperFactory`1.Create(DbDataReader reader, ObjectContext context, MetadataWorkspace workspace, MergeOption mergeOption, Boolean readerOwned) +93
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext context, ObjectParameterCollection parameterValues) +736
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +149
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +182
System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1(IEnumerable`1 sequence) +41
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +59
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +150
System.Data.Entity.Internal.Linq.DbQueryProvider.Execute(Expression expression) +102
System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +265
ApplicationBoilerplate.DataProvider.EntityFramework.Repository`1.ReadOne(ISpecification`1 spec) +217
mvcForum.Web.Extensions.ForumExtensions.GetAccess(Forum forum, Group group) +129
mvcForum.Web.Extensions.ForumExtensions.GetAccess(Forum forum) +895
mvcForum.Web.ViewModels.ForumViewModel..ctor(Forum forum, Int32 topicsPerPage) +1353
mvcForum.Web.Areas.Forum.Controllers.HomeController.Index() +1260
lambda_method(Closure , ControllerBase , Object[] ) +74
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Small update, I'm using code first. Thanks for looking!
This looks like the exception you get if your entity classes contain properties that are not public--i.e. they are internal, protected, or private. EF5 and below only support mapping to public properties when running in a partial trust environment.

System.ArgumentException: Duplicate type name within an assembly

I am working on an ASP.Net MVC 3 web application using EF 4.1. Since today, I am getting this error:
System.ArgumentException: Duplicate type name within an assembly
and I can't figure out what is causing it. It is happening in my repository when performing a Find:
public virtual T GetById(long id)
{
return dbset.Find(id);
}
Here is the stack trace:
[ArgumentException: Duplicate type name within an assembly.]
System.Reflection.Emit.ModuleBuilder.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +9544354
System.Reflection.Emit.AssemblyBuilderData.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +53
System.Reflection.Emit.TypeBuilder.Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, Module module, PackingSize iPackingSize, Int32 iTypeSize, TypeBuilder enclosingType) +178
System.Reflection.Emit.ModuleBuilder.DefineType(String name, TypeAttributes attr, Type parent, Type[] interfaces) +118
System.Data.Objects.Internal.ProxyTypeBuilder.get_TypeBuilder() +299
System.Data.Objects.Internal.ProxyTypeBuilder.CreateType(ModuleBuilder moduleBuilder) +227
System.Data.Objects.Internal.EntityProxyFactory.BuildType(ModuleBuilder moduleBuilder, ClrEntityType ospaceEntityType) +63
System.Data.Objects.Internal.EntityProxyFactory.TryCreateProxyType(EntityType ospaceEntityType) +193
System.Data.Objects.Internal.EntityProxyFactory.GetProxyType(ClrEntityType ospaceEntityType) +104
System.Data.Common.Internal.Materialization.Translator.Visit(EntityColumnMap columnMap, TranslatorArg arg) +178
System.Data.Query.InternalTrees.EntityColumnMap.Accept(ColumnMapVisitorWithResults`2 visitor, TArgType arg) +16
System.Data.Common.Internal.Materialization.Translator.ProcessCollectionColumnMap(CollectionColumnMap columnMap, TranslatorArg arg, ColumnMap discriminatorColumnMap, Object discriminatorValue) +116
System.Data.Common.Internal.Materialization.Translator.Visit(SimpleCollectionColumnMap columnMap, TranslatorArg arg) +13
System.Data.Query.InternalTrees.SimpleCollectionColumnMap.Accept(ColumnMapVisitorWithResults`2 visitor, TArgType arg) +17
System.Data.Common.Internal.Materialization.Translator.TranslateColumnMap(QueryCacheManager queryCacheManager, ColumnMap columnMap, MetadataWorkspace workspace, SpanIndex spanIndex, MergeOption mergeOption, Boolean valueLayer) +314
System.Data.Common.Internal.Materialization.TypedShaperFactoryCreator`1.TypedCreate(QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, Boolean valueLayer) +64
System.Data.Common.Internal.Materialization.ShaperFactory.Create(Type elementType, QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, Boolean valueLayer) +185
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters) +285
System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +696
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +149
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +184
System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__2(IEnumerable`1 sequence) +41
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +59
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +150
System.Linq.Queryable.SingleOrDefault(IQueryable`1 source) +265
System.Data.Entity.Internal.Linq.InternalSet`1.FindInStore(WrappedEntityKey key, String keyValuesParamName) +602
System.Data.Entity.Internal.Linq.InternalSet`1.Find(Object[] keyValues) +124
System.Data.Entity.DbSet`1.Find(Object[] keyValues) +12
XXXXXXXX.Data.Infrastructure.RepositoryBase`1.GetById(Int64 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Data\Infrastructure\RepositoryBase.cs:58
MatchesHorsConcours.Service.MatchService.GetMatch(Int32 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Service\XxxService.cs:55
XXXXXXXX.Controllers.XXXXXXXX.Edit(Int32 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Web\Controllers\XxxController.cs:130
lambda_method(Closure , ControllerBase , Object[] ) +101
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8920029
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
This could be related to table in which I duplicated a foreign key. It was called something like myKeyId, and I now have myKey1Id and myKey2Id in that table. I checked everywhere in my code, and I can't find myKeyId anymore.
The error message is so generic that I don't know how to pin-point what is causing this error. Any advice would be welcome.
I hade the same error.
I did clean solution rebuilt and it worked.
My solution was to turn off IIS and then start VS project again.
I ran into this error today, too.
It turned out, that my data model has missing the foreign and primary key constraints in the data base.
I had copied the original database to a local database to speed up the execution, but I had only copied the data and not the relationships.
Other errors i had in this context were
an item with the same key has already been added
and
Unable to update the EntitySet Table because it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element to support the current operation
it all was due to a faultive database structure
Ran into this issue today. I deleted all of my tables from the Entity Model .edmx file, the updated my model from the Database (right-click --> update from database).
Then I re-compiled and it ran fine. Such an odd error.
I am running MVC 4 and EF 5.0

Resources