Assembly binding redirect not working

后端 未结 3 986
星月不相逢
星月不相逢 2021-02-19 10:12

I am trying to deploy a test web app on Azure, but when I run the Azure emulator on my local machine I get this error from the Azure emulator console attached to my WebRole:

相关标签:
3条回答
  • 2021-02-19 10:53

    In Azure WebRoles, by default (in Full IIS Mode) the RoleEntryPoint gets walled off from the rest of the WebRole, and runs in a different process.

    A side effect of this is that your RoleEntryPoint will not have access to your web.config.

    • Azure SDK 1.3 -1.7 will look in WaIISHost.exe.config

    • Azure SDK 1.8+ will look in the WebRoleProjectName.dll.config.

    With the newest change to the SDK, you should be able to place an app.config in your project and your role entry point should then have access to it.

    You can read more about this in this Microsoft blog post or in this Stackoverflow post

    0 讨论(0)
  • 2021-02-19 10:53

    As of today with the latest SDK a WebRoleProjectName.dll.config will be automatically generated for you with the contents of the Web.config and copied to the output directory.

    However this won't be automatically be included in the deployment package! For this to happen you have to employ a kind of hackish solution: include the generated file in the project by selecting "show all files", then including just this file. The resulting change in the csproj should look like this (not, don't select it to be "Copy always"!):

    <Content Include="bin\WebRoleProjectName.dll.config" />
    
    0 讨论(0)
  • 2021-02-19 10:55

    Thank you Rune for the precious hint. That didn't solve my problem but it pointed me to the right direction, because I have the latest version of Azure SDK (1.8) and this WaIISHost.exe.config trick no longer works on the latest version of Azure. HERE is stated what I just said and the solution that worked for me, which is to rename the WaIISHost.exe.config file to MyWebAppName.dll.config (placing it at the same level of your web.config file in your web app and setting its Copy to output Directory property to 'Copy Always'. Of course this config file contains the binding redirect section as I described above.

    0 讨论(0)
提交回复
热议问题