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中)嗎?