Using System.Web.Http.SelfHost.HttpSelfHostConfiguration with Web Api 2 (System.Web.Http ver 5.0) throws the following exception:
Unable to create instance of class xxxxxxxxxxxx. Error: System.TypeLoadException: Inheritance security rules violated by type: 'System.Web.Http.SelfHost.HttpSelfHostConfiguration'. Derived types must either match the security accessibility of the base type or be less accessible.
Note that these dlls use System.Web.Http ver 4.0 but I'm redirecting the binding to 5.0 and this is where it fails.
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
Comments: This is one of our known breaking changes. We removed the security attribute in V5, this causes this issue. http://www.asp.net/visual-studio/overview/2013/release-notes#knownissues There is no workaround other than upgrading all assemblies (including selfhost) to 5.0. We do not support 4.0 & 5.0 side by side. This is the same for all dependencies you are using, they all have to reference the 5.0 assemblies.
Unable to create instance of class xxxxxxxxxxxx. Error: System.TypeLoadException: Inheritance security rules violated by type: 'System.Web.Http.SelfHost.HttpSelfHostConfiguration'. Derived types must either match the security accessibility of the base type or be less accessible.
Note that these dlls use System.Web.Http ver 4.0 but I'm redirecting the binding to 5.0 and this is where it fails.
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
Comments: This is one of our known breaking changes. We removed the security attribute in V5, this causes this issue. http://www.asp.net/visual-studio/overview/2013/release-notes#knownissues There is no workaround other than upgrading all assemblies (including selfhost) to 5.0. We do not support 4.0 & 5.0 side by side. This is the same for all dependencies you are using, they all have to reference the 5.0 assemblies.