我们在 MVC3 项目中使用 Unity 作为 IoC 容器。我们刚刚安装了 dynatrace,它显示在 FileSystemWatcher.StartRaisingEvents 方法中花费的时间过多,特别是在 ReadDirectoryChangesW 中。这似乎导致了糟糕的表现。
为什么 Unity 会监控文件系统?
Here's the call stack:
ChildActionExtensions.RenderAction
HttpServerUtility.Execute
HttpHandlerUtil+ServerExecuteHttpHandler.Wrap
UnityControllerFactory.CreateController
XmlConfigurator.ConfigureAndWatch
FileSystemWatcher.StartRaisingEvents
UnsafeNativeMethods.ReadDirectoryChangesW
这是 UnityControllerFactoryCode
try
{
if (requestContext.RouteData.DataTokens.ContainsKey("area") && !string.IsNullOrWhiteSpace(requestContext.RouteData.DataTokens["area"].ToString()))
{
controllerName = string.Format("{0}/{1}", requestContext.RouteData.DataTokens["area"], controllerName);
}
controllerName = controllerName.ToLower();
return _container.Resolve<IController>(controllerName);
}
catch (Exception ex)
{
if (ex is ResolutionFailedException)
{
IMyLogger logger = _container.Resolve<IMyLogger>();
logger.Error(LogEventIdType.General, ex, "Is the '{0}' controller defined in the Unity Container via RegisterType (in lowercase) in UnityIocBootstrapConfigure?", new object[] {controllerName});
throw;
}
}
记录器记录到 Windows 事件日志。