Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Hosting / RemotingHelper.cs / 1305376 / RemotingHelper.cs
using System; using System.Collections.Generic; using System.Text; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Ipc; namespace System.AddIn.Hosting { internal static class RemotingHelper { // runtime initializes this to false; static bool CreatedInAD; static readonly Object s_lock = new Object(); internal static readonly String s_emptyGuid = Guid.Empty.ToString(); //// [System.Security.SecuritySafeCritical] [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, Flags = System.Security.Permissions.SecurityPermissionFlag.RemotingConfiguration | System.Security.Permissions.SecurityPermissionFlag.Infrastructure)] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security","CA2116:AptcaMethodsShouldOnlyCallAptcaMethods")] [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 static void InitializeClientChannel() { lock(s_lock) { if (CreatedInAD) // only one client channel per AD return; CreatedInAD = true; // make sure this hasn't been created already in this AD // BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); System.Collections.IDictionary props = new System.Collections.Hashtable(); props["name"] = "ClientChannel"; props["portName"] = Guid.NewGuid().ToString(); props["typeFilterLevel"] = "Full"; // When communicating between application domains on the same computer, the ipc channel is much faster than the tcp IChannel ichannel = new AddInIpcChannel(props, clientProvider, serverProvider); // ( ChannelServices.RegisterChannel(ichannel, false); } } // AddinServer is a singleton per process. It is created at process creation. // The AddinServer is the Marshaled class used to hook up the Client and Server remoting channel. //// // // // // // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Reviewed")] [System.Security.SecuritySafeCritical] internal static AddInServer GetAddInServer(string guid) { System.Diagnostics.Contracts.Contract.Requires(guid != null && guid != s_emptyGuid); return (AddInServer)Activator.GetObject(Type.GetType(@"System.AddIn.Hosting.AddInServer") , @"ipc://" + guid + @"/AddInServer"); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Text; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Ipc; namespace System.AddIn.Hosting { internal static class RemotingHelper { // runtime initializes this to false; static bool CreatedInAD; static readonly Object s_lock = new Object(); internal static readonly String s_emptyGuid = Guid.Empty.ToString(); //// // [System.Security.SecuritySafeCritical] [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, Flags = System.Security.Permissions.SecurityPermissionFlag.RemotingConfiguration | System.Security.Permissions.SecurityPermissionFlag.Infrastructure)] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security","CA2116:AptcaMethodsShouldOnlyCallAptcaMethods")] [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 static void InitializeClientChannel() { lock(s_lock) { if (CreatedInAD) // only one client channel per AD return; CreatedInAD = true; // make sure this hasn't been created already in this AD // BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); System.Collections.IDictionary props = new System.Collections.Hashtable(); props["name"] = "ClientChannel"; props["portName"] = Guid.NewGuid().ToString(); props["typeFilterLevel"] = "Full"; // When communicating between application domains on the same computer, the ipc channel is much faster than the tcp IChannel ichannel = new AddInIpcChannel(props, clientProvider, serverProvider); // ( ChannelServices.RegisterChannel(ichannel, false); } } // AddinServer is a singleton per process. It is created at process creation. // The AddinServer is the Marshaled class used to hook up the Client and Server remoting channel. //// // // // // // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Reviewed")] [System.Security.SecuritySafeCritical] internal static AddInServer GetAddInServer(string guid) { System.Diagnostics.Contracts.Contract.Requires(guid != null && guid != s_emptyGuid); return (AddInServer)Activator.GetObject(Type.GetType(@"System.AddIn.Hosting.AddInServer") , @"ipc://" + guid + @"/AddInServer"); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.//
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AmbientProperties.cs
- regiisutil.cs
- MobileFormsAuthentication.cs
- DbDataReader.cs
- CustomErrorsSection.cs
- _AcceptOverlappedAsyncResult.cs
- DataSourceConverter.cs
- SHA1Managed.cs
- KeyToListMap.cs
- UserCancellationException.cs
- FastPropertyAccessor.cs
- ConfigXmlWhitespace.cs
- DynamicEntity.cs
- SortableBindingList.cs
- ToolboxCategoryItems.cs
- WebPartTransformerCollection.cs
- EnumBuilder.cs
- EntityCommandCompilationException.cs
- ExtensionWindow.cs
- PathGeometry.cs
- RangeContentEnumerator.cs
- PopupRoot.cs
- TransformerTypeCollection.cs
- ReachIDocumentPaginatorSerializer.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- IPHostEntry.cs
- EncryptedData.cs
- MiniLockedBorderGlyph.cs
- CodeIndexerExpression.cs
- SystemResources.cs
- CollectionViewGroupInternal.cs
- TextModifier.cs
- SymmetricKey.cs
- CookieHandler.cs
- ExpressionNormalizer.cs
- FlowDocumentPageViewerAutomationPeer.cs
- SiblingIterators.cs
- DropDownList.cs
- JoinSymbol.cs
- ApplicationTrust.cs
- BinaryOperationBinder.cs
- ZipIOExtraFieldZip64Element.cs
- XamlTypeMapper.cs
- TextReader.cs
- AssemblySettingAttributes.cs
- DesignerWebPartChrome.cs
- SafeMarshalContext.cs
- StoragePropertyMapping.cs
- PropertyHelper.cs
- TextDecorationCollectionConverter.cs
- SqlInfoMessageEvent.cs
- AsyncOperation.cs
- XmlNodeReader.cs
- VBCodeProvider.cs
- DBParameter.cs
- WindowsListBox.cs
- MappingMetadataHelper.cs
- DodSequenceMerge.cs
- SqlFactory.cs
- HtmlButton.cs
- RowBinding.cs
- AudioSignalProblemOccurredEventArgs.cs
- X509ChainPolicy.cs
- BindableAttribute.cs
- Pair.cs
- SimpleApplicationHost.cs
- UndoManager.cs
- XmlSchemaAttributeGroup.cs
- FunctionUpdateCommand.cs
- SoapMessage.cs
- AuthorizationBehavior.cs
- DragDeltaEventArgs.cs
- ConstraintCollection.cs
- GetWinFXPath.cs
- DataTableReader.cs
- PathNode.cs
- FamilyTypeface.cs
- EncryptedPackageFilter.cs
- DictionaryBase.cs
- Point3DKeyFrameCollection.cs
- TypeSystemProvider.cs
- UpdateProgress.cs
- TemplateBamlTreeBuilder.cs
- EditorReuseAttribute.cs
- ScriptIgnoreAttribute.cs
- EventSourceCreationData.cs
- RepeatInfo.cs
- RepeaterItemEventArgs.cs
- ColumnMap.cs
- SectionInformation.cs
- SqlServer2KCompatibilityCheck.cs
- InputEventArgs.cs
- ChtmlPhoneCallAdapter.cs
- EventWaitHandle.cs
- WebBrowser.cs
- PageParserFilter.cs
- SqlUdtInfo.cs
- TcpStreams.cs
- RequestSecurityTokenSerializer.cs
- UInt32Converter.cs