static private DnaLibraryAutoOpen ( ) : void | ||
Результат | void |
internal static short XlAutoOpen() { Debug.Print("AppDomain Id: " + AppDomain.CurrentDomain.Id + " (Default: " + AppDomain.CurrentDomain.IsDefaultAppDomain() + ")"); short result = 0; try { Debug.WriteLine("In XlAddIn.XlAutoOpen"); DeInitializeIntegration(); object xlCallResult; XlCallImpl.TryExcelImpl(XlCallImpl.xlcMessage, out xlCallResult /*Ignore*/, true, "Registering library " + pathXll); InitializeIntegration(); // InitializeIntegration has loaded the DnaLibrary IntegrationHelpers.DnaLibraryAutoOpen(); result = 1; // All is OK } catch (Exception e) { // TODO: What to do here? Debug.WriteLine(e.Message); result = 0; } finally { // Clear the status bar message object xlCallResult; XlCallImpl.TryExcelImpl(XlCallImpl.xlcMessage, out xlCallResult /*Ignore*/, false); } return(result); }
internal static short XlAutoOpen() { Debug.Print("AppDomain Id: " + AppDomain.CurrentDomain.Id + " (Default: " + AppDomain.CurrentDomain.IsDefaultAppDomain() + ")"); short result = 0; try { Debug.WriteLine("In XlAddIn.XlAutoOpen"); if (_opened) { DeInitializeIntegration(); } object xlCallResult; XlCallImpl.TryExcelImpl(XlCallImpl.xlcMessage, out xlCallResult /*Ignore*/, true, "Registering library " + pathXll); InitializeIntegration(); // v. 30 - moved the setting of _opened before calling AutoOpen, // so that checking in DeInitializeIntegration does not prevent AutoOpen - unloading via xlAutoRemove from working. _opened = true; // InitializeIntegration has loaded the DnaLibrary IntegrationHelpers.DnaLibraryAutoOpen(); result = 1; // All is OK } catch (Exception e) { // TODO: What to do here - maybe prefer Trace...? // START HERE: Better error display (with Exception info?) Debug.WriteLine("ExcelDna.Loader.XlAddin.XlAutoOpen. Exception during Integration load: " + e.ToString()); string alertMessage = string.Format("A problem occurred while an add-in was being initialized (InitializeIntegration failed - {1}).\r\nThe add-in is built with ExcelDna and is being loaded from {0}", pathXll, e.Message); object xlCallResult; XlCallImpl.TryExcelImpl(XlCallImpl.xlcAlert, out xlCallResult /*Ignored*/, alertMessage, 3 /* Only OK Button, Warning Icon*/); result = 0; } finally { // Clear the status bar message object xlCallResult; XlCallImpl.TryExcelImpl(XlCallImpl.xlcMessage, out xlCallResult /*Ignored*/, false); Debug.Print("Clear status bar message result: " + xlCallResult); } return(result); }