public InterfaceConfigCallback(ICatalogCollection coll, Type t, Hashtable cache, RegistrationDriver driver) { _type = t; _coll = coll; _cache = cache; _driver = driver; // TODO: Populate w/ QueryByKey // TODO: Build cache for FindObject() _ifcs = GetInteropInterfaces(_type); // Check to see if one of the interfaces is IProcessInitializer foreach (Type ifc in _ifcs) { if (Marshal.GenerateGuidForType(ifc) == IID_IProcessInitializer) { DBG.Info(DBG.Registration, "Setting component " + cache["ComponentType"] + " up as process initializer"); try { ICatalogObject comp = cache["Component"] as ICatalogObject; ICatalogCollection compColl = cache["ComponentCollection"] as ICatalogCollection; comp.SetValue("InitializesServerApplication", 1); compColl.SaveChanges(); } catch (Exception e) { throw new RegistrationException(Resource.FormatString("Reg_FailPIT", _type), e); } } } RegistrationDriver.Populate(_coll); }
public InterfaceConfigCallback(ICatalogCollection coll, Type t, Hashtable cache, RegistrationDriver driver) { this._type = t; this._coll = coll; this._cache = cache; this._driver = driver; this._ifcs = this.GetInteropInterfaces(this._type); foreach (Type type in this._ifcs) { if (Marshal.GenerateGuidForType(type) == IID_IProcessInitializer) { try { ICatalogObject obj2 = cache["Component"] as ICatalogObject; ICatalogCollection catalogs = cache["ComponentCollection"] as ICatalogCollection; obj2.SetValue("InitializesServerApplication", 1); catalogs.SaveChanges(); } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } throw new RegistrationException(Resource.FormatString("Reg_FailPIT", this._type), exception); } } } RegistrationDriver.Populate(this._coll); }
public ComponentConfigCallback(ICatalogCollection coll, ApplicationSpec spec, Hashtable cache, RegistrationDriver driver, InstallationFlags installFlags) { this._spec = spec; this._coll = coll; this._cache = cache; this._driver = driver; this._installFlags = installFlags; RegistrationDriver.Populate(coll); }
public ComponentConfigCallback(ICatalogCollection coll, ApplicationSpec spec, Hashtable cache, RegistrationDriver driver, InstallationFlags installFlags) { _spec = spec; _coll = coll; _cache = cache; _driver = driver; _installFlags = installFlags; // TODO: Populate w/ QueryByKey // TODO: Cache for FindObject RegistrationDriver.Populate(coll); }
private static ICatalogObject FindComponent(ICatalogCollection coll, Guid clsid, ref int idx) { RegistrationDriver.Populate(coll); int num = coll.Count(); for (int i = 0; i < num; i++) { ICatalogObject obj2 = (ICatalogObject)coll.Item(i); Guid guid = new Guid((string)obj2.GetValue("CLSID")); if (guid == clsid) { idx = i; return(obj2); } } return(null); }
private static ICatalogObject FindComponent(ICatalogCollection coll, Guid clsid, ref int idx) { RegistrationDriver.Populate(coll); int count = coll.Count(); for (int i = 0; i < count; i++) { ICatalogObject obj = (ICatalogObject)(coll.Item(i)); Guid objid = new Guid((String)(obj.GetValue("CLSID"))); if (objid == clsid) { idx = i; return(obj); } } return(null); }
public MethodConfigCallback(ICatalogCollection coll, Type t, Type impl, Hashtable cache, RegistrationDriver driver) { this._type = t; this._impl = impl; this._coll = coll; this._cache = cache; this._driver = driver; if (this._type.IsInterface) { this._map = this._impl.GetInterfaceMap(this._type); } else { this._map.InterfaceMethods = null; this._map.InterfaceType = null; this._map.TargetMethods = null; this._map.TargetType = null; } RegistrationDriver.Populate(coll); }
public MethodConfigCallback(ICatalogCollection coll, Type t, Type impl, Hashtable cache, RegistrationDriver driver) { _type = t; // The "interface" we have methods for _impl = impl; // The implementation of the interface: _coll = coll; _cache = cache; _driver = driver; try { _map = _impl.GetInterfaceMap(_type); } catch (System.ArgumentException) { _map.InterfaceMethods = null; _map.InterfaceType = null; _map.TargetMethods = null; _map.TargetType = null; } RegistrationDriver.Populate(coll); }
internal static void UninstallUtilityApplication(Type t) { DBG.Info(DBG.Registration, "Starting utility uninstallation:"); try { if (Platform.IsLessThan(Platform.W2K)) { return; } ICatalog cat = null; ICatalogCollection apps = null; ICatalogObject app = null; int appidx = 0; cat = (ICatalog)(new xCatalog()); if (!Platform.IsLessThan(Platform.Whistler)) { // AS/URT 97116: Keep this from failing the install if // we're on a Beta2 Whistler machine, which has a different // GUID for ICatalog2. ICatalog2 cat2 = cat as ICatalog2; if (cat2 != null) { cat2.CurrentPartition(cat2.GlobalPartitionID()); } } apps = (ICatalogCollection)(cat.GetCollection("Applications")); RegistrationDriver.Populate(apps); app = FindApplication(apps, _appid, ref appidx); if (app != null) { // Make sure that we can change this puppy: app.SetValue("Changeable", true); app.SetValue("Deleteable", true); apps.SaveChanges(); DBG.Info(DBG.Registration, "Found application!"); int idx = 0, compcount = 0; Guid clsid = Marshal.GenerateGuidForType(typeof(RegistrationHelperTx)); ICatalogCollection comps = (ICatalogCollection)(apps.GetCollection("Components", app.Key())); ICatalogObject comp = FindComponent(comps, clsid, ref idx); // Store count here, if it is 1, we can delete the app later. compcount = comps.Count(); if (comp != null) { DBG.Info(DBG.Registration, "Found component at " + idx); comps.Remove(idx); comps.SaveChanges(); } if (comp != null && compcount == 1) { DBG.Info(DBG.Registration, "Removing .NET Utilities application."); // we removed the last component, kill the app apps.Remove(appidx); apps.SaveChanges(); } else { // Make sure that we can't change the app: app.SetValue("Changeable", false); app.SetValue("Deleteable", false); apps.SaveChanges(); } } } catch (Exception e) { // Log a failure in some acceptable manner. try { EventLog appLog = new EventLog(); appLog.Source = "System.EnterpriseServices"; String errMsg = String.Format(Resource.FormatString("Reg_ErrUninstSysEnt"), e); appLog.WriteEntry(errMsg, EventLogEntryType.Error); } catch {} // We threw an exception? What do we do here? //DBG.Assert(false, // "Installation of System.EnterpriseServices threw an exception!", // "Exception: " + e); DBG.Info(DBG.Registration, "Caught exception: " + e); } }
internal static void InstallUtilityApplication(Type t) { DBG.Info(DBG.Registration, "Starting utility installation:"); try { if (Platform.IsLessThan(Platform.W2K)) { return; } ICatalog cat = null; ICatalogCollection apps = null; ICatalogObject app = null; int junk = 0; cat = (ICatalog)(new xCatalog()); if (!Platform.IsLessThan(Platform.Whistler)) { // AS/URT 97116: Keep this from failing the install if // we're on a Beta2 Whistler machine, which has a different // GUID for ICatalog2. ICatalog2 cat2 = cat as ICatalog2; if (cat2 != null) { cat2.CurrentPartition(cat2.GlobalPartitionID()); } } apps = (ICatalogCollection)(cat.GetCollection("Applications")); RegistrationDriver.Populate(apps); app = FindApplication(apps, _appid, ref junk); if (app == null) { DBG.Info(DBG.Registration, "Didn't find existing application..."); app = (ICatalogObject)(apps.Add()); app.SetValue("Name", _appname); app.SetValue("Activation", ActivationOption.Library); app.SetValue("ID", "{" + _appid.ToString() + "}"); if (!Platform.IsLessThan(Platform.Whistler)) { // AS/URT 97116: Keep this from failing the install if // we're on a Beta2 Whistler machine, which has no Replicable property. try { app.SetValue("Replicable", 0); } catch (Exception) {} } apps.SaveChanges(); } else { // Make sure that we can change this puppy: app.SetValue("Changeable", true); app.SetValue("Deleteable", true); apps.SaveChanges(); app.SetValue("Name", _appname); if (!Platform.IsLessThan(Platform.Whistler)) { // AS/URT 97116: Keep this from failing the install if // we're on a Beta2 Whistler machine, which has no Replicable property. try { app.SetValue("Replicable", 0); } catch (Exception) {} } apps.SaveChanges(); } // Import ourselves into the application: Guid clsid = Marshal.GenerateGuidForType(typeof(RegistrationHelperTx)); ICatalogCollection comps = (ICatalogCollection)(apps.GetCollection("Components", app.Key())); ICatalogObject comp = FindComponent(comps, clsid, ref junk); if (comp == null) { cat.ImportComponent("{" + _appid + "}", "{" + clsid + "}"); comps = (ICatalogCollection)(apps.GetCollection("Components", app.Key())); comp = FindComponent(comps, clsid, ref junk); } DBG.Assert(comp != null, "Couldn't find imported component!"); ConfigureComponent(comps, comp); // And finally, lock this guy down: app.SetValue("Changeable", false); app.SetValue("Deleteable", false); apps.SaveChanges(); DBG.Info(DBG.Registration, "Registering Proxy/Stub dlls:"); Thunk.Proxy.RegisterProxyStub(); // HACK // This is a HACK to get Windows XP Client COM+ export/import functionallity to work. // Export code will try to export System.EnterpriseServices.Thunk.dll because its not in it's // list of non-redist dlls. // We should get rid of this once this name is in the harcoded list in the export code. RegistryPermission rp = new RegistryPermission(PermissionState.Unrestricted); rp.Demand(); rp.Assert(); RegistryKey rk = Registry.LocalMachine.CreateSubKey("SOFTWARE\\MICROSOFT\\OLE\\NONREDIST"); rk.SetValue("System.EnterpriseServices.Thunk.dll", ""); rk.Close(); // END HACK } catch (Exception e) { // Log a failure in some acceptable manner. try { EventLog appLog = new EventLog(); appLog.Source = "System.EnterpriseServices"; String errMsg = String.Format(Resource.FormatString("Reg_ErrInstSysEnt"), e); appLog.WriteEntry(errMsg, EventLogEntryType.Error); } catch {} // We threw an exception? What do we do here? //DBG.Assert(false, // "Installation of System.EnterpriseServices threw an exception!", // "Exception: " + e); } }