错误处理无法将类型为 master的对象强制转换为类型 master

出错信息的例子:
下面这些出错信息,是你遇上这些编译问题时,你也许看到的运行时异常类型的例子:

Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.
(无法将ASP.masterpage_master类型的对象转换成ASP.masterpage_master类型)
或者:

Could not load file or assembly 'App_Web_e9dbmaj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
(无法装载文件或程序集“App_Web_e9dbmaj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”或它的依赖向。系统找不到指定的文件。)
或者:

Compiler Error Message: CS0006: Metadata file 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cms.web\44e73607\b028acb3\App_global.asax.fakktchx.dll' could not be found
(编译错误信息:CS0006:找不到元数据文件“C:\WINDOWS\Microsoft.NET\Framework\v2.0. 50727\Temporary ASP.NET Files\cms.web\44e73607\b028acb3\App_global.asax.fakktchx. dll”。)
或者:

System.InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again
(System.InvalidOperationException: 找不到当前页面的资源类。请检查资源文件确实存在,然后再试。)
这些问题的临时解决方案:
如果你有一个应用开始抛出上面这些错误中的某一个时,你通常可以马上施用一个临时解决方案,打开你应用的web.config文件,将 <compilation> 节的 batch 属性设置成false:

<configuration>

<system.web>
<compilation debug="false" batch="false"></compilation>
</system.web>

</configuration>
这告诉ASP.NET把单个的 .aspx/.ascx 文件动态编译成单独的程序集,这会避免触发异常的循环引用的问题。

你也可以使用下列步骤,删去“Temporary ASP.NET Files”缓存里的文件,来临时解决这个问题:

点击Windows开始按钮,点击运行,输入 iisreset /stop,然后点击OK。
打开 驱动字母: WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files 目录。
删除第二步里你找出的目录里的所有文件和所有文件夹。
点击开始,点击运行,输入 iisreset /start,然后点击OK

原文地址:https://www.cnblogs.com/zhangji/p/1852007.html