Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net httplistener的on start()函数发生异常;“拒绝访问”;_.net_C# 4.0_Windows 7_Windows Services_Httplistener - Fatal编程技术网

.net httplistener的on start()函数发生异常;“拒绝访问”;

.net httplistener的on start()函数发生异常;“拒绝访问”;,.net,c#-4.0,windows-7,windows-services,httplistener,.net,C# 4.0,Windows 7,Windows Services,Httplistener,我正在使用一项数据库通信服务,该服务使用带有智能手持设备的url。在这里,当转到httplistener.start()函数时,我得到一个拒绝访问的异常。如何解决这个问题。这里我以普通用户身份登录。我的用户名=NI-PC036,userdomain=User33 urlExecuter = new UrlExecuter(); eventStop = new ManualResetEvent(false); MySq

我正在使用一项数据库通信服务,该服务使用带有智能手持设备的url。在这里,当转到httplistener.start()函数时,我得到一个拒绝访问的异常。如何解决这个问题。这里我以普通用户身份登录。我的用户名=NI-PC036,userdomain=User33

      urlExecuter = new UrlExecuter();
                eventStop = new ManualResetEvent(false);


                MySql.Start();

                // HTTP
                httpListener = new HttpListener();
                httpListener.Prefixes.Add("http://*/");
                httpListener.Start();
                httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);
  httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);


            cleanupThread = new Thread(delegate()
            {
                while (!eventStop.WaitOne(5 * 60 * 1000))   // 5Min
                {
                    try
                    {
                        if (cleanupTime.AddDays(1) < DateTime.Now)
                        {
                            int days = MiscTool.ReadIni<int>("SERVICE", "KEEP", 60);
                            Cleanup.Execute(days);
                            cleanupTime = DateTime.Now.Date;
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.WriteExceptionLog("cleanupThread", ex);
                    }
                }
            });
            cleanupThread.Start();
        }
urlExecuter=新的urlExecuter();
eventStop=新手动重置事件(假);
MySql.Start();
//HTTP
httpListener=新的httpListener();
httpListener.Prefixes.Add(“http://*/”;
httpListener.Start();
BeginGetContext(新的AsyncCallback(HttpListenerCallback),httpListener);
BeginGetContext(新的AsyncCallback(HttpListenerCallback),httpListener);
cleanupThread=新线程(委托()
{
而(!eventStop.WaitOne(5*60*1000))//5分钟
{
尝试
{
if(cleanupTime.AddDays(1)
当您在*上进行侦听时,您必须以管理员身份运行,或者必须向正在以管理员身份运行的帐户授予权限才能进行侦听*

      urlExecuter = new UrlExecuter();
                eventStop = new ManualResetEvent(false);


                MySql.Start();

                // HTTP
                httpListener = new HttpListener();
                httpListener.Prefixes.Add("http://*/");
                httpListener.Start();
                httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);
  httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);


            cleanupThread = new Thread(delegate()
            {
                while (!eventStop.WaitOne(5 * 60 * 1000))   // 5Min
                {
                    try
                    {
                        if (cleanupTime.AddDays(1) < DateTime.Now)
                        {
                            int days = MiscTool.ReadIni<int>("SERVICE", "KEEP", 60);
                            Cleanup.Execute(days);
                            cleanupTime = DateTime.Now.Date;
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.WriteExceptionLog("cleanupThread", ex);
                    }
                }
            });
            cleanupThread.Start();
        }
关于StackOverflow还有其他几个帖子已经讨论过这一点

      urlExecuter = new UrlExecuter();
                eventStop = new ManualResetEvent(false);


                MySql.Start();

                // HTTP
                httpListener = new HttpListener();
                httpListener.Prefixes.Add("http://*/");
                httpListener.Start();
                httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);
  httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);


            cleanupThread = new Thread(delegate()
            {
                while (!eventStop.WaitOne(5 * 60 * 1000))   // 5Min
                {
                    try
                    {
                        if (cleanupTime.AddDays(1) < DateTime.Now)
                        {
                            int days = MiscTool.ReadIni<int>("SERVICE", "KEEP", 60);
                            Cleanup.Execute(days);
                            cleanupTime = DateTime.Now.Date;
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.WriteExceptionLog("cleanupThread", ex);
                    }
                }
            });
            cleanupThread.Start();
        }
如果你仔细听http://localhost/[…]那么您不需要是管理员,也不需要将prvis授予您的帐户。请记住,您必须在URL中加载带有localhost的页面,而不是127.0.0.1,因为127.0.0.1将失败。。。这与向localhost发出请求不同

      urlExecuter = new UrlExecuter();
                eventStop = new ManualResetEvent(false);


                MySql.Start();

                // HTTP
                httpListener = new HttpListener();
                httpListener.Prefixes.Add("http://*/");
                httpListener.Start();
                httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);
  httpListener.BeginGetContext(new AsyncCallback(HttpListenerCallback), httpListener);


            cleanupThread = new Thread(delegate()
            {
                while (!eventStop.WaitOne(5 * 60 * 1000))   // 5Min
                {
                    try
                    {
                        if (cleanupTime.AddDays(1) < DateTime.Now)
                        {
                            int days = MiscTool.ReadIni<int>("SERVICE", "KEEP", 60);
                            Cleanup.Execute(days);
                            cleanupTime = DateTime.Now.Date;
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.WriteExceptionLog("cleanupThread", ex);
                    }
                }
            });
            cleanupThread.Start();
        }