Azure search - Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'
See original GitHub issueWhen I try to use Azure Search on .NET Framework > 4.5.2, it blows up, throwing the above exception:
public SearchServiceClient Create()
{
return new SearchServiceClient(options.Value.ServiceName, new SearchCredentials(options.Value.SecurityKey));
}
System.TypeLoadException occurred
HResult=0x80131522
Message=Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility of the base type or be less accessible.
Source=<Cannot evaluate the exception source>
StackTrace:
at Microsoft.Rest.ServiceClient`1.CreateRootHandler()
at Microsoft.Azure.Search.SearchServiceClient..ctor(String searchServiceName, SearchCredentials credentials)
at Search.Index.Search.SearchClientFactory.Create() in C:\code\Search\solutions\service\Search.Index\Search\SearchClientFactory.cs:line 18
This code is in a class library compiled with .NET Framework 4.5.2. When the executable which includes the class library is also 4.5.2, the above code works. But if I upgrade the executable to 4.6 (or 4.6.1, 4.6.2, 4.7.1) then the code starts throwing the exception.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Inheritance sec rules violated by type: 'System.Net.Http. ...
Exception Details: "System.TypeLoadException: Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types ...
Read more >Inheritance security rules violated by type: 'System.Net.Http ...
Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility of the base type or ...
Read more >Inheritance security rules violated by type: 'System.Net.Http ...
TypeLoadException: Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility ...
Read more >Inheritance security rules violated by type
I got the following Error message. Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either ...
Read more >Inheritance security rules violated by type: 'System.Net.Http ...
Message: Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve spent the last couple of hours on this before raising the issue here - and I just figured out a workaround. I’ve added the NuGet package for System.Net.Http 4.3.3 to my class library which contains the above code - and now it works.
@mattfrear Thanks for confirming; I just found that issue yesterday. I’m hoping that fixing this will be a simple matter of ensuring that
Microsoft.Azure.Search
refers to the correct version of whatever dependency refers toSystem.Net.Http
. First I have to repro the issue though. I’m working on that today.