public void UpdateHostObjectModel(object sender, EventArgs empty) { var plugin = PluginFactory.GetInstance(); if (plugin == null) { return; } var context = plugin.GetAssemblyContext(ActiveItem); if (context == null) { return; } var adef = context.AssemblyDefinition; var wrapper = HostAssemblies.FirstOrDefault(a => a.Location == adef.MainModule.Image.FileName); if (wrapper == null) { return; } try { // Ok we have everything, write the assembly to stream var stream = new MemoryStream(); adef.MainModule.Write(stream); stream.Position = 0; // Then hot-replace the assembly UpdatingHostObjectModel = true; HotReplaceAssembly(wrapper, stream); } catch (Exception) { ShowMessage(string.Format("Unable to stream assembly to {0}. In case of item deletion make sure you removed all existing references.", plugin.HostApplication)); } finally { UpdatingHostObjectModel = false; } }