Hi everybody.

I need to get the assembly in which a type reside.

Here the code I'm using:

Assembly asm = typeof(IChannel).Assembly;

But somehow, the result didn't refering to System.Runtime.Remoting.dll but it refers to mscorlib.dll instead.

Is it because the typeof(IChannel) returning a type of System.Type, so calling to typeof(IChannel).Assembly will return mscorlib.dll in which System.Type reside

Anybody knows what wrong here Do I miss something
Any solution if I want to obtain System.Runtime.Remoting.dll assembly

Thanks & regards,


Re: .NET Base Class Library Strange Type.Assembly behavior.

MS Johan Stenberg

If you look in the docs for IChannel, you'll see the following:

Namespace: System.Runtime.Remoting.Channels

Assembly: mscorlib (in mscorlib.dll)

There is not a 1:1 mapping between namespaces and assemblies.

Pick a type that is actually defined in the System.Runtime.Remoting assembly if you want typeof(the type).Assembly to return the System.Runtime.Remoting assembly Smile One example would be BinaryClientFormatterSink

Best regards,

Johan Stenberg

Re: .NET Base Class Library Strange Type.Assembly behavior.


Ah.. my fault then... Big Smile thanks