Failed to create AppDomain 'xxx'. Exception has been Failed to create AppDomain

一服务器上的数据库全部被置于紧急模式(EMERGENCY),在错误日志里面能看到大量下面的错误

Failed to create AppDomain "YourSQLDba.dbo[runtime].79". Exception has been thrown by the target of an invocation.

Failed to create AppDomain "YourSQLDba.dbo[runtime].76". Exception has been thrown by the target of an invocation.

....................................................................

在Error Log里面,我们可以看到甚至包括YourSQLDba这个库也被设置为单用户模式、紧急模式。如下截图所示,这个发生在凌晨YourSQLDba_FullBackups_And_Maintenance作业启动做备份、维护的时候。

clipboard

Google 搜索了一下这方面资料,看到了官方的一个解释,如下所示。 具体参考这个链接Failed to create AppDomain "master.sys[runtime].X"

Microsoft 在 2011/12/6 於 22:24 公佈

Errors like:
Msg 6517, Level 16, State 1, Line 3
AppDomain "MDS.dbo [runtime] .20" Could not create.
Exception has been thrown by the target of an invocation.

come directly from .NET/CLR itself. It's usually about some inconsistency with the CLR/.NET itself. It means the CLR installation is corrupted (unlikely), or, more likely, a .NET patch was recently installed and the machine is pending a reboot.
Let us know if reboot doesn't fix the problem.
About the upgrade failure from upgrade step 677 to 678: this issue is fixed in Denali RC1.

翻译过来就是:这个错误通常是.NET/CLR 它本身导致的,通常是由于CLR/.NET它本身的一些不一致性导致(inconsistency),这意味着CLR安装损坏了(这个不太可能),大部分是由于最近安装了.NET 补丁,服务器没有重新启动导致。

继 续查找更早的日志,其实发现9号就有这个“Failed to create AppDomain "YourSQLDba.dbo[runtime].xx". Exception has been thrown by the target of an invocation"这个错误出现,告警邮件也有收到,只是忙于处理其它事情,没有留意。

检查系统日志(Windows NT System log),发现确实存在Microsoft .NET Framework 自动更新的记录。如下所示

clipboard[1]

另外在”控制面板“->"程序”->"程序和功能“->"已安装更新"里面可以看到

clipboard[2]

clipboard[3]

解决方法很简单,需要重启数据库服务器来解决这个问题。