MEF issue : AssemblyCatalog throws exception when MSAF assemblies are referenced

Nov 14, 2011 at 8:44 AM

Hi,

I'm trying to use both the SMF library (latest) and Microsoft's Silverlight Analytics Framework (latest). They both use MEF for their plug-in architecture and it seems this is somehow causing an issue.

When referencing SMF libraries only, the projet launches fine and videos can be played. However, as soon as I try to reference assemblies from MSAF, I'm trying to use the Google Analytics implementation, an ReflectionTypeLoadException exception is thrown in SMF's AssemblyCatalog class, more specifically the InnerCatalog property.

Here is the stack trace of the exception.

   at System.Reflection.Module.GetTypes()   at System.Reflection.Assembly.GetTypes()   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_Parts()   at System.ComponentModel.Composition.Hosting.AggregateCatalog.<.ctor>b__0(ComposablePartCatalog catalog)   at System.Linq.Enumerable.<SelectManyIterator>d__1a`2.MoveNext()   at System.Linq.Enumerable.<SelectManyIterator>d__1a`2.MoveNext()   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)   at System.ComponentModel.Composition.Hosting.DeploymentCatalog..ctor()   at Microsoft.SilverlightMediaFramework.Core.PluginsManager.InitializeCompositionContainer()   at Microsoft.SilverlightMediaFramework.Core.PluginsManager..ctor()   at Microsoft.SilverlightMediaFramework.Core.SMFPlayer..ctor()   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)   at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)   at MS.Internal.TypeProxy.<>c__DisplayClass30.<GetCreateObjectDelegate>b__2a()   at MS.Internal.TypeProxy.CreateInstance(UInt32 customTypeId)   at MS.Internal.XamlManagedRuntimeRPInvokes.CreateInstance(XamlTypeToken inXamlType, XamlQualifiedObject& newObject)   at MS.Internal.XcpImports.Application_LoadComponentNative(IntPtr pContext, IntPtr pComponent, UInt32 cUriStringLength, String uriString, UInt32 cXamlStrLength, Byte* pXamlStr, UInt32 cAssemblyStrLength, String assemblyStr)   at MS.Internal.XcpImports.Application_LoadComponent(IManagedPeerBase componentAsDO, String resourceLocator, UnmanagedMemoryStream stream, UInt32 numBytesToRead, String assemblyString)   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)   at Redacted.InitializeComponent()   at Redacted..ctor()   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)   at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)   at System.Activator.CreateInstance(Type type)   at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)   at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)   at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)   at System.Delegate.DynamicInvokeOne(Object[] args)   at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)   at System.Delegate.DynamicInvoke(Object[] args)   at System.Windows.Threading.DispatcherOperation.Invoke()   at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)   at System.Windows.Threading.Dispatcher.OnInvoke(Object context)   at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)   at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)   at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

This causes the assembly catalog to not be initialized correctly, therefore videos cannot play anymore because the plugins are not referenced.

Would anybody have an idea about what could cause this issue and how to fix it ?

 

Thanks,

Guillem

Jan 5 at 7:06 AM