security.config.cch文件对CLR做了什么?

时间:2009-02-10 19:35:52

标签: c# .net clr

我在机器上的VS2008,SP1下进行调试时遇到了令人讨厌的锁定问题。我正在运行ProcMon.exe来尝试确定发生了什么。我看到的一件事是100s或1000s的重复读取+写入一个名为security.config.cch和security.config.cch.new的文件。

这些文件是什么?为什么我的应用程序需要重复读取+写入此文件?

谢谢, 戴夫

示例:

2:18:14.1421944 PM  App.vshost.exe  1152    ReadFile    C:\Documents and Settings\myuser\Application Data\Microsoft\CLR Security Config\v2.0.50727.42\security.config.cch   SUCCESS Offset: 170,397, Length: 208
2:18:14.1422854 PM  App.vshost.exe  1152    ReadFile    C:\Documents and Settings\myuser\Application Data\Microsoft\CLR Security Config\v2.0.50727.42\security.config.cch   SUCCESS Offset: 170,605, Length: 224
2:18:14.1423824 PM  App.vshost.exe  1152    WriteFile   C:\Documents and Settings\myuser\Application Data\Microsoft\CLR Security Config\v2.0.50727.42\security.config.cch.new   SUCCESS Offset: 206,817, Length: 208
2:18:14.1424843 PM  App.vshost.exe  1152    WriteFile   C:\Documents and Settings\myuser\Application Data\Microsoft\CLR Security Config\v2.0.50727.42\security.config.cch.new   SUCCESS Offset: 207,025, Length: 224
2:18:14.1425788 PM  App.vshost.exe  1152    WriteFile   C:\Documents and Settings\myuser\Application Data\Microsoft\CLR Security Config\v2.0.50727.42\security.config.cch.new   SUCCESS Offset: 207,249, Length: 12
2:18:14.1426746 PM  App.vshost.exe  1152    ReadFile    C:\Documents and Settings\myuser\Application Data\Microsoft\CLR Security Config\v2.0.50727.42\security.config.cch   SUCCESS Offset: 170,841, Length: 220
2:18:14.1427679 PM  App.vshost.exe  1152    ReadFile    C:\Documents and Settings\myuser\Application Data\Microsoft\CLR Security Config\v2.0.50727.42\security.config.cch   SUCCESS Offset: 171,061, Length: 224

1 个答案:

答案 0 :(得分:7)

security.config.cch个文件及其变体(security.config.cch.newsecurity.config.cch.[random numbers]等)是安全解析缓存文件

这些文件本质上是应用程序代码的CAS (Code Access Security)要求的缓存。它们允许CLR的内置安全系统更快地解决代码的安全需求。

您可以安全地删除这些文件,这将导致您的应用程序下次初始性能略微降低,但CLR安全子系统最终会重新生成这些文件。

此过程可能会出现一个已知问题,"FIX: Error message when you try to run a Web application that was built by using the .NET Framework 2.0: "Overwhelming changes have occurred"但是,这适用于.NET Framework 2.0,可能会也可能不会适用于.NET Framework 3.5 SP1(您正在使用VS2008) SP1)。

对这些文件进行大量读/写是完全正常的,但是,如果读/写看起来过多而且您遇到锁定,我会考虑查看您的代码(假设您拨打demand specific security actions或同等数量的电话,或检查Runtime Security Policy中设置的.NET Framework Configuration Tool (Mscorcfg.msc)的配置。