samedi 23 novembre 2019

Type.GetType("System.Net.WebException") returns null

I'm trying to get a type reference to System.Net.WebException from its name by doing the following:

var t = Type.GetType("System.Net.WebException");

t is null which I don't understand why. My project is a class library targeting .NET 4.6.1. I am referencing System and also tried referencing System.Net and System.Web without any luck.

The following compiles and returns the correct type:

var t = typeof(System.Net.WebException);

But I need the string version to work here. I also tried this:

var t = Type.GetType("System.Net.WebException, System");

Returns null as well.

Any ideas?





Aucun commentaire:

Enregistrer un commentaire