部署 – 部署时不加载RazorGenerator.Mvc.dll
使用mvc.razor生成器可以正常工作.我的图书馆项目的视图在我的网站上显示得很好.它是一个.net 4.0,MVC4,EF5项目. IIS中的应用程序池设置为.net 4.0.
当我部署到服务器时,我在尝试加载PrecompiledMvc??Engine类型时遇到异常. 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.RuntimeModule.GetTypes(RuntimeModule module) +0 System.Reflection.Assembly.GetTypes() +159 RazorGenerator.Mvc.PrecompiledMvcEngine..ctor(Assembly assembly,String baseVirtualPath) +1209 RazorGenerator.Mvc.PrecompiledMvcEngine..ctor(Assembly assembly) +53 MyProj.Common.App_Start.RazorGeneratorMvcStart.Start() in E:UserFilessheamDocumentsVisual Studio 2010ProjectsMyProjProject.Common_vs2010App_StartRazorGeneratorMvcStart.cs:11 正如您所看到的,这来自我的共同项目. 以下是bin director的内容: 2012-10-17 09:06 PM <DIR> . 2012-10-17 09:06 PM <DIR> .. 2012-10-10 12:51 AM 105,528 Antlr3.Runtime.dll 2012-10-09 07:05 PM 1,118,296 EntityFramework.dll 2012-10-16 01:26 PM 359,424 MyProj.Common_vs2010.dll 2012-10-16 01:26 PM 112,128 MyProj.Common_vs2010.pdb 2012-10-09 06:46 PM 45,416 Microsoft.Web.Infrastructure.dll 2012-10-17 09:06 PM 29,696 MyProj.dll 2012-10-17 09:06 PM 42,496 MyProj.pdb 2012-10-13 08:04 PM 15,872 Mvc.Mailer.dll 2012-10-09 06:46 PM 374,784 Newtonsoft.Json.dll 2012-10-09 06:56 PM 15,872 RazorGenerator.Mvc.dll 2012-10-09 06:46 PM 180,832 System.Net.Http.dll 2012-10-09 06:46 PM 168,544 System.Net.Http.Formatting.dll 2012-10-09 06:46 PM 16,480 System.Net.Http.WebRequest.dll 2012-10-09 06:46 PM 138,328 System.Web.Helpers.dll 2012-10-09 06:46 PM 323,168 System.Web.Http.dll 2012-10-09 06:46 PM 73,312 System.Web.Http.WebHost.dll 2012-10-09 06:46 PM 506,976 System.Web.Mvc.dll 2012-10-10 12:51 AM 54,912 System.Web.Optimization.dll 2012-10-09 06:46 PM 264,792 System.Web.Razor.dll 2012-10-09 06:46 PM 41,048 System.Web.WebPages.Deployment.dll 2012-10-09 06:46 PM 204,376 System.Web.WebPages.dll 2012-10-09 06:46 PM 39,512 System.Web.WebPages.Razor.dll 2012-10-09 06:56 PM 8,704 WebActivator.dll 2012-10-10 12:51 AM 963,640 WebGrease.dll 24 File(s) 5,204,136 bytes 2 Dir(s) 1,519,661,289,472 bytes free RazorGenerator.Mvc.dll存在于那里,所以我不确定为什么它无法加载该类型. 如果是W7 Pro,服务器是全新安装的. 解决方法
事实证明,实际上并不是剃须刀发生器.问题是RG通过反射加载的类缺少正确的程序集.这是两个Webmatrix的瑕疵.
事实证明,即使设置了本地复制(在库项目中),如果构建计算机的GAC中存在Visual Studio 2010和2012,它实际上也不会复制它.在我的情况下,构建机器已安装该组件(由MVC3),但Web服务器没有.我最终将这些程序集添加到我的Web项目(而不是库)中,并将它们设置为本地副本. 这是一个令人讨厌的错误.我构建了一个特殊的异常处理程序,如果它再次发生,它会快速指出这个问题我的RazorGeneratorMvcStart中的Start()函数现在看起来像这样: public static void Start() { PrecompiledMvcEngine engine = null; try { engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) { UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal }; } catch (System.Reflection.ReflectionTypeLoadException e) { StringBuilder exceptions = new StringBuilder("The following DLL load exceptions occurred:"); foreach (var x in e.LoaderExceptions) exceptions.AppendFormat("{0},nn",x.Message); throw new Exception(string.Format("Error loading Razor Generator Stuff:n{0}",exceptions)); } ViewEngines.Engines.Insert(0,engine as PrecompiledMvcEngine); // StartPage lookups are done by WebPages. VirtualPathFactoryManager.RegisterVirtualPathFactory(engine as PrecompiledMvcEngine); } 不好,但我会弄清楚如何使它看起来更好,并可以在以后重复使用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows – 如何了解跨平台游戏开发?
- Windows – Active Directory站点 – 设计和连接
- Visual Studio 关闭鼠标悬停时自动出现快速文档浮
- 批处理文件 – Windows批处理文件过早终止
- windows-server-2008 – 将Windows Server 2008升
- windows – 使用Chocolatey创建自己的包
- 在运行VM的Hyper-V服务器上运行Windows Update的
- windows平台下微信多开的方法
- 如何在Windows 8应用程序中使用c#添加facebook r
- windows-server-2003 – 如何在Windows Small Bu