WCF 访问被拒绝异常
Posted
技术标签:
【中文标题】WCF 访问被拒绝异常【英文标题】:WCF Access is denied Exception 【发布时间】:2012-05-19 02:17:06 【问题描述】:尝试运行 WCF 服务会导致以下结果。我已经在引用的页面上尝试了与 netsh 相关的建议 http://msdn.microsoft.com/en-us/library/ms733768.aspx 并没有得到任何工作。请提供有关如何解决此问题的信息。
提前致谢。
"HTTP could not register URL http://+:8439/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details)."
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
at TestThreadSync.Form1.ListenOnChannel() in C:\Users\MyAccount\Desktop\TestService\Form1.cs:line 51
at TestThreadSync.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\MyAccount\Desktop\TestService\Form1.cs:line 32
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TestThreadSync.Program.Main() in C:\Users\MyAccount\Desktop\TestService\Program.cs:line 18
【问题讨论】:
【参考方案1】:两个选项(两个都可以)
1.使用netsh实用程序提供对端口的访问
netsh http添加urlacl url=http://+:8439/user=DOMAIN\UserName
http://blogs.msdn.com/b/amitlale/archive/2007/01/29/addressaccessdeniedexception-cause-and-solution.aspx
2.需要管理员权限
以管理员身份运行(Visual Studio 或应用程序本身)
【讨论】:
我已经尝试了第一个。尝试是成功的,但没有解决问题。但是,当我尝试使用第二个时,我现在收到一条不同的异常消息 "A registration already exists for URI '127.0.0.1:8439/'." 使用netsh http delete urlacl url=http://+:8439 ... 我已经删除了,但是异常 *** A Registration already exists for URI** 仍然存在 执行“netsh http show urlacl”并检查是否已经有8439的条目 刚查了一下,好像没有以前注册过这个端口号以上是关于WCF 访问被拒绝异常的主要内容,如果未能解决你的问题,请参考以下文章
错误:[异常...“访问受限 URI 被拒绝”...在调用 $.ajax 方法时
第一次机会异常访问路径被拒绝 (UnauthorizedAccessException)
意外异常:SQLSTATE[HY000] [1045] 用户 ****@'localhost' 的访问被拒绝(使用密码:YES)