コード例 #1
0
        // Restore the typelibs/controls that were previously loaded
        public static void RestoreComEnvironment()
        {
            if (_typelibs.Count == 0)
            {
                return;
            }
            ProgressDialog progressDialog = new ProgressDialog();

            progressDialog.Setup("Loading Remembered ActiveX Files",
                                 "Please wait while I load the previously " +
                                 "opened ActiveX files.",
                                 _typelibs.Count,
                                 ProgressDialog.HAS_PROGRESS_TEXT,
                                 ProgressDialog.FINAL);
            progressDialog.ShowIfNotDone();
            TraceUtil.WriteLineInfo(null, DateTime.Now + " ActiveX Restore start ");
            try {
                for (int i = _typelibs.Count - 1; i >= 0; --i)
                {
                    PreviouslyOpenedTypeLibrary typeLib = _typelibs[i];
                    try {
                        TraceUtil.WriteLineInfo(null, DateTime.Now + " restore assy: " + typeLib.FileName);
                        progressDialog.UpdateProgressText(typeLib.FileName);
                        Guid guid = new Guid(typeLib.Guid);
                        TypeLibrary.RestoreTypeLib(typeLib.FileName, guid, typeLib.Version);
                        TraceUtil.WriteLineInfo(null, DateTime.Now + " loaded assy: " + typeLib.FileName);
                        progressDialog.UpdateProgress(1);
                    } catch (Exception ex) {
                        TraceUtil.WriteLineWarning(null,
                                                   "Assemblies - deleting bad assemblies entry: "
                                                   + typeLib.FileName + " " + ex);
                        _typelibs.Remove(typeLib);
                        progressDialog.UpdateProgress(1);
                    }
                }
                // This depends on having all of the assemblies restored
                TraceUtil.WriteLineInfo(null, DateTime.Now + " ActiveX Restore end ");
            } catch (Exception ex) {
                TraceUtil.WriteLineError(null, "Unexpected exception "
                                         + "restoring assemblies: " + ex);
            }
            progressDialog.Finished();
            if (ComponentInspectorProperties.AddRunningComObjects)
            {
                AddRunningObjs();
            }
            FavoriteTypeLibNode.Expand();
        }