2014-04-22 53 views
-1

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

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如果我以管理员身份启动远程调试器 - 所有工作都正常。

但我需要使用它作为一个普通的用户。我可以在没有管理员权限的情况下启动我的服务(托管在AutoCAD中)吗?

回答