RIA Services XMLMetaDataProvider and Dynamic Assemblies

If you are using the XMLMetaDataProvider and have a dynamic assembly reference your service might fail with the following error:

           The invoked member is not supported in a dynamic assembly

There are two fixes for this problem, one is to use the full attribute names.  So ‘DisplayAttribute’ instead of just ‘Display’.  Second option is to fix the code in MetadataSet.cs.  The problem is with the TryGetType method around line 421.  You should be able to find the code below, the GetExportedTypes needs to be changed to GetTypes. 

   1: // TODO : the metadata file might need a way to specify the set
   2: // of source assemblies to load from - for now search all loaded assemblies
   3: foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
   4: {
   5:     foreach (Type t in assembly.GetTypes())
   6:     {
   7:         if (t.Name == typeName || t.FullName == typeName)
   8:         {
   9:             typeMap[typeName] = t;
  10:             return t;
  11:         }
  12:     }
  13: }


Thanks to Manfred Lange for the tip on the error message.