HTTP无法注册URL(远程调试)

时间:2014-04-22 08:28:47

标签: wcf remote-debugging

C#,Windows 7.
我编写了一个AutoCAD插件并使用远程调试(MS Visual Studio)。我的插件必须作为WCF服务。 AutoCAD是非托管应用程序,必须作为我的服务的主机。我正在读一本关于WCF的书,我尝试使用它。我无法使用acad.exe.config进行服务设置:我没有权限。所以我自己做(我会从我的xml文件中读取它们,但稍后在重构后)。我的“服务器”的代码(此代码由AutoCAD开始):

private static void RunServices() {
  Ap.Document doc = cad.DocumentManager.MdiActiveDocument;
  try {
    Uri address = new Uri("http://localhost:8000/CadService");
    BasicHttpBinding binding = new BasicHttpBinding();
    binding.Name = "httpBinding";
    binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
    binding.Security.Mode = BasicHttpSecurityMode.None;
    host = new ServiceHost(typeof(CadService));
    host.AddServiceEndpoint(typeof(ICadService), binding, address);
    host.Open(); // I get an Exception here...
    if (doc != null) {
      doc.Editor.WriteMessage("Service launched.\n");
    }
  }
  catch (Exception ex) {
    if (doc != null) {
      doc.Editor.WriteMessage("Exception: {0}\n", ex.Message);
    }
  }
}

我得到一个例外(查看代码注释):

Exception: HTTP could not register URL http://+:8000/CadServices/. 
Your process does not have access rights to this namespace 
(see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

http://go.microsoft.com/fwlink/?LinkId=70353页面不存在。我尝试以管理员身份启动MS Visual Studio 2013(我读到了这个here),但这对我没有帮助(请看下面的P.S.2)。

P.S。如果我以管理员身份启动AutoCAD - 一切正常 P.S.2如果我以管理员身份启动远程调试器 - 一切正常.Page
但我需要将它作为普通用户使用。我是否可以在没有管理员权限的情况下启动我的服务(托管在AutoCAD中)?

1 个答案:

答案 0 :(得分:0)

这可能是因为AutoCad没有在HTTP.SYS中注册端口所需的权限。在这种情况下,您有两个选择:

  1. 以管理员模式启动Autocad
  2. 手动在HTTP.SYS中注册端口/端点。为此,有几种工具可用。这是我要使用的那个:http://www.codeproject.com/Articles/437733/Demystify-http-sys-with-HttpSysManager
  3. 让我知道这是否有效

相关问题