Click here to Skip to main content
15,914,160 members
Home / Discussions / C#
   

C#

 
AnswerRe: Distribution license for Interop.ShockWaveFlashObjects.DLL Pin
Pete O'Hanlon11-Jul-07 3:35
mvePete O'Hanlon11-Jul-07 3:35 
QuestionRefresh DataGrid with Latest Values Pin
ramdil11-Jul-07 3:02
ramdil11-Jul-07 3:02 
AnswerRe: Refresh DataGrid with Latest Values Pin
Drew McGhie11-Jul-07 4:08
Drew McGhie11-Jul-07 4:08 
GeneralRe: Refresh DataGrid with Latest Values Pin
ramdil11-Jul-07 5:25
ramdil11-Jul-07 5:25 
GeneralRe: Refresh DataGrid with Latest Values Pin
Drew McGhie11-Jul-07 7:27
Drew McGhie11-Jul-07 7:27 
QuestionAutoCompleteStringCollection + Specified cast is not valid Pin
Nouman Bhatti11-Jul-07 3:00
Nouman Bhatti11-Jul-07 3:00 
AnswerRe: AutoCompleteStringCollection + Specified cast is not valid Pin
Scott Dorman11-Jul-07 3:29
professionalScott Dorman11-Jul-07 3:29 
QuestionIPC-Remoting call hangs Pin
BhaaL-san11-Jul-07 2:52
BhaaL-san11-Jul-07 2:52 
Greetings!

I am currently trying to implement a small IPC Protocol for 2 of my applications.
Basically, one of them needs to know if the other one is running, and if yes, tell it some orders.

My current setup consists of 3 Main projects:
- IPC: Holds an interface IIPC with a couple of methods that have to be shared.
- MainForm: implements the interface IIPC and is supposed to be shared. Also "starts" the IPC Server.
- PluginDLL: is loaded into a 3rd-party app, and tries to talk to MainForm.

The usual setup consists of the 3rd-party app, which loaded PluginDLL. MainForm is supposed to be started by PluginDLL in case a function is requested.
But its also possible that MainForm is already running, and 3rd-party app is loaded after that. As MainForm exists, its supposed to be used rather than creating a new instance.

First problem there:
I've tried to find out whether MainForm is running by checking if the Channel is already registered:
[MainForm, "serverside"]
class MainForm : MarshalByRefObject, IIPC { ... };<br />
...<br />
Type t = typeof(MainForm);<br />
string ServerChannel = "serverMainForm";<br />
string ObjectName = "mfObject";<br />
...<br />
IpcServerChannel ipcChannel = new IpcServerChannel(ServerChannel);<br />
ChannelServices.RegisterChannel(ipcChannel,true);<br />
RemotingConfiguration.RegisterWellKnownServiceType(t, ObjectName, WellKnownObjectMode.Singleton);


[PluginDLL, "clientside"]
IIPC getIPCObject() {<br />
//IChannel ipcServer = ChannelServices.GetChannel(ServerChannel);<br />
//if (ipcServer != null)<br />
//{<br />
   IpcClientChannel ipcChannel = new IpcClientChannel();<br />
   ChannelServices.RegisterChannel(ipcChannel,true);<br />
   IIPC ret = (IIPC)Activator.GetObject(typeof(IIPC), "ipc://" + ServerChannel + "/" + ObjectName);<br />
   ChannelServices.UnregisterChannel(ipcChannel);<br />
   try<br />
   {<br />
      if (ret.Equals(null)) return null;<br />
   }<br />
   catch<br />
   {<br />
      return null;<br />
   }<br />
   return ret;<br />
//}<br />
//return null;<br />
}

Unfortunately, GetChannel returned null, even tho I just registered the Channel before.
Enumerating ChannelServices.RegisteredChannels does not return anything inside PluginDLL, inside MainForm it does show the channel I just registered 2 lines before.
For that purpose, I had to use the exception that is thrown when accessing the proxy object with no serverobject behind.
This problem is worked around, but I'd like to know if theres a better way to check if I have an object behind the proxy, or either if the channel exists.

Second problem is the more serious one:
Using above Workaround, I managed to catch the circumstance that MainForm is not running, and run it in this case using System.Diagnostics.Process.Start(). After that, the code above generates a valid proxy - it seems.
But the call to ret.Equals(null) simply hangs, rather than returning false and retrieving the remote object OR failing and throwing an exception - it simply hangs, and wont respond. I also tried to use my own Method/Property/whatever back there instead of Equals, all of them simply hung.

So, what might be the reason for the Proxy object to hang when there is an object?
Or probably, is there any other way to communicate between 2 applications that does not need any additional stuff installed (like MSMQ), that isnt dependant on a port (Remoting with HTTP/TCP; its rather unlikely that a Channel with my programs ID exists already than an arbitrary port that may be used by other programs) or that depends on other lower level code (PostMessage with WM_COPYDATA, needs WinApi and other unmanaged stuff)

Regards, BhaaL
AnswerRe: IPC-Remoting call hangs Pin
michalburger24-Aug-10 1:00
michalburger24-Aug-10 1:00 
GeneralRe: IPC-Remoting call hangs Pin
BhaaLseN24-Aug-10 6:37
BhaaLseN24-Aug-10 6:37 
QuestionXML serialization #2 Pin
ruanr11-Jul-07 2:50
ruanr11-Jul-07 2:50 
QuestionFile Conversion from CSV format Excel format in C# (I have to do Programatically) Pin
liyakhat_shahid11-Jul-07 2:34
liyakhat_shahid11-Jul-07 2:34 
AnswerRe: File Conversion from CSV format Excel format in C# (I have to do Programatically) Pin
Christian Graus11-Jul-07 2:37
protectorChristian Graus11-Jul-07 2:37 
GeneralRe: File Conversion from CSV format Excel format in C# (I have to do Programatically) Pin
liyakhat_shahid11-Jul-07 2:46
liyakhat_shahid11-Jul-07 2:46 
QuestionConvert string in DB to DateTime in .NET Pin
blackjack215011-Jul-07 2:19
blackjack215011-Jul-07 2:19 
AnswerRe: Convert string in DB to DateTime in .NET Pin
originSH11-Jul-07 2:21
originSH11-Jul-07 2:21 
AnswerRe: Convert string in DB to DateTime in .NET Pin
Christian Graus11-Jul-07 2:22
protectorChristian Graus11-Jul-07 2:22 
QuestionRe: Convert string in DB to DateTime in .NET Pin
blackjack215011-Jul-07 2:30
blackjack215011-Jul-07 2:30 
AnswerRe: Convert string in DB to DateTime in .NET Pin
Pete O'Hanlon11-Jul-07 3:43
mvePete O'Hanlon11-Jul-07 3:43 
GeneralRe: Convert string in DB to DateTime in .NET Pin
PIEBALDconsult11-Jul-07 11:00
mvePIEBALDconsult11-Jul-07 11:00 
GeneralRe: Convert string in DB to DateTime in .NET Pin
blackjack215011-Jul-07 11:03
blackjack215011-Jul-07 11:03 
QuestionSMS from .NET application Pin
neer111-Jul-07 2:15
neer111-Jul-07 2:15 
AnswerRe: SMS from .NET application Pin
originSH11-Jul-07 2:22
originSH11-Jul-07 2:22 
AnswerRe: SMS from .NET application Pin
Giorgi Dalakishvili11-Jul-07 2:23
mentorGiorgi Dalakishvili11-Jul-07 2:23 
AnswerRe: SMS from .NET application Pin
Affan Toor11-Jul-07 2:24
Affan Toor11-Jul-07 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.