开发者

A registration already exists for URI after stop/start

开发者 https://www.devze.com 2023-03-10 05:30 出处:网络
I am currently working on an application where I am creating a ServiceHost, then getting rid of it, then recreating it later. The problem is that once I get rid of the service host when I try to recre

I am currently working on an application where I am creating a ServiceHost, then getting rid of it, then recreating it later. The problem is that once I get rid of the service host when I try to recreate it I get the exception "A registration already exists for URI after stop/start." The weird thing is I have three separate hosts and one works and two don't. I assume something is not being disposed of properly but I'm not sure why.

I am creating the hosts like this

host = new ServiceHost(typeof(MyService));
host.Open();

Then getting rid of them like so

if (host != null)
{
    host.Cl开发者_StackOverflow社区ose();
    host = null;
}

I have also tried abort instead of close without any luck.


Though I am not sure about the exact issue, I can give you a little thought on it and some workaround.

If you are working in Windows 7, any URL you create as part of your hosting has to get registered. Netsh command usually helps us register and unregister the URLs.

For both registering and unregistering URIs you need to have admin permission.

You may try the following.

  1. If you are running your exe, try running it in Administrator mode. (Right click and select admin mode).

  2. If you are trying out with visual studio, try to restart the visual studio in admin mode and run the app.

  3. Try to unregister the URI and try again using Netsh.

http://saravananarumugam.wordpress.com/2011/03/01/http-could-not-register-url/

may help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号