TypeLoadException looking for Microsoft.Practices.ServiceLocation

May 5, 2011 at 4:32 PM
Edited May 5, 2011 at 5:00 PM

When I'm using MEFedMVVM in junction with MvvMLight Extras DLL (BL16 build) I'm getting a TypeLoadException looking for Microsoft.Practices.ServiceLocation and that DLL can't be added to an SL4 project.

I've cross posted this, since I guess it's more of a MEFedMVVM issue. But I want to see, if there are any ideas from MvvmLight's perspective.

http://mefedmvvm.codeplex.com/discussions/256505

Update: Curiously, in BL15 it works. So it must be something that BL16 does differently.

Coordinator
May 9, 2011 at 2:24 PM

Hi,

This DLL has been added in V4 BL16, and is needed because of the SimpleIoc container that has been added to this version. In BL15, the SimpleIoc was not there yet, so the reference was not needed.

As you found out, this DLL is only needed when the Extras are referenced.

I made multiple versions of this DLL available, one for each supported framework in MVVM Light, including SL4. This DLL should be safe for an SL4 project.

If you don't get it to work, can you describe to me exactly when the error happens? Is it when MEF tries to load the assemblies?

Thanks,

Laurent

May 9, 2011 at 9:15 PM
Laurent,

The error happens when MEFedMVVM tries to attach the ViewModel to the View. More specifically at the function below, when GetExports function is executed.


        protected override IEnumerable<Export> GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
        {
	    var exports = _exportProvider.GetExports(definition, atomicComposition);
            return exports.Select(export => new Export(export.Definition, () => GetValue(export)));
        }

ReflectionTypeLoadException:
{System.Reflection.ReflectionTypeLoadException: [ReflectionTypeLoad_LoadFailed]

Loader Exception:
{System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b09c1d25ac742833' or one of its dependencies. The system cannot find the file specified.
[IO.FileName_Name]
Arguments: Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b09c1d25ac742833

Stack trace:
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_Parts()
at lambda_method(Closure , ComposablePartCatalog )
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.ComponentModel.Composition.Primitives.ComposablePartCatalog.GetExports(ImportDefinition definition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at MEFedMVVM.ViewModelLocator.MEFedMVVMExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)

When I roll back the extras DLL to BL15 problem goes away. This is my work around for the time being.

Best,

Doguhan

On Mon, May 9, 2011 at 9:24 AM, lbugnion <notifications@codeplex.com> wrote:

From: lbugnion

Hi,

This DLL has been added in V4 BL16, and is needed because of the SimpleIoc container that has been added to this version. In BL15, the SimpleIoc was not there yet, so the reference was not needed.

As you found out, this DLL is only needed when the Extras are referenced.

I made multiple versions of this DLL available, one for each supported framework in MVVM Light, including SL4. This DLL should be safe for an SL4 project.

If you don't get it to work, can you describe to me exactly when the error happens? Is it when MEF tries to load the assemblies?

Thanks,

Laurent

Read the full discussion online.

To add a post to this discussion, reply to this email (mvvmlight@discussions.codeplex.com)

To start a new discussion for this project, email mvvmlight@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com




--
Doguhan Uluca