將我的asp.net webform網站從Owin 2.1.0升級到Owin 3.0.1後,我有前面提到的編譯錯誤...我正在嘗試使用SignalR 2和CORS。這裏是我的packages.config:OWinStartup,OWinStartupAttribute not found&'Owin.IAppBuilder'沒有包含'Map'的定義
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="jQuery" version="2.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.JS" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Cors" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
我OwinStartup類是在web.config中定義中的AppSettings如下:
<add key="owin:AppStartup" value="SignalRStartup, App_Code" />
這是什麼類的樣子:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Owin;
using Microsoft.Owin;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Cors;
using System.IO;
[assembly: OwinStartup(typeof(SignalRStartup))]
public class SignalRStartup
{
public void Configuration(IAppBuilder app)
{
// Enable detailed errors (remember to remove it
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
//hubConfiguration.EnableCrossDomain = true;
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(hubConfiguration);
}
}
另請注意,我不能使用app.Map("/signalr", map => { ... });
...
編輯: 我在web.config中找到這些行,我沒升級前有:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
我快要放棄的時候,請如果您有任何想法...
會發生什麼,如果你刪除從配置文件啓動屬性。我不認爲你需要這個,如果你也使用程序集屬性 – 2015-03-03 12:14:47
這是相同的,編譯時,它掛在'OWinStartup'找不到(你是否缺少using指令... – junta 2015-03-03 12:21:11