Type.GetType("System.ServiceModel.BasicHttpBinding" returns null

363 views Asked by At

I would like to know why do I need to pass AssemblyQualifiedName to create any instance of basic http binding. I saw same behavior with ServiceModel.EndPointAddress.

When I pass assembly name, it returns null

string binding = "System.ServiceModel.BasicHttpBinding"; Type.GetType(binding); // Returns null

If I pass AssemblyQualifiedName, it works fine.

string binding = "System.ServiceModel.BasicHttpBinding, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; Type.GetType(binding); returns object

1

There are 1 answers

0
asawyer On

That's what GetType is documented as using, unless the type is a core type, or is the current executing assembly.

http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx

Parameters

typeName

Type: System.String

The assembly-qualified name of the type to get. See AssemblyQualifiedName. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.