all groups > dotnet distributed apps > january 2006 >
You're in the

dotnet distributed apps

group:

Unregistering IPCChannel doesn't seem to work


Unregistering IPCChannel doesn't seem to work Orlando
1/27/2006 1:06:27 PM
dotnet distributed apps: Hi,

I'm trying to run multiple unit tests where each test ends up registering
and unregistering an IPC remoting channel. Individually they pass, but as a
group all but the first fail - I get a "Failed to create IPC Port: Access is
denied" error. What do I need to do? I've tried multiple permutations of
things, but the following is the cleanest sample of what i'd like to do:

foreach (IChannel ch in ChannelServices.RegisteredChannels)
{
ChannelServices.UnregisterChannel(ch);
}

Other things that haven't worked include directly unregistering the channel,
calling "StopListening", waiting and retrying multiple times over 30 seconds,
and forcing a garbage collection.

thanks,
RE: Unregistering IPCChannel doesn't seem to work lukezhan NO[at]SPAM online.microsoft.com
1/30/2006 12:00:00 AM
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
RE: Unregistering IPCChannel doesn't seem to work Orlando
1/30/2006 12:34:28 PM
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]
RE: Unregistering IPCChannel doesn't seem to work lukezhan NO[at]SPAM online.microsoft.com
1/31/2006 12:00:00 AM
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
RE: Unregistering IPCChannel doesn't seem to work Orlando
1/31/2006 3:48:30 PM
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]
RE: Unregistering IPCChannel doesn't seem to work lukezhan NO[at]SPAM online.microsoft.com
2/2/2006 12:00:00 AM
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
RE: Unregistering IPCChannel doesn't seem to work Orlando
2/11/2006 9:12:28 AM
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]
RE: Unregistering IPCChannel doesn't seem to work spigi
2/12/2006 7:32:40 AM
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]
RE: Unregistering IPCChannel doesn't seem to work lukezhan NO[at]SPAM online.microsoft.com
2/13/2006 12:00:00 AM
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.)
AddThis Social Bookmark Button