首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ASP MVC2部署到IIS7时出错

ASP MVC2部署到IIS7时出错
EN

Stack Overflow用户
提问于 2011-04-26 10:23:13
回答 2查看 920关注 0票数 1

在我将应用程序部署到IIS7服务器之后,开始看起来还不错,并且可以显示登录页面。但在用户输入用户名和密码后,我必须通过DB连接验证用户。此时,它会显示错误(已附加)。我猜这个错误是由EntityFramwork加载DB数据时的反射引起的。

我的服务器已经安装了.net Framework3.5 sp1。

另一方面,我已经尝试了另一台服务器。如果服务器已经安装了VS2008和MVC2 VS2008软件包,则该服务器可以在IIS7中正确运行应用程序。

我的目标是在只有.net Framework3.5的IIS7服务器上运行这个应用程序。

请帮我解决这个问题。

错误数据:

代码语言:javascript
运行
复制
Server Error in '/FDDV_demo' Application.
--------------------------------------------------------------------------------

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. 
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.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

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: 


[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
   System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) +0
   System.Reflection.Assembly.GetTypes() +111
   System.Data.Metadata.Edm.AssemblyCacheEntry.LoadTypesFromAssembly(LoadingContext context) +28
   System.Data.Metadata.Edm.AssemblyCacheEntry.InternalLoadAssemblyFromCache(LoadingContext context) +290
   System.Data.Metadata.Edm.AssemblyCacheEntry.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, Dictionary`2 knownAssemblies, Dictionary`2& typesInLoading, List`1& errors) +137
   System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies) +284
   System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyForType(Type type) +33
   System.Data.Metadata.Edm.MetadataWorkspace.LoadAssemblyForType(Type type, Assembly callingAssembly) +80
   System.Data.Objects.ObjectContext.CreateQuery(String queryString, ObjectParameter[] parameters) +106
   FDDV.Models.DBEntities.get_user_master() +113
   FDDV.Controllers.HomeController.validateUser(String userid, String password) +254
   FDDV.Controllers.HomeController.LogOn(LogOnModel model, String returnUrl) +134
   lambda_method(ExecutionScope , ControllerBase , Object[] ) +136
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
   System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +53
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258
   System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +193
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +316
   System.Web.Mvc.Controller.ExecuteCore() +104
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +36
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
   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() +53
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +43
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8682542
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-28 13:51:24

我终于解决了这个问题。主要原因是项目遗漏了一些程序集引用。我将以下代码添加到登录函数中,以找出反射类型加载异常。再次感谢大家的帮助。

代码语言:javascript
运行
复制
try{
    //Do your work

        } 
    catch (Exception ex)
                        {

                            ReflectionTypeLoadException exception = ex as ReflectionTypeLoadException;

                            if (exception == null)
                                System.IO.File.AppendAllText("C:\\TestLog.txt", "Not a ReflectionTypeLoadException ex.");
                            else
                            {
                                foreach (Exception loaderException in exception.LoaderExceptions)
                                {
                                    System.IO.File.AppendAllText("C:\\TestLog.txt", loaderException.Message);
                                    System.IO.File.AppendAllText("C:\\TestLog.txt", loaderException.StackTrace);
                                }
                            }

                            return true;

                        }
票数 1
EN

Stack Overflow用户

发布于 2011-04-27 13:14:31

我隐约记得,当我从MVC2升级一个项目时,在我的web.config中遇到了一些版本问题,MVC3也有类似的问题。

尝试启用融合程序集日志绑定,看看是否可以找到加载失败的原因。

http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx

不久前我发现了一个脚本,可以让我在IIS中更好地处理融合日志(我遇到了一些问题,因为它在IIS中不能运行)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5785269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档