Communicating between C# and Visual C++ over IPC port (OR: Sharing a type between a Visual C++ DLL and a C# application) -
i have dll written in visual c++ , application written in c#. application written in c# uses ipc between multiple instances of ever runs 1 instance (it attempts start ipc server, , if can't assumes there's 1 running, in case sends command line arguments on ipc existing application).
now want send commands visual c++, however, when create type definition in visual c++ matches 1 in c# (on implementation level), rejects connection because fundamentally still 2 different types (from 2 different assemblies).
i thought using reflection in visual c++ fetch type c# assembly, can't because i'd have ship assembly along side dll (which defeats purpose of dll being api application).
i'm not sure of other way it, other store class in yet dll , make both application , api dll reference class in that, not ideal solution i'd single api dll distribute.
are there suggestions how can connect on ipc (other forms of communication tcp not permitted) send requests application?
the solution place interprocess class in api dll , make c# application use dll reference bring in class.
it important note in order initialize shared object correctly, had initialize server side of sharing in separate appdomain , make c# application client (this new version of previous paste):
try { // set interprocess object handle instructions // client , pass them onto main manager object. this.m_serverdomain = appdomain.createdomain("roketpack_server"); this.m_serverdomain.docallback(() => { // must give clients permission serialize delegates. binaryserverformattersinkprovider serverprov = new binaryserverformattersinkprovider(); serverprov.typefilterlevel = system.runtime.serialization.formatters.typefilterlevel.full; ipcserverchannel ipc = new ipcserverchannel("roketpack", "roketpack", serverprov); channelservices.registerchannel(ipc, true); remotingconfiguration.registerwellknownservicetype( typeof(api.interprocess), "interprocessmanager", wellknownobjectmode.singleton); }); // initialize object. ipcclientchannel client = new ipcclientchannel(); channelservices.registerchannel(client, true); this.m_interprocess = (api.interprocess)activator.getobject( typeof(api.interprocess), "ipc://" + name + "/interprocessmanager"); interprocesshandle.manager = this; this.m_interprocess.setcalls(interprocesshandle.callurl, interprocesshandle.islatestversion, interprocesshandle.requestupdate); return true; } catch (remotingexception) { // server appears running. connect // channel client , send instructions // server. ipcclientchannel client = new ipcclientchannel(); channelservices.registerchannel(client, true); api.interprocess = (api.interprocess)activator.getobject( typeof(api.interprocess), "ipc://" + name + "/interprocessmanager"); if (i == null) { errors.raise(errors.errortype.error_can_not_start_or_connect_to_ipc); return false; } if (environment.getcommandlineargs().length > 1) i.callurl(environment.getcommandlineargs()[1]); return false; }
i hope solution helps else :)
Comments
Post a Comment