private void ValidateCompensator(Type compensator) { DBG.Status(DBG.CRM, "Validating compensator: " + compensator); if (!compensator.IsSubclassOf(typeof(Compensator))) { // Throw an exception! throw new ArgumentException(Resource.FormatString("CRM_CompensatorDerive")); } // We've gotta make sure that this puppy's available for // COM clients: if (!(new RegistrationServices()).TypeRequiresRegistration(compensator)) { throw new ArgumentException(Resource.FormatString("CRM_CompensatorConstructor")); } DBG.Info(DBG.CRM, "Testing compensator instantiation:"); // Create an instance of it just in case: ServicedComponent inst = (ServicedComponent)Activator.CreateInstance(compensator); if (inst == null) { throw new ArgumentException(Resource.FormatString("CRM_CompensatorActivate")); } DBG.Info(DBG.CRM, "'" + compensator + "' instantiation succeeded"); // Make sure we forcibly get rid of the thing we just created immediately: // This has to happen in case it is pooled, otherwise we'll have to wait // for the GC to kick in. ServicedComponent.DisposeObject(inst); DBG.Info(DBG.CRM, "'" + compensator + "' is valid"); }
bool _ICompensator._AbortRecord(_LogRecord record) { DBG.Assert(_clerk != null, "Method call made on Compensator with no clerk!"); DBG.Info(DBG.CRM, "Compensator: abort-record"); LogRecord R = new LogRecord(record); return(AbortRecord(R)); }
/// <include file='doc\CRM.uex' path='docs/doc[@for="Clerk.WriteLogRecord"]/*' /> public void WriteLogRecord(Object record) { // Serialize the current log record, the write it to the // actual object. DBG.Info(DBG.CRM, "Clerk.WriteLogRecord: Serializing log record"); byte[] buf = Packager.Serialize(record); DBG.Info(DBG.CRM, "Clerk.WriteLogRecord: Writing log record: size = " + buf.Length); _control.WriteLogRecord(buf); DBG.Info(DBG.CRM, "Clerk.WriteLogRecord: Done"); }
public void ReceiveCallback() { DBG.Info(DBG.Pool, "AppDomainHelper.CallbackWrapper: delivering CB."); int hr = Thunk.Proxy.CallFunction(_pfnCB, _pv); if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } DBG.Info(DBG.Pool, "AppDomainHelper.CallbackWrapper: done."); }
private void Init(String compensator, String description, CompensatorOptions flags) { // Create the logcontrol object: DBG.Info(DBG.CRM, "Creating the log-control object"); _control = new CrmLogControl(); DBG.Info(DBG.CRM, "Registering the compensator '" + compensator + "' w/ the control."); _control.RegisterCompensator(compensator, description, (int)flags); DBG.Info(DBG.CRM, "Getting monitor from log-control object"); _monitor = _control.GetMonitor(); }
// callback for shutdown delegate: private void OnDomainUnload(Object sender, EventArgs e) { DBG.Assert(AppDomain.CurrentDomain == _ad, "Call to AppDomainHelper.OnDomainUnload for wrong AD"); // Our domain is being unloaded, it's time to call the // unmanaged world back... if (_pfnShutdownCB != IntPtr.Zero) { DBG.Info(DBG.Pool, "AppDomainHelper.OnDomainUnload: delivering callback."); Thunk.Proxy.CallFunction(_pfnShutdownCB, _punkPool); _pfnShutdownCB = IntPtr.Zero; Marshal.Release(_punkPool); _punkPool = IntPtr.Zero; DBG.Info(DBG.Pool, "OnDomainUnload: done."); } }
/// <include file='doc\ImportUtil.uex' path='docs/doc[@for="ComManagedImportUtil.InstallAssembly"]/*' /> public void InstallAssembly(string asmpath, string parname, string appname) { try { DBG.Info(DBG.Registration, "Attempting install of " + asmpath + " to app " + appname + " in partition " + parname); String tlb = null; InstallationFlags flags = InstallationFlags.Default; RegistrationHelper h = new RegistrationHelper(); h.InstallAssembly(asmpath, ref appname, parname, ref tlb, flags); } catch (Exception e) { EventLog.WriteEntry(Resource.FormatString("Reg_InstallTitle"), Resource.FormatString("Reg_FailInstall", asmpath, appname) + "\n\n" + e.ToString(), EventLogEntryType.Error); throw; } }
/// <include file='doc\ExportUtil.uex' path='docs/doc[@for="AppDomainHelper.IAppDomainHelper.DoCallback"]/*' /> void IAppDomainHelper.DoCallback(IntPtr pUnkAD, IntPtr pfnCallbackCB, IntPtr data) { #if _DEBUG AppDomain ad = (AppDomain)Marshal.GetObjectForIUnknown(pUnkAD); DBG.Assert(ad == _ad, "Call to AppDomainHelper.DoCallback for wrong AD"); #endif // DoCallback: CallbackWrapper wrap = new CallbackWrapper(pfnCallbackCB, data); if (_ad != AppDomain.CurrentDomain) { DBG.Info(DBG.Pool, "AppDomainHelper.DoCallback: the current domain differs from the passed domain."); _ad.DoCallBack(new CrossAppDomainDelegate(wrap.ReceiveCallback)); DBG.Info(DBG.Pool, "AppDomainHelper.DoCallback: done with callback."); } else { DBG.Info(DBG.Pool, "AppDomainHelper.DoCallback: the current domain matches."); wrap.ReceiveCallback(); } }
/// <include file='doc\CRM.uex' path='docs/doc[@for="Compensator.Compensator"]/*' /> public Compensator() { DBG.Info(DBG.CRM, "Compensator: created"); _clerk = null; }
void _ICompensator._SetLogControl(IntPtr logControl) { DBG.Info(DBG.CRM, "Compensator: Setting new clerk:"); _clerk = new Clerk(new CrmLogControl(logControl)); }
/// <include file='doc\ExportUtil.uex' path='docs/doc[@for="AssemblyLocator.IAssemblyLocator.GetModules"]/*' /> String[] IAssemblyLocator.GetModules(String appdir, String appName, String name) { DBG.Info(DBG.Registration, "Finding modules for \"" + name + "\" at \"" + appdir + "\" in \"" + appName + "\""); if (appdir != null && appdir.Length > 0) { AssemblyLocator loc = null; try { // Spawn off an app-domain with the given directory as // the root search path: AppDomainSetup domainOptions = new AppDomainSetup(); domainOptions.ApplicationBase = appdir; AppDomain domain = AppDomain.CreateDomain(appName, null, domainOptions); if (domain != null) { AssemblyName n = typeof(AssemblyLocator).Assembly.GetName(); ObjectHandle h = domain.CreateInstance(n.FullName, typeof(AssemblyLocator).FullName); if (h != null) { loc = (AssemblyLocator)h.Unwrap(); } } } catch (Exception e) { DBG.Info(DBG.Registration, "Exception: " + e); return(null); } return(((IAssemblyLocator)loc).GetModules(null, null, name)); } // Otherwise, Just load the assembly and be done with it: try { Assembly asm = Assembly.Load(name); if (asm == null) { // TODO: error? DBG.Info(DBG.Registration, "Couldn't load assembly!"); } Module[] modules = asm.GetModules(); String[] names = new String[modules.Length]; for (int i = 0; i < modules.Length; i++) { names[i] = modules[i].FullyQualifiedName; } return(names); } catch (Exception e) { DBG.Info(DBG.Registration, "Exception loading assembly: " + e); throw e; } }