void CheckHostAssembly(Assembly asm) { if (AddinDatabase.RunningSetupProcess || asm is System.Reflection.Emit.AssemblyBuilder || asm.IsDynamic) { return; } string codeBase; try { codeBase = asm.CodeBase; } catch { return; } Uri u; if (!Uri.TryCreate(codeBase, UriKind.Absolute, out u)) { return; } string asmFile = u.LocalPath; Addin ainfo; try { ainfo = Registry.GetAddinForHostAssembly(asmFile); } catch (Exception ex) { // GetAddinForHostAssembly may crash if the add-in db has been corrupted. In this case, update the db // and try getting the add-in info again. If it crashes again, then this is a bug. defaultProgressStatus.ReportError("Add-in description could not be loaded.", ex); Registry.Update(null); ainfo = Registry.GetAddinForHostAssembly(asmFile); } if (ainfo != null && !IsAddinLoaded(ainfo.Id)) { AddinDescription adesc = null; try { adesc = ainfo.Description; } catch (Exception ex) { defaultProgressStatus.ReportError("Add-in description could not be loaded.", ex); } if (adesc == null || adesc.FilesChanged()) { // If the add-in has changed, update the add-in database. // We do it here because once loaded, add-in roots can't be // reloaded like regular add-ins. Registry.Update(null); ainfo = Registry.GetAddinForHostAssembly(asmFile); if (ainfo == null) { return; } } LoadAddin(null, ainfo.Id, false); } }