SignalR WebApp.Start(url)不喜欢文件夹中的其他exe文件吗?

时间:2015-08-04 16:05:01

标签: c# .net signalr owin signalr-hub

当其他exe文件位于同一文件夹中时,我的WebApp.Start方法抛出System.IO.FileLoadException。我不知道为什么会这样,它让我疯狂。任何帮助表示赞赏。

//Calling webapp.start
string url = "http://*:8080/";
SignalRServer = WebApp.Start(url);


//My Owin Startup Class
class Startup
{
    public void Configuration(IAppBuilder app)
    {            
        // Branch the pipeline here for requests that start with "/signalr"
        app.Map("/signalr", map =>
        {               
            map.UseCors(CorsOptions.AllowAll);
            var hubConfiguration = new HubConfiguration
            {                    
                EnableJSONP = false,                   
                EnableDetailedErrors = true,
                EnableJavaScriptProxies = true
            };                              
            map.RunSignalR(hubConfiguration);
        });
    }
}

这个工作正常,直到我将服务投入到生产部署的测试中,现在它给出了以下错误。

  

System.IO.FileLoadException:无法加载文件或程序集' AutoServiceController,Version = 1.0.5270.19403,Culture = neutral,PublicKeyToken = null'或其中一个依赖项。尝试使用fixups加载无法验证的可执行文件(IAT包含2个以上的部分或TLS部分。)(HRESULT异常:0x80131019)   文件名:' AutoServiceController,Version = 1.0.5270.19403,Culture = neutral,PublicKeyToken = null' ---> System.IO.FileLoadException:尝试使用fixups加载无法验证的可执行文件(IAT包含2个以上的部分或TLS部分。)(HRESULT异常:0x80131019)      在System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)      在System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)      在System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)      在System.Reflection.Assembly.Load(AssemblyName assemblyRef)      在Owin.Loader.DefaultLoader.AssemblyDirScanner.d__1e.MoveNext()      在Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName,IList 1 errors, Boolean& conflict) at Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList 1个错误)      at Owin.Loader.DefaultLoader.LoadImplementation(String startupName,IList 1 errorDetails) at Owin.Loader.DefaultLoader.Load(String startupName, IList 1 errorDetails)      在Microsoft.Owin.Hosting.Loader.AppLoader.Load(String appName,IList`1错误)      在Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveApp(StartContext context)      在Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)      在Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions选项)      在Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions选项)      在Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider服务,StartOptions选项)      在Microsoft.Owin.Hosting.WebApp.Start(StartOptions选项)      在Microsoft.Owin.Hosting.WebApp.Start(String url)      在PvValuationController.PvValuationController.OnStart(String [] args)中的c:\ Users \ ahardy \ Documents \ Visual Studio 2013 \ Projects \ PvValuationController \ PvValuationController \ PvValuationController.cs:第156行

2 个答案:

答案 0 :(得分:4)

我最近遇到了同样的问题。对于未来的人们:

您只需要指定“Startup”类。 这样可以解决问题:

string url = "http://*:8080/";
SignalRServer = WebApp.Start<Startup>(url);

答案 1 :(得分:3)

这似乎解决了这个问题,虽然我不能告诉你原因......如果有人可以解释为什么这个问题解决了,请告诉我!

不再调用上面的启动类。用此替换了WebApp.Start(url)调用。

            string url = "http://*:8080/";
            StartOptions options = new StartOptions();
            options.Urls.Add(url);
            SignalRServer = WebApp.Start(options, builder =>
            {
                builder.UseCors(CorsOptions.AllowAll);
                builder.MapSignalR("/signalr", new HubConfiguration
                {
                    // You can enable JSONP by uncommenting line below.
                    // JSONP requests are insecure but some older browsers (and some
                    // versions of IE) require JSONP to work cross domain
                    EnableJSONP = false,

                    // Turns on sending detailed information to clients when errors occur, disable for production
                    EnableDetailedErrors = true,
                    EnableJavaScriptProxies = true
                });
                builder.RunSignalR();
            });