Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Deployment 部署时未加载RazorGenerator.Mvc.dll_Deployment_Asp.net Mvc 4_Razorgenerator - Fatal编程技术网

Deployment 部署时未加载RazorGenerator.Mvc.dll

Deployment 部署时未加载RazorGenerator.Mvc.dll,deployment,asp.net-mvc-4,razorgenerator,Deployment,Asp.net Mvc 4,Razorgenerator,使用mvc.razor generator,一切正常。我的图书馆项目中的视图在我的网站中显示良好。这是一个.NET4.0、MVC4和EF5项目。应用程序池在IIS中设置为.net 4.0 当我部署到服务器时,当它尝试加载预编译的MVCEngine类型时,我会遇到一个异常。 以下是例外情况(我已附上附件中错误的完整输出): 正如你所看到的,这是来自我的共同项目 以下是银行标识代码管理器的内容: 2012-10-17 09:06 PM <DIR> . 2012-10-17 09:06 P

使用mvc.razor generator,一切正常。我的图书馆项目中的视图在我的网站中显示良好。这是一个.NET4.0、MVC4和EF5项目。应用程序池在IIS中设置为.net 4.0

当我部署到服务器时,当它尝试加载预编译的MVCEngine类型时,我会遇到一个异常。 以下是例外情况(我已附上附件中错误的完整输出):

正如你所看到的,这是来自我的共同项目

以下是银行标识代码管理器的内容:

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
2012-10-17 09:06下午。
2012-10-17 09:06下午。。
2012-10-10 12:51 AM 105528 Antlr3.Runtime.dll
2012-10-09 07:05 PM 1118296 EntityFramework.dll
2012-10-16 01:26 PM 359424 MyProj.Common_vs2010.dll
2012-10-16 01:26 PM 112128 MyProj.Common_vs2010.pdb
2012-10-09 06:46 PM 45416 Microsoft.Web.Infrastructure.dll
2012-10-17 09:06 PM 29696 MyProj.dll
2012-10-17 09:06 PM 42496 MyProj.pdb
2012-10-13 08:04下午15872 Mvc.Mailer.dll
2012-10-09 06:46 PM 374784 Newtonsoft.Json.dll
2012-10-09 06:56下午15872 RazorGenerator.Mvc.dll
2012-10-09 06:46 PM 180832 System.Net.Http.dll
2012-10-09 06:46下午168544 System.Net.Http.Formatting.dll
2012-10-09 06:46 PM 16480 System.Net.Http.WebRequest.dll
2012-10-09 06:46 PM 138328 System.Web.Helpers.dll
2012-10-09 06:46 PM 323168 System.Web.Http.dll
2012-10-09 06:46 PM 73312 System.Web.Http.WebHost.dll
2012-10-09 06:46 PM 506976 System.Web.Mvc.dll
2012-10-10 12:51 AM 54912 System.Web.Optimization.dll
2012-10-09 06:46 PM 264792 System.Web.Razor.dll
2012-10-09 06:46 PM 41048 System.Web.WebPages.Deployment.dll
2012-10-09 06:46 PM 204376 System.Web.WebPages.dll
2012-10-09 06:46 PM 39512 System.Web.WebPages.Razor.dll
2012-10-09 06:56 PM 8704 WebActivator.dll
2012-10-10 12:51 AM 963640 webfleep.dll
24个文件5204136字节
2个目录1519661289472字节可用
RazorGenerator.Mvc.dll存在于其中,因此我不确定它为什么不能加载该类型


如果W7 Pro出现问题,服务器将是全新安装。

事实证明,问题并不在于razor generator。问题是RG通过反射加载的类缺少正确的程序集。那是两个Webmatrix assmebly的

事实证明,即使在库项目中设置了“复制本地”,VisualStudio2010和2012也不会实际复制它(如果它存在于生成机器的GAC中)。在我的例子中,构建机器安装了该程序集(由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},\n\n", 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);
}

不太好,但我会想办法让它看起来更好,以后再使用。:)

谢谢-这非常有帮助!在新版本2.3.4中仍然会发生这种情况吗?我目前正在运行版本2.2.3,这非常有用,并为我节省了不少时间。谢谢您正在运行哪个版本的RazorGenerator?
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},\n\n", 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);
}