Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Hosting / AddInEnvironment.cs / 1305376 / AddInEnvironment.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: AddInEnvironment ** ** Purpose: Abstraction representing an AppDomain, Process and Machine ** ===========================================================*/ using System; using System.AddIn.Contract; using System.Runtime.Remoting; using System.Security; using System.Security.Permissions; using System.Diagnostics.Contracts; namespace System.AddIn.Hosting { public sealed class AddInEnvironment { private AddInProcess _process; // for in process we have an appdomain. private AppDomain _appDomain; // for out-of-process we have this. private AddInServerWorker _addInServerWorker; [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId="appDomain")] public AddInEnvironment(AppDomain appDomain) { if (appDomain == null) throw new ArgumentNullException("appDomain"); System.Diagnostics.Contracts.Contract.EndContractBlock(); if (appDomain != AppDomain.CurrentDomain && !Utils.HasFullTrust()) { throw new SecurityException(Res.PartialTrustCannotActivate); } _appDomain = appDomain; _process = AddInProcess.Current; } // This version is used when we have just created a new appdomain for this addin. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId="appDomain")] internal AddInEnvironment(AppDomain appDomain, bool skipDomainCheck) { if (appDomain == null) throw new ArgumentNullException("appDomain"); System.Diagnostics.Contracts.Contract.EndContractBlock(); _appDomain = appDomain; _process = AddInProcess.Current; } internal AddInEnvironment(AddInProcess process, AddInServerWorker worker) { _addInServerWorker = worker; _process = process; } public AddInProcess Process { get { return _process; } } internal AppDomain AppDomain { get { return _appDomain; } } internal AddInServerWorker AddInServerWorker { get { return _addInServerWorker; } } //// [System.Security.SecuritySafeCritical] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2129:SecurityTransparentCodeShouldNotReferenceNonpublicSecurityCriticalCode", Justification = "This is a SecurityRules.Level1 assembly, in which this rule is being incorrectly applied")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2128:SecurityTransparentCodeShouldNotAssert", Justification = "This is a SecurityRules.Level1 assembly, in which this rule is being incorrectly applied")] internal void UnloadAppDomain() { if (Process.IsCurrentProcess) { SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.ControlAppDomain); permission.Assert(); AppDomain.Unload(AppDomain); CodeAccessPermission.RevertAssert(); } else { try { _addInServerWorker.UnloadAppDomain(); } catch (AppDomainUnloadedException) { } catch (RemotingException) { } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: AddInEnvironment ** ** Purpose: Abstraction representing an AppDomain, Process and Machine ** ===========================================================*/ using System; using System.AddIn.Contract; using System.Runtime.Remoting; using System.Security; using System.Security.Permissions; using System.Diagnostics.Contracts; namespace System.AddIn.Hosting { public sealed class AddInEnvironment { private AddInProcess _process; // for in process we have an appdomain. private AppDomain _appDomain; // for out-of-process we have this. private AddInServerWorker _addInServerWorker; [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId="appDomain")] public AddInEnvironment(AppDomain appDomain) { if (appDomain == null) throw new ArgumentNullException("appDomain"); System.Diagnostics.Contracts.Contract.EndContractBlock(); if (appDomain != AppDomain.CurrentDomain && !Utils.HasFullTrust()) { throw new SecurityException(Res.PartialTrustCannotActivate); } _appDomain = appDomain; _process = AddInProcess.Current; } // This version is used when we have just created a new appdomain for this addin. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId="appDomain")] internal AddInEnvironment(AppDomain appDomain, bool skipDomainCheck) { if (appDomain == null) throw new ArgumentNullException("appDomain"); System.Diagnostics.Contracts.Contract.EndContractBlock(); _appDomain = appDomain; _process = AddInProcess.Current; } internal AddInEnvironment(AddInProcess process, AddInServerWorker worker) { _addInServerWorker = worker; _process = process; } public AddInProcess Process { get { return _process; } } internal AppDomain AppDomain { get { return _appDomain; } } internal AddInServerWorker AddInServerWorker { get { return _addInServerWorker; } } //// // // [System.Security.SecuritySafeCritical] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2129:SecurityTransparentCodeShouldNotReferenceNonpublicSecurityCriticalCode", Justification = "This is a SecurityRules.Level1 assembly, in which this rule is being incorrectly applied")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2128:SecurityTransparentCodeShouldNotAssert", Justification = "This is a SecurityRules.Level1 assembly, in which this rule is being incorrectly applied")] internal void UnloadAppDomain() { if (Process.IsCurrentProcess) { SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.ControlAppDomain); permission.Assert(); AppDomain.Unload(AppDomain); CodeAccessPermission.RevertAssert(); } else { try { _addInServerWorker.UnloadAppDomain(); } catch (AppDomainUnloadedException) { } catch (RemotingException) { } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.// //
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ReceiveMessageContent.cs
- IndexedEnumerable.cs
- SerializationInfo.cs
- InputReport.cs
- SchemaTypeEmitter.cs
- PolicyValidationException.cs
- InputReferenceExpression.cs
- MouseCaptureWithinProperty.cs
- IsolatedStorageFilePermission.cs
- _SpnDictionary.cs
- SafeJobHandle.cs
- ToolStripSystemRenderer.cs
- UserPreferenceChangingEventArgs.cs
- CharacterBufferReference.cs
- JpegBitmapEncoder.cs
- AppSettingsReader.cs
- SpeakInfo.cs
- Intellisense.cs
- CodeGroup.cs
- DataObjectPastingEventArgs.cs
- XhtmlBasicPageAdapter.cs
- ExpandCollapsePattern.cs
- ImageAutomationPeer.cs
- HTTPRemotingHandler.cs
- CommonDialog.cs
- safemediahandle.cs
- GroupItemAutomationPeer.cs
- Soap.cs
- SHA256.cs
- ParameterCollection.cs
- XpsS0ValidatingLoader.cs
- ToolStripContentPanel.cs
- ConfigXmlSignificantWhitespace.cs
- DefinitionUpdate.cs
- SqlConnection.cs
- EncryptedType.cs
- ZipArchive.cs
- BitmapEffectInputConnector.cs
- Helper.cs
- FileSecurity.cs
- WarningException.cs
- TextElementCollectionHelper.cs
- URLAttribute.cs
- UnsafeNativeMethodsCLR.cs
- ItemList.cs
- TypeDelegator.cs
- AutomationElementCollection.cs
- InvokeGenerator.cs
- CounterSampleCalculator.cs
- TypeForwardedToAttribute.cs
- MetricEntry.cs
- StatusBarDesigner.cs
- commandenforcer.cs
- Executor.cs
- BlobPersonalizationState.cs
- AppDomainGrammarProxy.cs
- ThemeableAttribute.cs
- FullTrustAssembliesSection.cs
- Size3DConverter.cs
- SchemaElementDecl.cs
- DbConnectionPoolOptions.cs
- DataGridRelationshipRow.cs
- TrayIconDesigner.cs
- InitiatorServiceModelSecurityTokenRequirement.cs
- IDReferencePropertyAttribute.cs
- ServiceModelInstallComponent.cs
- Hyperlink.cs
- ProxyAttribute.cs
- DESCryptoServiceProvider.cs
- MenuCommandService.cs
- CaseInsensitiveComparer.cs
- BindingMAnagerBase.cs
- SafeProcessHandle.cs
- InstallerTypeAttribute.cs
- DesignObjectWrapper.cs
- DocumentPageHost.cs
- ExpressionSelection.cs
- DispatcherExceptionFilterEventArgs.cs
- RangeValidator.cs
- HttpResponse.cs
- XmlIncludeAttribute.cs
- PrintDialog.cs
- ValidationPropertyAttribute.cs
- FrameworkContentElement.cs
- TimeoutConverter.cs
- ConfigurationPropertyCollection.cs
- HandoffBehavior.cs
- XmlAttributeHolder.cs
- selecteditemcollection.cs
- SqlIdentifier.cs
- SignatureGenerator.cs
- Storyboard.cs
- Int32AnimationUsingKeyFrames.cs
- XamlWriter.cs
- XmlComplianceUtil.cs
- EventMappingSettings.cs
- PeoplePickerWrapper.cs
- FindCompletedEventArgs.cs
- RowUpdatingEventArgs.cs
- PseudoWebRequest.cs