[Windows Phone]System.TypeAccessException: Attempt by security transparent method ‘HtmlAgilityPack.HtmlWeb.LoadFromWebAsync(System.Uri, System.Text.Encoding, and so on…

Today I decided to port my existing Windows Store 8.1 App to Windows Phone, so I added windows phone support, moved a few classes to shared project, and started coding.

Unfortunately, everytime I try to call any HTMLAgilityPack-related function, the app throws an error:

+ $exception {System.TypeAccessException: Attempt by security transparent method 'HtmlAgilityPack.HtmlWeb.LoadFromWebAsync(System.Uri, System.Text.Encoding, System.Net.NetworkCredential)' to access security critical type 'System.Net.NetworkCredential' failed. at HtmlAgilityPack.HtmlWeb.LoadFromWebAsync(Uri uri, Encoding encoding, NetworkCredential credentials) at HtmlAgilityPack.HtmlWeb.<LoadFromWebAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was

And basically, the stack goes forever like this.

I found out that it's ccaused by some kind of security checks, and that I can disable it by removing the attribute from AssemblyInfo.cs file, but unfortunately I don't have this attribute to begin with. Any ideas? Anyone had similar issues?

by MrReynevan2 via /r/csharp

Leave a Reply