Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
FileLoadException在Azure Worker角色上托管具有F的信号器时发生_Azure_F#_Signalr_Owin - Fatal编程技术网

FileLoadException在Azure Worker角色上托管具有F的信号器时发生

FileLoadException在Azure Worker角色上托管具有F的信号器时发生,azure,f#,signalr,owin,Azure,F#,Signalr,Owin,我正在尝试以Windows Azure Worker角色运行SignalR自主机服务器,但继续获取 System.IO.FileLoadException:无法加载文件或程序集 'Microsoft.Owin,版本=2.0.0.0,区域性=中性, PublicKeyToken=31bf3856ad364e35'或其依赖项之一。这个 定位程序集的清单定义与程序集不匹配 参考来自HRESULT的异常:0x8013100 当我在控制台应用程序中运行相同的代码时,它运行良好,一切正常。整个worker角

我正在尝试以Windows Azure Worker角色运行SignalR自主机服务器,但继续获取

System.IO.FileLoadException:无法加载文件或程序集 'Microsoft.Owin,版本=2.0.0.0,区域性=中性, PublicKeyToken=31bf3856ad364e35'或其依赖项之一。这个 定位程序集的清单定义与程序集不匹配 参考来自HRESULT的异常:0x8013100

当我在控制台应用程序中运行相同的代码时,它运行良好,一切正常。整个worker角色是用F编写的。下面是生成我所说的异常的最短代码:

override wr.Run() =
    let x : IAppBuilder = null

    x.MapSignalR() |> ignore // this line throws the FileLoadException
当然,上面的代码不应该工作,但有不同的例外。通常我在启动类WebApp.Starturl的配置方法中调用MapSignalR

我粘贴的异常详细信息来自ComputeEmulator,但我在live Cloud服务中得到了同样的信息


您知道问题的原因吗?或者我如何进一步诊断它?

这是Nuget的已知问题:请参阅。绑定重定向不会自动为工作角色项目添加。此失败的原因是生成的信号器二进制文件依赖于Microsoft.Owin 2.0.0版。但是公共提要中的Microsoft.Owin的最新可用版本是2.0.2。要解决此程序集绑定问题,当您在控制台应用程序或web应用程序上安装相同的Signal程序包时,您将在app.config中看到为您自动添加的程序集绑定重定向。由于Nuget client存在问题,在工作者角色项目中不会发生这种情况。若要解决此问题,请将其添加到worker角色项目的app.config,或者尝试将您的signalR包添加到控制台应用,并从其app.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.0.2.0" newVersion="2.0.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

如果接受的答案不适用于您,请在package manager控制台中发出以下2个命令:

update-package Microsoft.Owin -version 2.x.x
update-package Microsoft.Owin.Security -version 2.x.x
其中2.x.x是异常抱怨的版本

对我来说,版本号是2.0.1

之后,确保应用程序的配置文件配置部分中包含以下内容:


添加上面的绑定并没有解决我的问题。我必须手动编辑.csproj文件

“右键单击”项目并选择“卸载项目”,然后“右键单击”项目并单击“编辑”

从那时起,我必须清理Owin程序集的节点。我的Owin程序集未从相对NuGet packages目录加载,因此正在加载2.0.0

之前:

之后:

最后,“右键单击”项目并选择“重新加载项目”。 打开项目的“引用”,并验证它正在从系统上的正确位置加载正确的版本。
谢谢!这就成功了。。我还必须手动将所需的nuget软件包signalr.selfhost等安装到WorkerRole项目中,即使它们被WorkerRole项目引用的另一个库使用。这里有一个更完整的答案:最好使用nuget package manager来更新Microsoft.Owin.*设置,这样您也可以获得更新的二进制文件:
<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.0.1.0" newVersion="2.x.x.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.x.x.0" />
  </dependentAssembly>
</assemblyBinding>
</runtime>
-    <Reference Include="Microsoft.Owin">
-      <HintPath>..\packages\Microsoft.Owin.2.0.0\lib\net45\Microsoft.Owin.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Owin.Host.SystemWeb">
-      <HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.2.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Owin.Security">
-      <HintPath>..\packages\Microsoft.Owin.Security.2.0.0\lib\net45\Microsoft.Owin.Security.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Owin.Security.Facebook">
-      <HintPath>..\packages\Microsoft.Owin.Security.Facebook.2.0.0\lib\net45\Microsoft.Owin.Security.Facebook.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Owin.Security.Cookies">
-      <HintPath>..\packages\Microsoft.Owin.Security.Cookies.2.0.0\lib\net45\Microsoft.Owin.Security.Cookies.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Owin.Security.OAuth">
-      <HintPath>..\packages\Microsoft.Owin.Security.OAuth.2.0.0\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>
-    </Reference>
+    <Reference Include="Microsoft.AspNet.Identity.Owin">
+      <HintPath>..\packages\Microsoft.AspNet.Identity.Owin.1.0.0\lib\net45\Microsoft.AspNet.Identity.Owin.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Owin.Security, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Owin.Security.2.0.2\lib\net45\Microsoft.Owin.Security.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Owin.Security.Cookies, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Owin.Security.Cookies.2.0.2\lib\net45\Microsoft.Owin.Security.Cookies.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Owin.Security.OAuth, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Owin.Security.OAuth.2.0.2\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Owin.Host.SystemWeb, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.2.0.2\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
+    </Reference>