jeudi 23 juin 2016

How to get the name of the dll that a `Type` comes from while in a portable class library

In the process of porting a project to a Portable Class Library (PCL).

Previously, I have been able to get the Module of a Type directly in order to access the name of the DLL using...

private static bool isSystemType(Type service) {
    var moduleName = service.Module.Name.ToLower();//eg: system.dll
    //other code removed for brevity
}

System.Type.Module does not exist in the PCL project so it does not compile.

I've gone down the Type.Assembly.Fullname route but would prefer not having to parse the string just to get the name of the dll.

The PCL project targets

  • .Net Framework 4.5
  • Silverlight 5
  • Xamarin.Android
  • Xamarin.iOS
  • Xamarin.iOS (Classic)

Any other ways of getting the name of the dll that a Type comes from while in a portable class library with the above targets?





Aucun commentaire:

Enregistrer un commentaire