我需要以下绑定:
我的设置如下。
一个网站项目。引用该网站的云服务 Webrole。从 webrole 启动方法调用并启动 Owin 自托管服务的类库。
var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["CompositeServiceEndpoint"];
string baseUri = string.Format("{0}://{1}",
endpoint.Protocol, endpoint.IPEndpoint);
Trace.TraceInformation(String.Format("Starting OWIN at {0}", baseUri));
_app = WebApp.Start(new StartOptions(url: baseUri), (appbuilder) => new Startup().Configuration(appbuilder, CompositeWebRole.DependencyResolver));
这就是失败的原因,它尝试加载 4.0。
Plugin Initialization 'Composite.WindowsAzure.Management.Plugins.CompositeManagementPlugin': System.IO.FileLoadException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
我尝试在网站项目的 app.config 和 web.config 中添加程序集绑定。这不是我应该放文件的地方吗?
更新
我已经验证,登录到远程桌面, f:/approot/ 有 web.config 里面的绑定。
完整的错误是:
Plugin Initialization 'Composite.WindowsAzure.Management.Plugins.CompositeManagementPlugin': System.IO.FileLoadException: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Composite.WindowsAzure.Management.Startup.Configuration(IAppBuilder app, IWebroleDependencyResolver dpr)
at Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveApp(StartContext context)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at Composite.WindowsAzure.Management.Plugins.CompositeManagementPlugin.InitializePlugin()
at Composite.WindowsAzure.WebRole.Websites.WebsiteManager.InitializeManager()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
; TraceSource 'WaIISHost.exe' event
当我在模拟器中运行它时没有问题。