本文整理汇总了C#中System.Runtime.Remoting.Channels.Ipc.IpcClientChannel类的典型用法代码示例。如果您正苦于以下问题:C# IpcClientChannel类的具体用法?C# IpcClientChannel怎么用?C# IpcClientChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IpcClientChannel类属于System.Runtime.Remoting.Channels.Ipc命名空间,在下文中一共展示了IpcClientChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
/// <summary>
/// Start connection with specified engine interface
/// </summary>
/// <param name="typeEngineInterface">Type of engine interface</param>
/// <param name="urlClient">Asscoiated URL</param>
/// <param name="ensureSecurity">Remoting security attribute</param>
public void Start(string urlClient, bool ensureSecurity, uint timeOut, Type iProxyType)
{
Trace.TraceInformation("Configuring client connection");
_ensureSecurity = ensureSecurity;
#if MONO
_sinkProvider = new BinaryClientFormatterSinkProvider();
#endif
IDictionary t = new Hashtable();
t.Add("timeout", timeOut);
t.Add("name", urlClient);
Console.WriteLine("New IPC channel");
// need to make ChannelNames unique so need to use this
// constructor even though we dont care about the sink provider
_channel = new IpcClientChannel(urlClient, _sinkProvider);
Console.WriteLine("\tRegister");
ChannelServices.RegisterChannel(_channel, _ensureSecurity);
Console.WriteLine("\tActivate object proxy to IEngine");
_base = (IBase)Activator.GetObject(iProxyType, urlClient);
Console.WriteLine("\tActivated.");
}
示例2: VisualStudioInstance
public VisualStudioInstance(Process process, DTE dte)
{
_hostProcess = process;
_dte = dte;
dte.ExecuteCommandAsync(VisualStudioCommandNames.VsStartServiceCommand).GetAwaiter().GetResult();
_integrationServiceChannel = new IpcClientChannel($"IPC channel client for {_hostProcess.Id}", sinkProvider: null);
ChannelServices.RegisterChannel(_integrationServiceChannel, ensureSecurity: true);
// Connect to a 'well defined, shouldn't conflict' IPC channel
var serviceUri = string.Format($"ipc://{IntegrationService.PortNameFormatString}", _hostProcess.Id);
_integrationService = (IntegrationService)(Activator.GetObject(typeof(IntegrationService), $"{serviceUri}/{typeof(IntegrationService).FullName}"));
_integrationService.Uri = serviceUri;
// There is a lot of VS initialization code that goes on, so we want to wait for that to 'settle' before
// we start executing any actual code.
_integrationService.Execute(typeof(RemotingHelper), nameof(RemotingHelper.WaitForSystemIdle));
_csharpInteractiveWindow = new Lazy<CSharpInteractiveWindow>(() => new CSharpInteractiveWindow(this));
_editorWindow = new Lazy<EditorWindow>(() => new EditorWindow(this));
_solutionExplorer = new Lazy<SolutionExplorer>(() => new SolutionExplorer(this));
_workspace = new Lazy<Workspace>(() => new Workspace(this));
// Ensure we are in a known 'good' state by cleaning up anything changed by the previous instance
Cleanup();
}
示例3: GetMessager
/// <summary>
/// Gets an instance of a <see cref="Messager"/> to use to talk to the running instance of the client.
/// </summary>
/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
/// <param name="p_gmdGameModeInfo">The descriptor of the game mode for which mods are being managed.</param>
/// <returns>An instance of a <see cref="Messager"/> to use to talk to the running instance of the client,
/// or <c>null</c> if no valid <see cref="Messager"/> could be created.</returns>
public static IMessager GetMessager(EnvironmentInfo p_eifEnvironmentInfo, IGameModeDescriptor p_gmdGameModeInfo)
{
if (m_cchMessagerChannel == null)
{
System.Collections.IDictionary properties = new System.Collections.Hashtable();
properties["exclusiveAddressUse"] = false;
m_cchMessagerChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(m_cchMessagerChannel, true);
}
else
throw new InvalidOperationException("The IPC Channel has already been created as a CLIENT.");
string strMessagerUri = String.Format("ipc://{0}-{1}IpcServer/{1}Listener", p_eifEnvironmentInfo.Settings.ModManagerName, p_gmdGameModeInfo.ModeId);
IMessager msgMessager = null;
try
{
Trace.TraceInformation(String.Format("Getting listener on: {0}", strMessagerUri));
msgMessager = (IMessager)Activator.GetObject(typeof(IMessager), strMessagerUri);
//Just because a messager has been returned, dosn't mean it exists.
//All you've really done at this point is create an object wrapper of type "Messager" which has the same methods, properties etc...
//You wont know if you've got a real object, until you invoke something, hence the post (Power on self test) method.
msgMessager.Post();
}
catch (RemotingException e)
{
Trace.TraceError("Could not get Messager: {0}", strMessagerUri);
TraceUtil.TraceException(e);
return null;
}
return new MessagerClient(msgMessager);
}
示例4: PtAccClient
/// <summary>
/// Register remoting channel and types
/// </summary>
private PtAccClient()
{
IpcClientChannel clientChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(clientChannel, true);
RemotingConfiguration.RegisterWellKnownClientType(typeof(PtAccRemoteType), "ipc://remote/PtAcc");
_remoteType = new PtAccRemoteType();
}
示例5: Send
public static void Send(Program.AppMessage msg, int lParam,
bool bWaitWithTimeout)
{
if(!KeePassLib.Native.NativeLib.IsUnix()) // Windows
{
if(bWaitWithTimeout)
{
IntPtr pResult = new IntPtr(0);
NativeMethods.SendMessageTimeout((IntPtr)NativeMethods.HWND_BROADCAST,
Program.ApplicationMessage, (IntPtr)msg,
(IntPtr)lParam, NativeMethods.SMTO_ABORTIFHUNG, 5000, ref pResult);
}
else
NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST,
Program.ApplicationMessage, (IntPtr)msg, (IntPtr)lParam);
}
else // Unix
{
if(m_chClient == null)
{
m_chClient = new IpcClientChannel();
ChannelServices.RegisterChannel(m_chClient, false);
}
try
{
IpcBroadcastSingleton ipc = (Activator.GetObject(typeof(
IpcBroadcastSingleton), "ipc://" + GetPortName() + "/" +
IpcObjectName) as IpcBroadcastSingleton);
if(ipc != null) ipc.Call((int)msg, lParam);
}
catch(Exception) { } // Server might not exist
}
}
示例6: Main
public static void Main (string [] args)
{
IpcClientChannel channel = new IpcClientChannel ();
ChannelServices.RegisterChannel (channel, false);
IFoo foo = (IFoo) Activator.GetObject (typeof (IFoo), "ipc://Foo/Foo");
foo.Foo ();
}
示例7: RegisterProxy
/// <summary>
/// Register the ipc client proxy
/// </summary>
internal void RegisterProxy()
{
try
{
string uri = "ipc://NetOffice.SampleChannel/NetOffice.WebTranslationService.DataService";
//Create an IPC client channel.
_channel = new IpcClientChannel();
//Register the channel with ChannelServices.
ChannelServices.RegisterChannel(_channel, true);
//Register the client type.
WellKnownClientTypeEntry[] entries = RemotingConfiguration.GetRegisteredWellKnownClientTypes();
if (null == GetEntry(entries, uri))
{
RemotingConfiguration.RegisterWellKnownClientType(
typeof(WebTranslationService),
uri);
}
DataService = new WebTranslationService();
// try to do some action to see the server is alive
string[] dumy = DataService.AvailableTranslations;
}
catch (RemotingException exception)
{
// rethrow the exception with a friendly message
throw new RemotingException("Unable to connect the local translation service.", exception);
}
catch (Exception)
{
throw;
}
}
示例8: Bug81653
public void Bug81653 ()
{
IpcClientChannel c = new IpcClientChannel ();
ChannelDataStore cd = new ChannelDataStore (new string[] { "foo" });
string objectUri;
c.CreateMessageSink (null, cd, out objectUri);
}
示例9: MonitorVdmClient
public MonitorVdmClient()
{
// Set up communication with the virtual desktop monitoring server.
_channel = new IpcClientChannel();
ChannelServices.RegisterChannel( _channel, false );
_monitorVdm = (IMonitorVdmService)Activator.GetObject( typeof( IMonitorVdmService ), "ipc://VirtualDesktopManagerAPI/MonitorVdmService" );
}
示例10: ChromePersistence
public ChromePersistence()
: base("chrome", "Google Inc.")
{
// Set up communication with the Chrome ABC extension.
_channel = new IpcClientChannel();
ChannelServices.RegisterChannel( _channel, false );
_chromeService = (IChromeAbcService)Activator.GetObject( typeof( IChromeAbcService ), "ipc://ChromeAbcConnection/ChromeAbcService" );
}
示例11: CreateClientChannel
private static void CreateClientChannel(String arg)
{
IpcClientChannel channel = new IpcClientChannel();
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownClientType(typeof(Ipc), "ipc://" + ipcPortName + "/" + ipcServername);
Ipc ipc = new Ipc();
ipc.OpenFile(arg);
}
示例12: Main
static void Main(string[] args)
{
if (args == null)
throw new ArgumentNullException("args");
if (args.Length != 1)
throw new ArgumentException("Arguments number doesn't match!", "args");
var name = args[0];
if (string.IsNullOrEmpty(name))
throw new Exception("Name cannot be null or empty.");
name = name.Trim('"');
var channelPort = string.Format(ProcessAppConst.PortNameTemplate, name, Process.GetCurrentProcess().Id);
var currentDomain = AppDomain.CurrentDomain;
var root = Path.Combine(Path.Combine(currentDomain.BaseDirectory, ProcessAppConst.WorkingDir), name);
//Hack to change the default AppDomain's root
if (NDockEnv.IsMono) //for Mono
{
var pro = typeof(AppDomain).GetProperty("SetupInformationNoCopy", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty);
var setupInfo = (AppDomainSetup)pro.GetValue(currentDomain, null);
setupInfo.ApplicationBase = root;
}
else // for .NET
{
currentDomain.SetData("APPBASE", root);
}
currentDomain.SetData(typeof(IsolationMode).Name, IsolationMode.Process);
try
{
var serverChannel = new IpcServerChannel("IpcAgent", channelPort, new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full });
var clientChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(serverChannel, false);
ChannelServices.RegisterChannel(clientChannel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ManagedAppWorker), ProcessAppConst.WorkerRemoteName, WellKnownObjectMode.Singleton);
Console.WriteLine("Ok");
var line = Console.ReadLine();
while (!"quit".Equals(line, StringComparison.OrdinalIgnoreCase))
{
line = Console.ReadLine();
}
}
catch
{
Console.Write("Failed");
}
}
示例13: Sounds
static Sounds()
{
//クライアントのチャンネルを生成
IpcClientChannel channel = new IpcClientChannel();
//チャンネルを登録
ChannelServices.RegisterChannel(channel, true);
//リモートオブジェクトの取得
midObject = Activator.GetObject(typeof(IPCSound), "ipc://HoppoAlphaSound/SoundData") as IPCSound;
}
示例14: IpcClient
/// <summary>
/// コンストラクタ
/// </summary>
public IpcClient()
{
// クライアントチャンネルの生成
IpcClientChannel channel = new IpcClientChannel();
// チャンネルを登録
ChannelServices.RegisterChannel(channel, true);
// リモートオブジェクトを取得
RemoteObject = Activator.GetObject(typeof(IpcRemoteObj), "ipc://" + IpcRemoteObj.ipcAddr + "/" + IpcRemoteObj.ipcAddrCom) as IpcRemoteObj;
}
示例15: IpcClientTransportSink
internal IpcClientTransportSink(string channelURI, IpcClientChannel channel)
{
string str;
this.portCache = new ConnectionCache();
this._tokenImpersonationLevel = TokenImpersonationLevel.Identification;
this._timeout = 0x3e8;
this._channel = channel;
string str2 = IpcChannelHelper.ParseURL(channelURI, out str);
int startIndex = str2.IndexOf("://") + 3;
this._portName = str2.Substring(startIndex);
}