\r
private void DiscoverExportsAndImports()\r
{\r
- if (this._exports != null)\r
+ // NOTE : in most cases both of these will be null or not null at the same time\r
+ // the only situation when that is not the case is when there was a failure during the previous discovery\r
+ // and one of them ended up not being set. In that case we will force the discovery again so that the same exception is thrown.\r
+ if ((this._exports != null) && (this._imports != null))\r
{\r
return;\r
}\r
{\r
yield break;\r
}\r
-\r
+ \r
// Stopping at object instead of null to help with performance. It is a noticable performance\r
// gain (~5%) if we don't have to try and pull the attributes we know don't exist on object.\r
- while (currentType != CompositionServices.ObjectType)\r
+ // We also need the null check in case we're passed a type that doesn't live in the runtime context.\r
+ while (currentType != null && currentType != CompositionServices.ObjectType)\r
{\r
if (IsInheritedExport(currentType))\r
{\r
\r
// Stopping at object instead of null to help with performance. It is a noticable performance\r
// gain (~5%) if we don't have to try and pull the attributes we know don't exist on object.\r
- while (baseType != CompositionServices.ObjectType)\r
+ // We also need the null check in case we're passed a type that doesn't live in the runtime context.\r
+ while (baseType != null && baseType != CompositionServices.ObjectType)\r
{\r
foreach (MemberInfo member in GetDeclaredOnlyImportMembers(baseType))\r
{\r