本文整理汇总了C#中System.ServiceModel.NetNamedPipeBinding类的典型用法代码示例。如果您正苦于以下问题:C# NetNamedPipeBinding类的具体用法?C# NetNamedPipeBinding怎么用?C# NetNamedPipeBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetNamedPipeBinding类属于System.ServiceModel命名空间,在下文中一共展示了NetNamedPipeBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Inspect
public string Inspect(ManagedApplicationInfo applicationInfo)
{
var binding = new NetNamedPipeBinding();
var channelFactory = new ChannelFactory<IProcessService>(binding, ProcessServiceAddress);
IProcessService processService = channelFactory.CreateChannel();
return processService.Inspect(applicationInfo);
}
示例2: ReadyRemoteProcess
private void ReadyRemoteProcess()
{
string uri = "net.pipe://localhost/download";
DownloadManager dm = new DownloadManager();
dm.CopyFileCallBack = delegate(string file)
{
return doCopyFile(file);
};
try
{
this.host = new ServiceHost(dm);
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
host.AddServiceEndpoint(typeof(IDownloadManager), binding, uri);
host.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.host = null;
}
}
示例3: ServerAncClientExceptionsEndpointBehavior
public void ServerAncClientExceptionsEndpointBehavior()
{
var hook = new ExceptionsEndpointBehaviour();
var address = @"net.pipe://127.0.0.1/test" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
var serv = new ExceptionService();
using (var host = new ServiceHost(serv, new Uri[] { new Uri(address), }))
{
var b = new NetNamedPipeBinding();
var serverEndpoint = host.AddServiceEndpoint(typeof(IExceptionService), b, address);
serverEndpoint.Behaviors.Add(hook);
host.Open();
var f = new ChannelFactory<IExceptionService>(b);
f.Endpoint.Behaviors.Add(hook);
var c = f.CreateChannel(new EndpointAddress(address));
try
{
c.DoException("message");
}
catch (InvalidOperationException ex)
{
StringAssert.AreEqualIgnoringCase("message", ex.Message);
}
host.Abort();
}
}
示例4: RunClientAsync
private static async Task RunClientAsync(Uri address, CancellationToken token)
{
ClientEventSource eventSource = ClientEventSource.Instance;
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
binding.OpenTimeout = TimeSpan.FromSeconds(1.0d);
binding.SendTimeout = TimeSpan.FromSeconds(1.0d);
binding.ReceiveTimeout = TimeSpan.FromSeconds(1.0d);
binding.CloseTimeout = TimeSpan.FromSeconds(1.0d);
CalculatorChannelFactory factory = new CalculatorChannelFactory(binding, new EndpointAddress(address), eventSource);
await factory.OpenAsync();
ConnectionManager<ICalculatorClientAsync> connectionManager = new ConnectionManager<ICalculatorClientAsync>(factory);
using (ProxyInvoker<ICalculatorClientAsync> proxy = new ProxyInvoker<ICalculatorClientAsync>(connectionManager))
{
Random random = new Random();
while (!token.IsCancellationRequested)
{
try
{
await proxy.InvokeAsync(c => InvokeRandomAsync(random, c));
}
catch (Exception)
{
}
await Task.Delay(TimeSpan.FromMilliseconds(250.0d));
}
}
await factory.CloseAsync();
}
示例5: TrySetColor
private static bool TrySetColor(Color color)
{
try
{
const string uriText = "net.pipe://localhost/mailnotifier/sign";
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
EndpointAddress endpointAddress = new EndpointAddress(uriText);
using (MailNotifierServiceClient client = new MailNotifierServiceClient(binding, endpointAddress))
{
byte red = color.R;
byte green = color.G;
byte blue = color.B;
client.SetColor(red, green, blue);
client.Close();
return true;
}
}
catch (Exception e)
{
Console.WriteLine("Failed to set color to " + color + ": " + e.Message);
return false;
}
}
示例6: CreateChannel
public void CreateChannel()
{
Binding binding;
EndpointAddress endpointAddress;
bool useAuth = !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password);
if (IsLocal(ServerName))
{
endpointAddress = new EndpointAddress("net.pipe://localhost/MPExtended/TVAccessService");
binding = new NetNamedPipeBinding { MaxReceivedMessageSize = 10000000 };
}
else
{
endpointAddress = new EndpointAddress(string.Format("http://{0}:4322/MPExtended/TVAccessService", ServerName));
BasicHttpBinding basicBinding = new BasicHttpBinding { MaxReceivedMessageSize = 10000000 };
if (useAuth)
{
basicBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
basicBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
}
basicBinding.ReaderQuotas.MaxStringContentLength = 5*1024*1024; // 5 MB
binding = basicBinding;
}
binding.OpenTimeout = TimeSpan.FromSeconds(5);
ChannelFactory<ITVAccessService> factory = new ChannelFactory<ITVAccessService>(binding);
if (factory.Credentials != null && useAuth)
{
factory.Credentials.UserName.UserName = Username;
factory.Credentials.UserName.Password = Password;
}
TvServer = factory.CreateChannel(endpointAddress);
}
示例7: Create
// Public Creator
public bool Create()
{
bool rc = false;
try
{
_binding = new NetNamedPipeBinding();
_binding.MaxReceivedMessageSize = 10485760;
if (productId == 0)
{
//_endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2013/LyrebirdService");
}
else if (productId == 2)
{
_endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2015/LyrebirdService");
}
else if (productId == 3)
{
_endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2016/LyrebirdService");
}
else
{
_endpoint = new EndpointAddress("net.pipe://localhost/LMNts/LyrebirdServer/Revit2014/LyrebirdService");
}
_factory = new ChannelFactory<ILyrebirdService>(_binding, _endpoint);
_channel = _factory.CreateChannel();
rc = true;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
return rc;
}
示例8: CreateSession
internal void CreateSession()
{
Uri serviceAddress = new Uri("net.pipe://localhost/Multitouch.Service/ApplicationInterface");
EndpointAddress remoteAddress = new EndpointAddress(serviceAddress);
NetNamedPipeBinding namedPipeBinding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
namedPipeBinding.MaxReceivedMessageSize = int.MaxValue;
namedPipeBinding.MaxBufferSize = int.MaxValue;
namedPipeBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
namedPipeBinding.ReceiveTimeout = TimeSpan.MaxValue;
IApplicationInterfaceCallback dispatcher = new MultitouchServiceContactDispatcher(logic);
InstanceContext instanceContext = new InstanceContext(dispatcher);
service = new ApplicationInterfaceClient(instanceContext, namedPipeBinding, remoteAddress);
try
{
service.CreateSession();
MouseHelper.SingleMouseFallback = false;
}
catch (EndpointNotFoundException)
{
//throw new MultitouchException("Could not connect to Multitouch service, please start Multitouch input server before running this application.", e);
Trace.TraceWarning("Could not connect to Multitouch service. Enabling single mouse input.");
SingleMouseClientAndDispatcher client = new SingleMouseClientAndDispatcher(logic);
service = client;
dispatcher = client;
MouseHelper.SingleMouseFallback = true;
}
contactDispatcher = dispatcher;
}
示例9: OnStart
protected override void OnStart(string[] args)
{
base.OnStart(args);
if (this.serviceHost != null)
{
this.serviceHost.Close();
}
// start ServiceHost
var baseUri = new Uri(Prison.changeSessionBaseEndpointAddress);
Uri serviceUri = baseUri;
//Debugger.Launch();
if (this.serviceId != null)
{
serviceUri = new Uri(Prison.changeSessionBaseEndpointAddress + "/" + this.serviceId);
}
var bind = new NetNamedPipeBinding();
bind.Security.Mode = NetNamedPipeSecurityMode.Transport;
bind.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;
serviceHost = new ServiceHost(typeof(Executor), serviceUri);
//serviceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = false, HttpsGetEnabled = false });
//serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;
//serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>().HttpHelpPageUrl = serviceUri;
serviceHost.AddServiceEndpoint(typeof(IExecutor), bind, string.Empty);
//this.serviceHost = new ServiceHost(typeof(Executor));
this.serviceHost.Open();
}
示例10: StartService
public static IDisposable StartService(TestDetails testDetails, TestCallbackHandler testCallback)
{
if (_currentService != null)
{
_currentService.Dispose();
_currentService = null;
}
_currentCallback = testCallback;
_testDetails = testDetails;
ServiceHost host = new ServiceHost(typeof(TestCallbackService));
try
{
var binding = new NetNamedPipeBinding();
binding.MaxReceivedMessageSize = 100000;
host.AddServiceEndpoint(typeof(ITestCallbackService), binding, new Uri(ServiceAddress));
host.Open();
}
catch (Exception)
{
((IDisposable)host).Dispose();
_currentCallback = null;
throw;
}
return new ServiceWrapper(host);
}
示例11: Open
public void Open(int port)
{
if (port < 0 || port > 65536)
throw new ArgumentOutOfRangeException("port", "port value is invalid");
string urlService = "net.pipe://localhost/" + SERVICE_NAME + "_" + port.ToString();
lock (mClientLocker)
{
if (mProxy != null)
return;
var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
bind.MaxReceivedMessageSize = 2147483647;
bind.MaxBufferSize = 2147483647;
// Commented next statement since it is not required
bind.MaxBufferPoolSize = 2147483647;
bind.ReaderQuotas.MaxArrayLength = 2147483647;
bind.ReaderQuotas.MaxBytesPerRead = 2147483647;
bind.ReaderQuotas.MaxDepth = 2147483647;
bind.ReaderQuotas.MaxStringContentLength = 2147483647;
bind.ReaderQuotas.MaxNameTableCharCount = 2147483647;
mProxy = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
mProxy.Faulted += mProxy_Faulted;
}
}
示例12: CallbackToSyncContext
public void CallbackToSyncContext()
{
var path = @"net.pipe://127.0.0.1/" + this.GetType().Name + MethodBase.GetCurrentMethod().Name;
var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None) { MaxConnections = 5 };
using (var server = new ServiceHost(new SyncCallbackService(), new Uri(path)))
{
server.AddServiceEndpoint(typeof(ISyncCallbackService), binding, path);
server.Open();
using (var syncContext = new StaSynchronizationContext())
{
InstanceContext context = null;
DuplexChannelFactory<ISyncCallbackService> channelFactory = null;
ISyncCallbackService client = null;
syncContext.Send(_ => SynchronizationContext.SetSynchronizationContext(syncContext), null);
syncContext.Send(_ => context = new InstanceContext(new SyncCallbackServiceCallback()), null);
syncContext.Send(_ => channelFactory = new DuplexChannelFactory<ISyncCallbackService>(context, binding),null);
syncContext.Send(_ => client = channelFactory.CreateChannel(new EndpointAddress(path)),null);
using (channelFactory)
{
var callbackThread = client.Call();
Assert.AreEqual(syncContext.ManagedThreadId, callbackThread);
}
}
}
}
示例13: InitChannel
/// <summary>
/// Creates a new client channel if the communication object is null or
/// is faulted, closed or closing.
/// </summary>
private void InitChannel()
{
lock (_padlock)
{
if (_commObj == null ||
(_commObj.State != CommunicationState.Opened &&
_commObj.State != CommunicationState.Opening))
{
if (!string.IsNullOrEmpty(_configurationName))
{
_client = new ChannelFactory<IProxyTraceService>(_configurationName).CreateChannel();
}
else
{
// Todo - is None really the best choice of security mode?
// maybe we should secure the transport by default???
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
EndpointAddress address = new EndpointAddress(DefaultEndpointAddress);
_client = ChannelFactory<IProxyTraceService>.CreateChannel(binding, address);
}
_commObj = (ICommunicationObject)_client;
}
}
}
示例14: Start
internal void Start()
{
//Create a proxy to the event service
EndpointAddress remoteAddress = new EndpointAddress(Config.Communincation.ServiceURI);
NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
IChannelFactory<IEventService> channelFactory = new ChannelFactory<IEventService>(netNamedPipeBinding, remoteAddress);
IEventService eventService = channelFactory.CreateChannel(remoteAddress);
//Signal ready and wait for other threads to join.
_syncStartBarrier.SignalAndWait();
EventSource eventSource = new EventSource() { ID = Guid.NewGuid(), Name = string.Format("Publisher:{0}", _Id) };
Console.WriteLine("{0} Running...", eventSource);
Event @event = new Event() { Source = eventSource, Info = String.Format("EVENT PUBLISHED AT[{0}]", DateTime.Now.ToLongTimeString()), RecordedAt = DateTime.Now };
Byte[] bytes = ProtoBufSerializer.Serialize<Event>(@event);
//Start publishing events
for (Int64 i = 0; i < _iterations; i++)
{
eventService.Handle(bytes);
}
channelFactory.Close();
}
示例15: Open_Open_error
public void Open_Open_error()
{
var tcp= new NetTcpBinding();
var pipe = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
Assert.IsTrue(tcp.Security.GetType() != pipe.Security.GetType());
}