I have a website made in Asp.net MVC which is installed in the root directory of shared hosting enviroment.
Now, I have made a mobile version for this site in Asp.net MVC and installed it as a sub-domain http://m.price-tag.org which points to a folder m(set as virtual directory) in root directory.
When someone visits the site from mobile, an assembly qualified name error is shown which goes off when the page is refreshed. Following is the screen-shot for iPhone emulator which displays the same error. Even in emulator, the error goes when the page is refreshed.
The strange part is that the type mentioned in error is used in my main website and not the mobile website. Why is this happening when my mobile project is completely different and has its own web.config but somehow, it seems that the root's web.config is used ? Can this be a web.config issue
NOTE:- Both projects have their own EntityObject, Models and Web.config files and nothing is shared between them.
EDIT:- This error shows in mobile only.....And that too first time, if one refreshes the page, it goes away.
EDIT with Stack Trace
[InvalidOperationException: The type 'PriceCompare.Models.PriceCompareEntity,
PriceCompare' could not be found. The type name must be an assembly-qualified name.]
System.Data.Entity.Internal.DatabaseInitializerConfig.ApplyInitializer() +315
[InvalidOperationException: Failed to set database initializer of type 'Disabled' for DbContext type 'PriceCompare.Models.PriceCompareEntity, PriceCompare' specified in the application configuration. Entries should be of the form 'key="DatabaseInitializerForType MyNamespace.MyDbContextClass, MyAssembly" value="MyNamespace.MyInitializerClass, MyAssembly"' or 'key="DatabaseInitializerForType MyNamespace.MyDbContextClass, MyAssembly" value="Disabled"'. The initializer class must have a parameterless constructor. See inner exception for details.]
System.Data.Entity.Internal.DatabaseInitializerConfig.ApplyInitializer() +383
System.Data.Entity.Internal.DatabaseInitializerConfig.ApplyInitializersFromConfig() +288
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +59
System.Data.Entity.Internal.LazyInternalContext.b__4(InternalContext c) +7
System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input) +118
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
1 action) +190
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +27
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +62
System.Data.Entity.Internal.Linq.InternalSet
1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider() +37
System.Linq.Queryable.OrderByDescending(IQueryable
1 source, Expression1 keySelector) +66
PriceMobile.Controllers.HomeController.Index() in HomeController.cs:19
lambda_method(Closure , ControllerBase , Object[] ) +40
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary
2 parameters) +188
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +267
System.Web.Mvc.<>c__DisplayClass17.b__14() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +190
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329
System.Web.Mvc.Controller.ExecuteCore() +115
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +93
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult
1.End() +55
System.Web.Mvc.<>c__DisplayClasse.b__d() +31
System.Web.Mvc.SecurityUtil.b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +23
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
You need to use inheritInChildApplications, so that application inside sub directory will not use the root application configuration. See this for detail.
For appSettings section, one can't use location tag. Therefore configurations which uses key/value pair, one needs to use the
clear
tag in child directories web.configSomething is shared - PriceCompareEntity has to be. I had a similar problem. I included a DLL in one project that had a reference to another I didn't think I needed. The site failed with a similar error caling for a type in the referred-DLL.
Virtual directories/application by default inherit the root web.config file. We can stop this behavior by having,
in root web.config
Please visit for More information
Two possibilities: 1) PriceCompare not only is the name of a namespace and of a dll but ALSO the name of some Type. The system is confused by this omonimy. Try to change either the name of the type or the name of both the dll and the namespace. 2) the web site is not able to find the PriceCompare dll with the right version. This might happen because some part of the system refers to an old version of this dll. Only one of the two dll is taken so one of the two references fails. Clean up your project to solve this