首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grapevine 3.1 -‘进程无法访问文件’

Grapevine 3.1 -‘进程无法访问文件’
EN

Stack Overflow用户
提问于 2016-08-11 05:43:29
回答 1查看 1.9K关注 0票数 1

我有一个解决方案,它利用Grapevine在Program类中启动一个服务器。但是,由于某些原因,我一启动程序,当调用server.Start()时它就崩溃了。在这一点上,解决方案的其他部分都没有运行,所以我不知道这是如何发生的?

在Windows 10上以管理员身份在Visual Studio 15中运行。

Program.cs

代码语言:javascript
复制
using System;
using System.Threading;
using Grapevine.Server;
using QuantConnect.Logging;

namespace QuantConnect.Services
{
    class Program
    {
        /// <summary>
        /// QuantConnect C# Services Server:
        /// </summary>
        static void Main(string[] args)
        {
            var server = new RESTServer
            {
                //Host = Configuration.Config.Get("grapevine-host"),
                //Port = Configuration.Config.Get("grapevine-port")
                Host = Configuration.Config.Get("grapevine-host", "localhost"),
                Port = Configuration.Config.Get("grapevine-port", "80")
            };

            Log.Trace(string.Format("Starting Server On {0}:{1}", server.Host, server.Port));
            server.Start(); // Exception occurs here

            while (server.IsListening)
            {
                Thread.Sleep(300);
            }

            Log.Trace("Server stopped. Press key to continue...");
            Console.ReadLine();
        }
    }
}

错误和堆栈跟踪:

An unhandled exception of type 'System.Net.HttpListenerException' occurred in Grapevine.dll

代码语言:javascript
复制
System.Net.HttpListenerException was unhandled
  ErrorCode=32
  HResult=-2147467259
  Message=The process cannot access the file because it is being used by another process
  NativeErrorCode=32
  Source=System
  StackTrace:
       at System.Net.HttpListener.AddAllPrefixes()
       at System.Net.HttpListener.Start()
       at Grapevine.Server.RESTServer.Start()
       at QuantConnect.Services.Program.Main(String[] args) in C:\Users\RichardsPC\Source\Repos\Lean\Services\Program.cs:line 29
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-15 04:49:08

所以我找出了问题所在。我将Grapevine设置为使用端口80

Port = Configuration.Config.Get("grapevine-port", "80")

问题是我的机器上有另一个服务在使用这个端口,我将它改为使用8080,现在它工作得很好。

Port = Configuration.Config.Get("grapevine-port", "8080")

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38884061

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档