void UnregisterWithXmlProvider(Workbook wb) { var path = wb.FullName; var xmlPath = GetXmlPath(path); _xmlProvider.UnregisterXmlFunctionInfo(path); _xmlProvider.UnregisterXmlFunctionInfo(xmlPath); }
// Runs on the main thread, but not in a macro context // WARNING: The sequence of calls here, between queued // instances of ProcessLoadNotification, Refresh and OnInvalidate // is quite fragile. void ProcessLoadNotification(object state) { var notification = (LoaderNotification.NotificationEventArgs)state; var xllPath = notification.FullDllName; Logger.Provider.Verbose(string.Format("ExcelDnaIntelliSenseProvider.ProcessLoadNotification {0}, {1}", notification, xllPath)); lock (_xllRegistrationInfos) { Logger.Provider.Verbose("ExcelDnaIntelliSenseProvider.ProcessLoadNotification - inside lock"); XllRegistrationInfo regInfo; if (!_xllRegistrationInfos.TryGetValue(xllPath, out regInfo)) { if (notification.Reason == LoaderNotification.Reason.Loaded) { regInfo = new XllRegistrationInfo(xllPath); _xllRegistrationInfos[xllPath] = regInfo; //regInfo.Refresh(); // Rather not.... so that we don't even try during the AddIns enumeration... OnInvalidate will lead to Refresh() _xmlProvider.RegisterXmlFunctionInfo(GetXmlPath(xllPath)); if (!_isDirty) { _isDirty = true; // This call would case trouble while Excel is shutting down. // CONSIDER: Is there a check we might do.... (and do we in fact get .xll loads during shutdown?) _syncContextExcel.Post(OnInvalidate, null); } } } else if (notification.Reason == LoaderNotification.Reason.Unloaded) { _xllRegistrationInfos.Remove(xllPath); _xmlProvider.UnregisterXmlFunctionInfo(GetXmlPath(xllPath)); // Not too eager when cleaning up // OnInvalidate(); } } Logger.Provider.Verbose("ExcelDnaIntelliSenseProvider.ProcessLoadNotification - after lock"); }