public void Process(ActivationContext c) { if (c.HasTargets == false) { var p = new CostRuleParameters(c.Card, c.MaxX.Value.GetValueOrDefault()); c.X = CalculateX(p); if (c.X > c.MaxX.Value) { c.CancelActivation = true; } return; } var targetsCombinations = c.TargetsCombinations().ToList(); foreach (var targetsCombination in targetsCombinations) { var p = new CostRuleParameters(c.Card, c.MaxX.Value.GetValueOrDefault(), targetsCombination.Targets); targetsCombination.X = CalculateX(p); if (targetsCombination.X > c.MaxX.Value) { c.RemoveTargetCombination(targetsCombination); } } if (c.HasTargets == false) c.CancelActivation = true; }
public ActivationArguments (ActivationContext activationData) { if (activationData == null) throw new ArgumentNullException ("activationData"); _context = activationData; _identity = activationData.Identity; }
public static bool DetermineApplicationTrust (ActivationContext activationContext, TrustManagerContext context) { // FIXME: a null activationContext throw a NullReferenceException but calling directly the ApplicationTrustManager.DetermineApplicationTrust doesn't if (activationContext == null) throw new NullReferenceException ("activationContext"); // throw new ArgumentNullException ("activationContext"); ApplicationTrust at = ApplicationTrustManager.DetermineApplicationTrust (activationContext, context); return at.IsApplicationTrustedToRun; }
public ActivationArguments (ActivationContext activationContext, string[] activationData) { if (activationContext == null) throw new ArgumentNullException ("activationContext"); _context = activationContext; _identity = activationContext.Identity; _data = activationData; }
public ActivationArguments (ActivationContext activationContext, string[] activationData) { if (activationContext == null) throw new ArgumentNullException("activationContext"); Contract.EndContractBlock(); m_appFullName = activationContext.Identity.FullName; m_appManifestPaths = activationContext.ManifestPaths; m_activationData = activationData; m_useFusionActivationContext = true; }
public override bool Process(int pass, ActivationContext c) { if (pass == 2) { Process(c); return true; } return false; }
public virtual ObjectHandle CreateInstance (ActivationContext activationContext, string[] activationCustomData) { if (activationContext == null) throw new ArgumentNullException ("activationContext"); // TODO : compare activationContext with the one from this domain // and use it if it match // TODO : we must pass the activationCustomData in the AppDomainSetup // even if the activationCustomData don't match ??? AppDomainSetup setup = new AppDomainSetup (activationContext); return CreateInstanceHelper (setup); }
public void Fields() { var value = new ActivationContext(); Assert.AreEqual(0, value.cbSize); Assert.AreEqual((uint)0, value.dwFlags); Assert.AreEqual(0, value.wProcessorArchitecture); Assert.AreEqual((short)0, value.wLangId); Assert.IsNull(value.lpSource); Assert.IsNull(value.lpAssemblyDirectory); Assert.IsNull(value.lpResourceName); Assert.IsNull(value.lpApplicationName); Assert.AreEqual(IntPtr.Zero, value.hModule); }
internal ManifestRunner (AppDomain domain, ActivationContext activationContext) { m_domain = domain; string file, parameters; CmsUtils.GetEntryPoint(activationContext, out file, out parameters); if (parameters == null || parameters.Length == 0) m_args = new string[0]; else m_args = parameters.Split(' '); m_apt = ApartmentState.Unknown; // get the 'merged' application directory path. string directoryName = activationContext.ApplicationDirectory; m_path = Path.Combine(directoryName, file); }
internal ManifestRunner (AppDomain domain, ActivationContext activationContext) { m_domain = domain; string file, parameters; CmsUtils.GetEntryPoint(activationContext, out file, out parameters); if (String.IsNullOrEmpty(file)) throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); if (String.IsNullOrEmpty(parameters)) m_args = new string[0]; else m_args = parameters.Split(' '); m_apt = ApartmentState.Unknown; // get the 'merged' application directory path. string directoryName = activationContext.ApplicationDirectory; m_path = Path.Combine(directoryName, file); }
public static bool DetermineApplicationTrust (ActivationContext activationContext, TrustManagerContext context) { if (activationContext == null) throw new ArgumentNullException("activationContext"); ApplicationTrust appTrust = null; AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager; if (domainManager != null) { HostSecurityManager securityManager = domainManager.HostSecurityManager; if ((securityManager != null) && ((securityManager.Flags & HostSecurityManagerOptions.HostDetermineApplicationTrust) == HostSecurityManagerOptions.HostDetermineApplicationTrust)) { appTrust = securityManager.DetermineApplicationTrust(CmsUtils.MergeApplicationEvidence(null, activationContext.Identity, activationContext, null), null, context); if (appTrust == null) return false; return appTrust.IsApplicationTrustedToRun; } } appTrust = DetermineApplicationTrustInternal(activationContext, context); if (appTrust == null) return false; return appTrust.IsApplicationTrustedToRun; }
/// <summary> /// Initializes a new instance of the WebKitBrowser control. /// </summary> public WebKitBrowser() { InitializeComponent(); if (LicenseManager.UsageMode != LicenseUsageMode.Designtime) { // Control Events this.Load += new EventHandler(WebKitBrowser_Load); this.Resize += new EventHandler(WebKitBrowser_Resize); // If this is the first time the library has been loaded, // initialize the activation context required to load the // WebKit COM component registration free if ((actCtxRefCount++) == 0) { activationContext = new ActivationContext("WebKitBrowser.dll.manifest"); activationContext.Initialize(); // TODO: more error handling here // Enable OLE for drag and drop functionality - WebKit // will throw an OutOfMemory exception if we don't... Application.OleRequired(); } // If this control is brought to focus, focus our webkit child window this.GotFocus += (s, e) => { W32API.SetFocus(webViewHWND); }; activationContext.Activate(); webView = new WebViewClass(); activationContext.Deactivate(); } }
public ActivationArguments(ActivationContext activationContext, string[] activationData) { Contract.Requires(activationContext.Identity != null); }
public static byte[] GetApplicationManifestBytes(ActivationContext appInfo) { throw new NotImplementedException(); }
/// <summary>Gets a value indicating whether this is the first time this <see cref="T:System.ActivationContext" /> object has been run.</summary> /// <param name="appInfo">The object to examine.</param> /// <returns> /// <see langword="true" /> if the <see cref="T:System.ActivationContext" /> indicates it is running for the first time; otherwise, <see langword="false" />.</returns> // Token: 0x06004DFA RID: 19962 RVA: 0x001178F8 File Offset: 0x00115AF8 public static bool IsFirstRun(ActivationContext appInfo) { return(appInfo.LastApplicationStateResult == ActivationContext.ApplicationStateDisposition.RunningFirstTime); }
/// <summary>Creates an instance of the application to be activated, using the specified activation context. </summary><returns>An <see cref="T:System.Runtime.Remoting.ObjectHandle" /> that is a wrapper for the return value of the application execution. The return value must be unwrapped to access the real object. </returns><param name="activationContext">An <see cref="T:System.ActivationContext" /> that identifies the application to activate.</param><exception cref="T:System.ArgumentNullException"><paramref name="activationContext" /> is null. </exception> public virtual ObjectHandle CreateInstance(ActivationContext activationContext) { throw new NotImplementedException(); }
public static System.Security.Policy.ApplicationTrust RequestTrust(SubscriptionState subState, bool isShellVisible, bool isUpdate, ActivationContext actCtx) { return(ApplicationTrust.RequestTrust(subState, isShellVisible, isUpdate, actCtx, new TrustManagerContext() { IgnorePersistedDecision = false, NoPrompt = false, Persist = true })); }
public static object GetDeploymentComponentManifest(ActivationContext appInfo) { return(appInfo.DeploymentComponentManifest); }
public override void Activate(ActivationContext <T> context) { _condition(context.Fact, () => base.Activate(context)); }
public static void PrepareForExecution(ActivationContext appInfo) { Contract.Requires(appInfo != null); }
public static bool DetermineApplicationTrust(ActivationContext activationContext, TrustManagerContext context) { return(default(bool)); }
public ActivationArguments(ActivationContext activationData) : this(activationData, null) { }
private List<Playable> GeneratePlayables(ActivationPrerequisites prerequisites, Func<Playable> createPlayable) { var context = new ActivationContext(_player, prerequisites); var result = new List<Playable>(); var work = prerequisites.Rules.ToList(); var pass = 1; while (work.Count > 0) { var newWork = new List<MachinePlayRule>(); foreach (var rule in work) { var isFinished = rule.Process(pass, context); if (context.CancelActivation) { return result; } if (!isFinished) { newWork.Add(rule); } } pass++; work = newWork; } if (context.HasTargets == false) { var playable = createPlayable(); playable.Card = prerequisites.Card; playable.Index = prerequisites.Index; playable.ActivationParameters.X = context.X; playable.ActivationParameters.Repeat = context.Repeat; result.Add(playable); return result; } foreach (var targetsCombination in context.TargetsCombinations().Take(Ai.CurrentTargetCount)) { var playable = createPlayable(); playable.Card = prerequisites.Card; playable.Index = prerequisites.Index; playable.ActivationParameters.Targets = targetsCombination.Targets; playable.ActivationParameters.X = targetsCombination.X; playable.ActivationParameters.Repeat = targetsCombination.Repeat; result.Add(playable); } return result; }
public static System.Security.Policy.ApplicationTrust PersistTrustWithoutEvaluation(ActivationContext actCtx) { ApplicationSecurityInfo applicationSecurityInfo = new ApplicationSecurityInfo(actCtx); System.Security.Policy.ApplicationTrust trust = new System.Security.Policy.ApplicationTrust(actCtx.Identity); trust.IsApplicationTrustedToRun = true; trust.DefaultGrantSet = new PolicyStatement(applicationSecurityInfo.DefaultRequestSet, PolicyStatementAttribute.Nothing); trust.Persist = true; trust.ApplicationIdentity = actCtx.Identity; ApplicationSecurityManager.UserApplicationTrusts.Add(trust); return(trust); }
public static System.Security.Policy.ApplicationTrust RequestTrust(SubscriptionState subState, bool isShellVisible, bool isUpdate, ActivationContext actCtx, TrustManagerContext tmc) { Logger.AddMethodCall("ApplicationTrust.RequestTrust(isShellVisible=" + isShellVisible.ToString() + ", isUpdate=" + isUpdate.ToString() + ", subState.IsInstalled=" + subState.IsInstalled.ToString() + ") called."); if (!subState.IsInstalled || subState.IsShellVisible != isShellVisible) { tmc.IgnorePersistedDecision = true; } if (isUpdate) { tmc.PreviousApplicationIdentity = subState.CurrentBind.ToApplicationIdentity(); } bool applicationTrust1; try { Logger.AddInternalState("Calling ApplicationSecurityManager.DetermineApplicationTrust()."); Logger.AddInternalState("Trust Manager Context=" + Logger.Serialize(tmc)); applicationTrust1 = ApplicationSecurityManager.DetermineApplicationTrust(actCtx, tmc); } catch (TypeLoadException ex) { throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidTrustInfo"), (Exception)ex); } if (!applicationTrust1) { throw new TrustNotGrantedException(Resources.GetString("Ex_NoTrust")); } Logger.AddInternalState("Trust granted."); System.Security.Policy.ApplicationTrust applicationTrust2 = (System.Security.Policy.ApplicationTrust)null; for (int index = 0; index < 5; ++index) { applicationTrust2 = ApplicationSecurityManager.UserApplicationTrusts[actCtx.Identity.FullName]; if (applicationTrust2 == null) { Thread.Sleep(10); } else { break; } } if (applicationTrust2 == null) { throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidMatchTrust")); } return(applicationTrust2); }
public virtual ObjectHandle CreateInstance (ActivationContext activationContext) { return CreateInstance(activationContext, null); }
public static object GetActivationContextData(ActivationContext appInfo) { return(appInfo.ActivationContextData); }
public ActivationArguments (ActivationContext activationData) : this (activationData, null) {}
private void GetInterfacesInternal(NtToken token) { IntPtr punk = IntPtr.Zero; IntPtr pfactory = IntPtr.Zero; Guid IID_IUnknown = COMInterfaceEntry.IID_IUnknown; CLSCTX clsctx = _clsctx; if (token != null) { clsctx |= CLSCTX.ENABLE_CLOAKING; } using (var imp = token?.Impersonate()) { int hr = 0; if (_winrt_component) { hr = COMUtilities.RoGetActivationFactory(_activatable_classid, ref IID_IUnknown, out pfactory); } else { hr = COMUtilities.CoGetClassObject(ref _clsid, clsctx, null, ref IID_IUnknown, out pfactory); } // If we can't get class object, no chance we'll get object. if (hr != 0) { throw new Win32Exception(hr); } if (_winrt_component) { hr = COMUtilities.RoActivateInstance(_activatable_classid, out punk); } else { hr = COMUtilities.CoCreateInstance(ref _clsid, IntPtr.Zero, clsctx, ref IID_IUnknown, out punk); } if (hr != 0) { punk = IntPtr.Zero; } try { Dictionary <IntPtr, string> module_names = new Dictionary <IntPtr, string>(); QueryInterface(punk, COMInterfaceEntry.IID_IMarshal, module_names, _interfaces); QueryInterface(pfactory, COMInterfaceEntry.IID_IMarshal, module_names, _factory_interfaces); QueryInterface(punk, COMInterfaceEntry.IID_IPSFactoryBuffer, module_names, _interfaces); QueryInterface(pfactory, COMInterfaceEntry.IID_IPSFactoryBuffer, module_names, _factory_interfaces); var actctx = ActivationContext.FromProcess(); if (actctx != null) { foreach (var intf in actctx.ComInterfaces) { QueryInterface(punk, intf.Iid, module_names, _interfaces); QueryInterface(pfactory, intf.Iid, module_names, _factory_interfaces); } } using (RegistryKey interface_key = Registry.ClassesRoot.OpenSubKey("Interface")) { foreach (string iid_string in interface_key.GetSubKeyNames()) { if (Guid.TryParse(iid_string, out Guid iid)) { QueryInterface(punk, iid, module_names, _interfaces); QueryInterface(pfactory, iid, module_names, _factory_interfaces); } } } QueryInspectableInterfaces(punk, module_names, _interfaces); QueryInspectableInterfaces(pfactory, module_names, _factory_interfaces); } finally { if (pfactory != IntPtr.Zero) { Marshal.Release(pfactory); } if (punk != IntPtr.Zero) { Marshal.Release(punk); } } } }
public virtual ApplicationTrust DetermineApplicationTrust(Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context) { if (applicationEvidence == null) { throw new ArgumentNullException("applicationEvidence"); } Contract.EndContractBlock(); // This method looks for a trust decision for the ActivationContext in three locations, in order // of preference: // // 1. Supplied by the host in the AppDomainSetup. If the host supplied a decision this way, it // will be in the applicationEvidence. // 2. Reuse the ApplicationTrust from the current AppDomain // 3. Ask the TrustManager for a trust decision // get the activation context from the application evidence. // The default HostSecurityManager does not examine the activatorEvidence // but other security managers could use it to figure out the // evidence of the domain attempting to activate the application. ActivationArguments activationArgs = applicationEvidence.GetHostEvidence <ActivationArguments>(); if (activationArgs == null) { throw new ArgumentException(Environment.GetResourceString("Policy_MissingActivationContextInAppEvidence")); } ActivationContext actCtx = activationArgs.ActivationContext; if (actCtx == null) { throw new ArgumentException(Environment.GetResourceString("Policy_MissingActivationContextInAppEvidence")); } // Make sure that any ApplicationTrust we find applies to the ActivationContext we're // creating the new AppDomain for. ApplicationTrust appTrust = applicationEvidence.GetHostEvidence <ApplicationTrust>(); if (appTrust != null && !CmsUtils.CompareIdentities(appTrust.ApplicationIdentity, activationArgs.ApplicationIdentity, ApplicationVersionMatch.MatchExactVersion)) { appTrust = null; } // If there was not a trust decision supplied in the Evidence, we can reuse the existing trust // decision from this domain if its identity matches the ActivationContext of the new domain. // Otherwise consult the TrustManager for a trust decision if (appTrust == null) { if (AppDomain.CurrentDomain.ApplicationTrust != null && CmsUtils.CompareIdentities(AppDomain.CurrentDomain.ApplicationTrust.ApplicationIdentity, activationArgs.ApplicationIdentity, ApplicationVersionMatch.MatchExactVersion)) { appTrust = AppDomain.CurrentDomain.ApplicationTrust; } else { appTrust = ApplicationSecurityManager.DetermineApplicationTrustInternal(actCtx, context); } } // If the trust decision allows the application to run, then it should also have a permission set // which is at least the permission set the application requested. ApplicationSecurityInfo appRequest = new ApplicationSecurityInfo(actCtx); if (appTrust != null && appTrust.IsApplicationTrustedToRun && !appRequest.DefaultRequestSet.IsSubsetOf(appTrust.DefaultGrantSet.PermissionSet)) { throw new InvalidOperationException(Environment.GetResourceString("Policy_AppTrustMustGrantAppRequest")); } return(appTrust); }
public ApplicationTrust DetermineApplicationTrust (ActivationContext activationContext, TrustManagerContext context) { if (activationContext == null) throw new ArgumentNullException ("activationContext"); return null; }
public static object GetApplicationComponentManifest(ActivationContext appInfo) { return(appInfo.ApplicationComponentManifest); }
public static System.Runtime.Remoting.ObjectHandle CreateInstance(ActivationContext activationContext) { }
/// <summary>Informs an <see cref="T:System.ActivationContext" /> to get ready to be run.</summary> /// <param name="appInfo">The object to inform.</param> // Token: 0x06004DF9 RID: 19961 RVA: 0x001178F0 File Offset: 0x00115AF0 public static void PrepareForExecution(ActivationContext appInfo) { appInfo.PrepareForExecution(); }
public static System.Runtime.Remoting.ObjectHandle CreateInstance(ActivationContext activationContext, string[] activationCustomData) { }
/// <summary> /// Verify and gather information about the signatures of the specified manifests /// </summary> public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application) { return(VerifySignature(application, ManifestKinds.ApplicationAndDeployment)); }
// Getters can be used with conditional code. public void Good3(ActivationContext context) { ConditionalCall(context.Form); }
public virtual ObjectHandle CreateInstance(ActivationContext activationContext, string[] activationCustomData) { throw new NotImplementedException(); }
public AppDomainSetup(ActivationContext activationContext) {}
public static object GetActivationContextData(ActivationContext appInfo) { throw new NotImplementedException(); }
/// <summary> /// Initializes the specified host. /// </summary> /// <param name="host">The host.</param> public void Initialize(IWebKitBrowserHost host) { if(host == null) throw new ArgumentNullException("host"); this.host = host; if(!host.InDesignMode) { // Control Events this.host.Load += new EventHandler(WebKitBrowser_Load); this.host.Resize += new EventHandler(WebKitBrowser_Resize); // If this is the first time the library has been loaded, // initialize the activation context required to load the // WebKit COM component registration free if((actCtxRefCount++) == 0) { FileInfo fi = new FileInfo(Assembly.GetExecutingAssembly().Location); activationContext = new ActivationContext(Path.Combine(fi.DirectoryName, "WebKitBrowser.dll.manifest")); activationContext.Initialize(); // TODO: more error handling here // Enable OLE for drag and drop functionality - WebKit // will throw an OutOfMemory exception if we don't... Application.OleRequired(); } // If this control is brought to focus, focus our webkit child window this.host.GotFocus += (s, e) => { NativeMethods.SetFocus(webViewHWND); }; activationContext.Activate(); webView = new WebViewClass(); activationContext.Deactivate(); } }
public static object GetDeploymentComponentManifest(ActivationContext appInfo) { throw new NotImplementedException(); }
public static extern SafeActivationContextHandle CreateActCtx(ref ActivationContext pActCtx);
public abstract bool Process(int pass, ActivationContext c);
internal static Evidence MergeApplicationEvidence(Evidence evidence, ApplicationIdentity applicationIdentity, ActivationContext activationContext, string[] activationData, ApplicationTrust applicationTrust) { Evidence evidence2 = new Evidence(); ActivationArguments arguments = (activationContext == null) ? new ActivationArguments(applicationIdentity, activationData) : new ActivationArguments(activationContext, activationData); evidence2 = new Evidence(); evidence2.AddHostEvidence <ActivationArguments>(arguments); if (applicationTrust != null) { evidence2.AddHostEvidence <ApplicationTrust>(applicationTrust); } if (activationContext != null) { Evidence applicationEvidence = new ApplicationSecurityInfo(activationContext).ApplicationEvidence; if (applicationEvidence != null) { evidence2.MergeWithNoDuplicates(applicationEvidence); } } if (evidence != null) { evidence2.MergeWithNoDuplicates(evidence); } return(evidence2); }
public virtual ObjectHandle CreateInstance (ActivationContext activationContext, string[] activationCustomData) { if (activationContext == null) throw new ArgumentNullException("activationContext"); Contract.EndContractBlock(); if (CmsUtils.CompareIdentities(AppDomain.CurrentDomain.ActivationContext, activationContext)) { ManifestRunner runner = new ManifestRunner(AppDomain.CurrentDomain, activationContext); return new ObjectHandle(runner.ExecuteAsAssembly()); } AppDomainSetup adSetup = new AppDomainSetup(new ActivationArguments(activationContext, activationCustomData)); // inherit the calling domain's AppDomain Manager AppDomainSetup currentDomainSetup = AppDomain.CurrentDomain.SetupInformation; adSetup.AppDomainManagerType = currentDomainSetup.AppDomainManagerType; adSetup.AppDomainManagerAssembly = currentDomainSetup.AppDomainManagerAssembly; // we inherit the evidence from the calling domain return CreateInstanceHelper(adSetup); }
internal static void CreateActivationContext(string fullName, string[] manifestPaths, bool useFusionActivationContext, out ApplicationIdentity applicationIdentity, out ActivationContext activationContext) { applicationIdentity = new ApplicationIdentity(fullName); activationContext = null; if (useFusionActivationContext) { if (manifestPaths != null) { activationContext = new ActivationContext(applicationIdentity, manifestPaths); } else { activationContext = new ActivationContext(applicationIdentity); } } }
public virtual ObjectHandle CreateInstance(ActivationContext activationContext) { return(CreateInstance(activationContext, null)); }
public static bool IsFirstRun(ActivationContext appInfo) { Contract.Requires(appInfo != null); return(default(bool)); }
public ApplicationSecurityInfo (ActivationContext activationContext) { if (activationContext == null) throw new ArgumentNullException ("activationContext"); _context = activationContext; }
public void Activate(ActivationContext <T> context) { context.Schedule(session => AddFact(session, context.Fact), _priority); }
// // Internal // internal static ApplicationTrust DetermineApplicationTrustInternal (ActivationContext activationContext, TrustManagerContext context) { ApplicationTrust trust = null; ApplicationTrustCollection userTrusts = new ApplicationTrustCollection(true); // See if there is a persisted trust decision for this application. if ((context == null || !context.IgnorePersistedDecision)) { trust = userTrusts[activationContext.Identity.FullName]; if (trust != null) return trust; } // There is no cached trust decision so invoke the trust manager. trust = ApplicationTrustManager.DetermineApplicationTrust(activationContext, context); if (trust == null) trust = new ApplicationTrust(activationContext.Identity); // make sure the application identity is correctly set. trust.ApplicationIdentity = activationContext.Identity; if (trust.Persist) userTrusts.Add(trust); return trust; }
internal static Evidence MergeApplicationEvidence(Evidence evidence, ApplicationIdentity applicationIdentity, ActivationContext activationContext, string[] activationData) { return(MergeApplicationEvidence(evidence, applicationIdentity, activationContext, activationData, null)); }
/// <summary> /// Initializes a new instance of the WebKitBrowser control. /// </summary> public WebKitBrowser() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; // this will prevent exceptions that occur when you use the favicon event PageSettings = new PageSettings(); if (LicenseManager.UsageMode != LicenseUsageMode.Designtime) { LanguageLoader.Initialize(); // Control Events this.Load += new EventHandler(WebKitBrowser_Load); this.Resize += new EventHandler(WebKitBrowser_Resize); // If this is the first time the library has been loaded, // initialize the activation context required to load the // WebKit COM component registration free if ((actCtxRefCount++) == 0) { activationContext = new ActivationContext(GlobalPreferences.WebKitPath + "\\OpenWebKitSharp.manifest"); activationContext.Initialize(); // TODO: more error handling here if (activationContext.Initialized != true) { return; } // Enable OLE for drag and drop functionality - WebKit // will throw an OutOfMemory exception if we don't... Application.OleRequired(); } // If this control is brought to focus, focus our webkit child window this.GotFocus += (s, e) => { NativeMethods.SetFocus(webViewHWND); }; activationContext.Activate(); webView = new WebViewClass(); contextmenumanager = new ContextMenuManager(this); Marshal.AddRef(Marshal.GetIUnknownForObject(contextmenumanager)); activationContext.Deactivate(); } }
public ComActivationProvider(string manifestPath) { ActivationContext ac = new ActivationContext { cbSize = Marshal.SizeOf(typeof (ActivationContext)), lpSource = manifestPath, dwFlags = 0 }; using (SafeActivationContextHandle hActCtx = NativeMethod.CreateActCtx(ref ac)) { if (hActCtx.IsInvalid) { Console.WriteLine("The ActCtx failed to be created w/err {0}", Marshal.GetLastWin32Error()); } // Activate the activation context. IntPtr cookie; if (NativeMethod.ActivateActCtx(hActCtx, out cookie)) { try { actoinToDo(); } finally { // Deactivate the activation context. NativeMethod.DeactivateActCtx(0, cookie); } } else { Console.WriteLine("The ActCtx failed to be activated w/err {0}", Marshal.GetLastWin32Error()); } } }