Hi Luke,
It's not the first call to register that fails - it's any register call
*after* unregister is called.
I'm using NUnit. Every test registers the channel in Setup and unregisters
in TearDown. Individually, running any single test passes. It's only when i
run the entire suite that Tests 2 through N fail.
Here's the register code when a config file doesn't exist:
System.Collections.IDictionary properties = new
System.Collections.Hashtable();
properties["name"] = "ipc";
properties["portName"] = Constants.IpcPipeName;
properties["authorizedGroup"] = "Everyone";
mIpcChannel = new IpcServerChannel(properties, null);
ChannelServices.RegisterChannel(mIpcChannel, false);
When a config file does exist, I just do
RemotingConfiguration.Configure(configFile.FullName, false);
The problem happens either way... I get "Failed to create IPC Port: Access is
denied" exception.
thanks,
Orlando
[quoted text, click to view] "Luke Zhang [MSFT]" wrote:
> Hello Orlando,
>
> Can you tell more how did you run the Unit tests and the channel are
> registered? It seems to be weird that only the first call to register the
> channel failed, since no channel was registered before it.
>
> Luke
>
I have logging in place. I'm sure the unregister is getting called. Any ideas
on what could theoretically be happening? Are there any diagnostic calls i
can make to verify the channel is free without trying to register?
thanks,
Orlando
[quoted text, click to view] "Luke Zhang [MSFT]" wrote:
> Hello,
>
> Did you use same port name for every unit test? if so, you may share a
> channel with all your tests. I am not a professional on NUnit, not sure if
> it will call the code to unregister the channel before it open a new one. I
> suggest you may add some debug code, for example, add a messagebox to make
> sure if the unregister code was called before registering a new one in
> NUint.
>
> Luke
>
I performed a test with a winform app:
IpcChannel serverChannel = new IpcChannel("localhost:9090");
ChannelServices.RegisterChannel(serverChannel,false);
System.Threading.Thread.Sleep(5000);
ChannelServices.UnregisterChannel(serverChannel);
System.Threading.Thread.Sleep(5000);
IpcChannel serverChannel2 = new IpcChannel("localhost:9090");
ChannelServices.RegisterChannel(serverChannel2, false);
System.Threading.Thread.Sleep(5000);
ChannelServices.UnregisterChannel(serverChannel2);
And I didn't find any problem. The UnregisterChannel method worked well in
this test. I suspect the problem may be related how NUnit run the code.
Luke
I confirmed your results.. but I'm no closer to solving my problem. Why is
this happening and what can i do about it? Not using NUnit is not an option.
Any theories? Technically what could be going on?
thanks,
Orlando
[quoted text, click to view] "Luke Zhang [MSFT]" wrote:
> I performed a test with a winform app:
>
> IpcChannel serverChannel = new IpcChannel("localhost:9090");
>
> ChannelServices.RegisterChannel(serverChannel,false);
>
> System.Threading.Thread.Sleep(5000);
> ChannelServices.UnregisterChannel(serverChannel);
>
> System.Threading.Thread.Sleep(5000);
> IpcChannel serverChannel2 = new IpcChannel("localhost:9090");
>
> ChannelServices.RegisterChannel(serverChannel2, false);
>
> System.Threading.Thread.Sleep(5000);
> ChannelServices.UnregisterChannel(serverChannel2);
>
>
> And I didn't find any problem. The UnregisterChannel method worked well in
> this test. I suspect the problem may be related how NUnit run the code.
>
> Luke
>
I have a similar problem. I think that problem is when is used secured
connection. In your example is not secured...
[quoted text, click to view] "Luke Zhang [MSFT]" wrote:
> I performed a test with a winform app:
>
> IpcChannel serverChannel = new IpcChannel("localhost:9090");
>
> ChannelServices.RegisterChannel(serverChannel,false);
>
> System.Threading.Thread.Sleep(5000);
> ChannelServices.UnregisterChannel(serverChannel);
>
> System.Threading.Thread.Sleep(5000);
> IpcChannel serverChannel2 = new IpcChannel("localhost:9090");
>
> ChannelServices.RegisterChannel(serverChannel2, false);
>
> System.Threading.Thread.Sleep(5000);
> ChannelServices.UnregisterChannel(serverChannel2);
>
>
> And I didn't find any problem. The UnregisterChannel method worked well in
> this test. I suspect the problem may be related how NUnit run the code.
>
> Luke
>
I guess, when you run a unit test in Nunit, it open a channel; when it open
another one, the previous channel hadn't been closed yet. This may be
related to the threading modal of Nunit. You had better post this question
to a Nunit related newsgroup, maybe there are someone knowing what happen
exactly there.
Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Don't see what you're looking for? Try a search.