We are using Unity as our IoC container in an MVC3 project. We just installed dynatrace, and it is showing an inordinate amount of time spent in a FileSystemWatcher.StartRaisingEvents method, specifically in ReadDirectoryChangesW. This seems to be contributing to bad performance.
Why on earth would Unity be monitoring the file system?
Here's the call stack:
ChildActionExtensions.RenderAction
HttpServerUtility.Execute
HttpHandlerUtil+ServerExecuteHttpHandler.Wrap
UnityControllerFactory.CreateController
XmlConfigurator.ConfigureAndWatch
FileSystemWatcher.StartRaisingEvents
UnsafeNativeMethods.ReadDirectoryChangesW
Here is the 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;
}
}
The logger logs to the Windows event log.
Your trace is pointing to
XmlConfigurator, which is log4net. log4net stores its configuration in a separate file from the web.config, so it starts a File System Watcher to check if the file has changed to reconfigure itself.It would seem that the culprit of your performance problems then is log4net, not Unity.