Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies - asp.net-mvc

I have just tried to install Glimpse.MVC5 via Nuget.
After doing that I cannot run my application.
The error says that the assembly Glimpse.AspNet cannot be loaded, but I found that the dll at C:\Users\xxx\Documents\Visual Studio 2013\Projects\yyy\zzz\packages\Glimpse.AspNet.1.8.0\lib\net45\Glimpse.AspNet.dll does exist.
The error in full is;
Server Error in '/' Application.
Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Glimpse.AspNet' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Glimpse.AspNet
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Glimpse.AspNet | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/
LOG: Initial PrivatePath = C:\Users\xxx\Documents\Visual Studio 2013\Projects\yyy\zzz\zzz.yzyzyz\bin
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\xxx\Documents\Visual Studio 2013\Projects\yyy\zzz\zzz.yzyzyz\web.config
LOG: Using host configuration file: C:\Users\xxx\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet/Glimpse.AspNet.EXE.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet.EXE.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet/Glimpse.AspNet.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +70
System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +39
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +37
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +38
[ConfigurationErrorsException: Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +348
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) +19
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +39
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +42
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +158
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +950
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +82
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9931916
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248

I found what the problem was.
After I created a new project to my application, the project I loaded Glimpse into was not building, and that is why there was a problem. When I build the project individually it works. I need to sort out my builds

Related

HostGator MVC Upload

I am trying to upload my ASP.NET MVC app to hostgator but I keep receiving this error:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: Request failed.]
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +166
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +272
System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, RuntimeAssembly asm, SecurityAction action) +55
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +70
System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +39
System.Type.GetType(String typeName) +32
System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +10
System.Web.Compilation.CompilationUtil.GetRecompilationHash(CompilationSection ps) +2085
System.Web.Configuration.CompilationSection.get_RecompilationHash() +107
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDateInternal(Int64 cachedHash) +465
System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate(Int64 cachedHash) +51
System.Web.Compilation.BuildManager.ExecutePreAppStart() +132
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521
I try to resolve it by adding <trust level="Full"/> but once I do I receive another error.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using from an inherited configuration file.
Source Error:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
It says the error is on the same line as what i just added (<trust level="Full"/>). It just keeps going in circles and I don't know what else to do. If anyone has any ideas it would be a huge help. Thank you!

Asp.Net Mvc 4 website deploying on server throwing error "Could not load type 'System.Web.WebPages.DisplayModes'"

I am struggling with this issue from past 6 hours and still not able to figure this out. I was getting this exception when I deployed one of the Asp.Net Mvc 4 project on the server which is a shared hosting. I got this issue.
I googgled and found that it could be an issue related with the version differences of System.Web.Mvc and System.Web.WebPages. I verified version number of all dlls, tried to re-install using nuget, but still got the same message.
Thinking it could be an issue related with my project only, I created a new Asp.Net Mvc 4 Internet Application and deployed it on the server, boom... got the same message.
I spent next few hours un-installing all older versions of Asp.Mvc, repairing Visual Studio 2010, installing Mvc 4 again using Web Platform Installer, but nothing could help, still getting the same message.
Can anybody please help, I am just stuck.
Here is the error message
Could not load type 'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type 'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Could not load type 'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +0
System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +198
System.Web.Mvc.<>c__DisplayClassc.<FindView>b__a(IViewEngine e) +43
System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +177
System.Web.Mvc.ViewEngineCollection.Find(Func`2 cacheLocator, Func`2 locator) +23
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +144
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +151
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +846308
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +846608
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Here are the link that I googled and found to resolve the issue:
http://tkntips.blogspot.in/2012/05/could-not-load-type-systemwebwebpagesdi.html
Solution is not that clear. Did not work for me.

Error on using usercontrol on umbraco azure

The user control that I am using is working perfectly on my umbraco ie installed on local machine but when I uploaded it on the azure website the user control is showing errors like these
Error reading usercontrols/MdriveReg.ascx
The following list shows the Public Properties from the Control. By checking the Properties and click the "Save Properties" button at the bottom, umbraco will create the corresponding Macro Elements.
System.Web.HttpParseException (0x80004005): Could not load type 'MdriveUmbraco.MdriveReg'. ---> System.Web.HttpParseException (0x80004005): Could not load type 'MdriveUmbraco.MdriveReg'. ---> System.Web.HttpException (0x80004005): Could not load type 'MdriveUmbraco.MdriveReg'. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at umbraco.developer.assemblyBrowser.Page_Load(Object sender, EventArgs e)
I'm not an Azure pro, but it looks like it can't load the assembly that your user control is referencing (MdriveUmbraco.dll?).
Does this assembly exist in the bin folder of the web site? Perhaps it's in the GAC of your local machine and thus not problematic there?
Do assemblies need to be signed to run in Azure? Perhaps you need to sign it?
The Problem was that my .dll file was not loading properly so I created a new project coded it to my requirements and then I build it and placed it in to my umbraco running in windows azure it worked.
THE PROBLEM WAS WITH MY .dll FILE

Unable to Create DbContext per Request with Simple Injector

Simple Inject is throwing the following exception when attempting to register my DbContext.
The supplied connection string is not valid, because it contains insufficient mapping or metadata information.
Parameter name: connectionString
I'm new to DI and could be missing something fairly obvious. The connection string looks fine. It is the same one that gets used to create the DbContext normally. I was attempting the solution here
public static class SimpleInjectorInitializer
{
/// <summary>Initialize the container and register
// it as MVC3 Dependency Resolver.</summary>
public static void Initialize()
{
var container = new Container();
InitializeContainer(container);
container.RegisterMvcControllers(
Assembly.GetExecutingAssembly());
container.RegisterMvcAttributeFilterProvider();
container.Verify();
DependencyResolver.SetResolver(
new SimpleInjectorDependencyResolver(container));
}
private static void InitializeContainer(
Container container)
{
}
}
Update: I still haven't solved my issue, but it is very similar to this issue with Ninject
Stack Trace:
System.InvalidOperationException was unhandled by user code
Message=The configuration is invalid. Creating the instance for type _AccountController failed. Error occurred while trying to get an instance of type _AccountController. The type initializer for 'Web.Controllers._AccountController' threw an exception.
Source=SimpleInjector
StackTrace:
at SimpleInjector.Helpers.Verify(IInstanceProducer instanceProducer, Type serviceType)
at SimpleInjector.Container.ValidateRegistrations()
at SimpleInjector.Container.Verify()
at Web.App_Start.SimpleInjectorInitializer.Initialize() in C:\workspace\BrowsarServer\QARSite\Web\App_Start\SimpleInjectorInitializer.cs:line 24
InnerException: SimpleInjector.ActivationException
Message=Error occurred while trying to get an instance of type _AccountController. The type initializer for 'Web.Controllers._AccountController' threw an exception.
Source=SimpleInjector
StackTrace:
at SimpleInjector.InstanceProducers.InstanceProducer.ThrowErrorWhileTryingToGetInstanceOfType(Exception innerException)
at SimpleInjector.InstanceProducers.InstanceProducer.GetInstance()
at SimpleInjector.Helpers.Verify(IInstanceProducer instanceProducer, Type serviceType)
InnerException: System.TypeInitializationException
Message=The type initializer for 'Web.Controllers._AccountController' threw an exception.
Source=Web
TypeName=Web.Controllers._AccountController
StackTrace:
at Web.Controllers._AccountController..ctor()
at lambda_method(Closure )
at SimpleInjector.InstanceProducers.InstanceProducer.GetInstance()
InnerException: System.ArgumentException
Message=The supplied connection string is not valid, because it contains insufficient mapping or metadata information.
Parameter name: connectionString
Source=System.Data.Entity
ParamName=connectionString
StackTrace:
at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at Web.Models.BrowsarEntities..ctor() in C:\workspace\BrowsarServer\QARSite\Web\Models\Browsar.Designer.cs:line 90
at Web.Controllers._AccountController..cctor() in C:\workspace\BrowsarServer\QARSite\Web\Controllers\_AccountController.cs:line 15
InnerException: System.InvalidOperationException
Message=Unable to determine application context. The ASP.NET application path could not be resolved.
Source=System.Data.Entity
StackTrace:
at System.Data.Metadata.Edm.AspProxy.GetBuildManagerReferencedAssemblies()
at System.Data.Metadata.Edm.DefaultAssemblyResolver.GetAllDiscoverableAssemblies()
at System.Data.Metadata.Edm.DefaultAssemblyResolver.GetWildcardAssemblies()
at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataCache.SplitPaths(String paths)
at System.Data.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()
at System.Data.Common.Utils.Memoizer`2.Result.GetValue()
at System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg)
at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)
at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()
at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)
InnerException: System.Reflection.TargetInvocationException
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Data.Metadata.Edm.AspProxy.GetBuildManagerReferencedAssemblies()
InnerException: System.InvalidOperationException
Message=This method cannot be called during the application's pre-start initialization stage.
Source=System.Web
StackTrace:
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.GetReferencedAssemblies()
InnerException:
The root cause is burried deep down in the inner exceptions. When inspecting the stack trace, you will be able to find the cause of this. The reason is in the following two inner exceptions:
InvalidOperationException: Unable to determine application context.
The ASP.NET application path could not be resolved.
and:
InvalidOperationException: This method cannot be called during the
application's pre-start initialization stage.
In other words, this exception is caused by a timing problem. I'm not sure if you can change your connection string to solve this, but you can also move your initalization to a later moment in starting the application. You can do this as follows:
Remove the [assembly: WebActivator.PreApplicationStartMethod] (top line) of the SimpleInjectorInitializer.cs class.
Add a call to the SimpleInjectorInitializer.Initialize() method in the Application_Start() event of the global asax.
After doing this, initializing (and especially, verifying) of the object graph is done after the pre-init state, which seems to be too early for EF in an ASP.NET environment.
Another option is to remove the container.Verify(); call from the SimpleInjectorInitializer.Initialize method, since it is the early verification process that is killing you. However, please read this Verify the container’s configuration first, to see alternatives, before doing so.
Although you use a class DbContext it looks like it is derived from ObjectContext. In that case you should use an EntityConnectionStringBuilder to build the connection string.
You may be missing some of the metadata information in your connection string. For example entity framework has some special metadata in the connection string, see sample below:
<add name="MyEntities" connectionString="metadata=res://*/MyEntitiesStore.csdl|res://*/MyEntitiesStore.ssdl|res://*/MyEntitiesStore.msl;provider=System.Data.SqlClient;provider connection string="Data Source=<your server>;Initial Catalog=<your DB>;Integrated Security=False;User ID=<user>;Password=<pass>;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />

DynamicData RegisterContext error using multiple edmx

Before posting this I made sure to read all suggestion made from SO.
The application currently has two projects one for the web application and one for the Entity Frame work (version 4.0). We are trying a tool from RSSBus for the Quickbooks Provider description here
Setting it up was easy enough. I prefixed QB on all the entities and generated the QB.tt file, no issues. Both edmx files are housed in the same project using a shared namespace (SMR.Model)
When I rebuilt the project to run it the global.asax.cs file threw an error:
DefaultModel.RegisterContext(typeof(SMR.Model.SMREntities),
new ContextConfiguration() { ScaffoldAllTables = true });
The error given was:
The given key was not present in the dictionary.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Source Error:
Line 36: public static void RegisterRoutes(RouteCollection routes)
Line 37: {
Line 38: DefaultModel.RegisterContext(typeof(SMR.Model.SMREntities),
Line 39: new ContextConfiguration() { ScaffoldAllTables = true });
Line 40:
Source File: C:\all\src\smr\smr.pl.Web\Global.asax.cs Line: 38
Stack Trace:
[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary2.get_Item(TKey key) +9624829
System.Web.DynamicData.ModelProviders.EFDataModelProvider..ctor(Object contextInstance, Func1 contextFactory) +800
System.Web.DynamicData.ModelProviders.SchemaCreator.CreateDataModel(Object contextInstance, Func1 contextFactory) +126
System.Web.DynamicData.MetaModel.RegisterContext(Func1 contextFactory, ContextConfiguration configuration) +378
System.Web.DynamicData.MetaModel.RegisterContext(Type contextType, ContextConfiguration configuration) +88
smr.pl.Web.Global.RegisterRoutes(RouteCollection routes) in C:\all\src\smr\smr.pl.Web\Global.asax.cs:38
smr.pl.Web.Global.Application_Start(Object sender, EventArgs e) in C:\all\src\smr\smr.pl.Web\Global.asax.cs:91
[HttpException (0x80004005): The given key was not present in the dictionary.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9170941
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +131
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): The given key was not present in the dictionary.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090044
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
With so little to go on as to what could eb the problem I looked at the .config files to see if they were wrong and all checked out as ok.
<add name="SMREntities" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SMR;Persist Security Info=True;User ID=sa;Password=XXX;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
<add name="RSSQBEntities" connectionString="metadata=res://*/Model.QBOE.csdl|res://*/Model.QBOE.ssdl|res://*/Model.QBOE.msl;provider=System.Data.RSSBus.QuickBooks;provider connection string="Offline=False;Application Id=987654321;Connection Ticket=TGT-000-T_xxxxxxxxxxxxxxxxxxxx;Online Login=ohno"" providerName="System.Data.EntityClient" />
Any thoughts as to what is causing the structure to fail like this?
I finally figured out the "real" problem. I first seperated the two models into separate projects. The problem I was facing was the metadata was being integrated into the same assembly namespace. I resolved my issue by updating the res://*/ section
<add name="SMREntities" connectionString="metadata=res://SMR.Model/;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SMR;Persist Security Info=True;User ID=sa;Password=XXX;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
<add name="RSSQBEntities" connectionString="metadata=res://SMR.QBOE/Model.RSSQBOE.csdl|res://SMR.QBOE/Model.RSSQBOE.ssdl|res://SMR.QBOE/Model.RSSQBOE.msl;provider=System.Data.RSSBus.QuickBooks;provider connection string="Offline=False;Application Id=987654321;Connection Ticket=TGT-000-T_xxxxxxxxxxxxxxxxxxxx;Online Login=ohno"" providerName="System.Data.EntityClient" />
A Classic "the issue is not the issue".

Resources