奇怪的程序集名称从手机访问网站时出错
我有一个用 Asp.net MVC 制作的网站,它安装在共享托管环境的根目录中。
现在,我已经在 Asp.net MVC 中为此网站制作了一个移动版本,并将其安装为子域 http: //m.price-tag.org 指向根目录中的文件夹m(设置为虚拟目录)。
当有人通过移动设备访问该网站时,会显示程序集限定名称错误,该错误会在刷新页面时消失。以下是 iPhone 模拟器的屏幕截图,显示相同的错误。即使在模拟器中,刷新页面时也会出现错误。
奇怪的是,错误中提到的类型用于我的主网站而不是移动网站。当我的移动项目完全不同并且有自己的 web.config 但不知何故,似乎使用了根的 web.config 时,为什么会发生这种情况?这是否是一个 web.config 问题
注意:- 两个项目都有自己的 EntityObject、模型和 Web.config 文件,并且它们之间没有共享任何内容。
编辑:-此错误仅在移动设备中显示......而且也是第一次,如果刷新页面,它就会消失。
使用堆栈跟踪进行编辑
[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:无法为应用程序配置中指定的 DbContext 类型“PriceCompare.Models.PriceCompareEntity、PriceCompare”设置类型为“Disabled”的数据库初始值设定项。条目的格式应为 'key="DatabaseInitializerForType MyNamespace.MyDbContextClass, MyAssembly" value="MyNamespace.MyInitializerClass, MyAssembly"' 或 'key="DatabaseInitializerForType MyNamespace.MyDbContextClass, MyAssembly" value="Disabled"'。初始化类必须有一个无参数构造函数。有关详细信息,请参阅内部异常。] 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 输入) +118 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(操作
1操作)+190 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型实体类型)+27 System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +62 System.Data.Entity.Internal.Linq.InternalSet
1.get_InternalContext() +15 System.Data.Entity.Infrastruct.DbQuery1.System.Linq.IQueryable.get_Provider() +37 System.Linq.Queryable.OrderByDescending(IQueryable
1 源,Expression1 keySelector)+66 HomeController.cs 中的 PriceMobile.Controllers.HomeController.Index():19 lambda_method(闭包,ControllerBase,对象[])+40 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,Object[]参数)+17 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContextcontrollerContext,IDictionary
2个参数)+188 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 个参数) +27 System.Web.Mvc.<>c__DisplayClass15.
1延续)+267 System.Web.Mvc.<>c__DisplayClass17.b__14() +20 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContextcontrollerContext,IList1个过滤器,ActionDescriptoractionDescriptor,IDictionary
2个参数)+190 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContextcontrollerContext,字符串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.
1.End() +55 System.Web.Mvc.<>c__DisplayClasse.b__d() +31 System.Web.Mvc.SecurityUtil.b__0(操作 f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(操作操作)+23 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+59 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 结果) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,Boolean&completedSynchronously) +184
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
1 action) +190
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +27
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +62
1.get_InternalContext() +15
System.Data.Entity.Internal.Linq.InternalSet
System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider() +37
1 source, Expression
System.Linq.Queryable.OrderByDescending(IQueryable1 keySelector) +66
2 parameters) +188
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
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +27
1 continuation) +267
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
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
1.End() +55
System.Web.Mvc.Async.WrappedAsyncResult
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
虚拟目录/应用程序默认继承根 web.config 文件。我们可以通过
在根 web.config 中
添加请访问了解更多信息来阻止此行为
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
您需要使用inheritInChildApplications,以便子目录内的应用程序不会使用根应用程序配置。有关详细信息,请参阅此。
对于 appSettings 部分,不能使用位置标签。因此使用键/值对的配置,需要在子目录 web.config 中使用
clear
标签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.config有些东西是共享的——PriceCompareEntity 必须是共享的。我有类似的问题。我在一个项目中包含了一个 DLL,该项目引用了另一个我认为不需要的项目。该站点因对引用的 DLL 中的类型进行类似的错误校准而失败。
Something 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.
两种可能性:
1) PriceCompare 不仅是命名空间和 dll 的名称,而且也是某些类型的名称。系统对这种同名关系感到困惑。尝试更改类型名称或 dll 和命名空间的名称。
2) 网站无法找到正确版本的 PriceCompare dll。发生这种情况可能是因为系统的某些部分引用了该 dll 的旧版本。仅获取两个 dll 之一,因此两个引用之一失败。清理你的项目来解决这个问题
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