Tests failing under VS2010

Topics: Prism v2 - WPF 3.5
Oct 11, 2009 at 12:38 PM

Hi,

The following tests fail under VS2010 Beta 1 (only Desktop successfully imported):

  1. DifferentTargetTypeInFilterThrows
  2. DifferentTargetTypeInActionThrows
  3. ShouldLoadFilesEvenIfDynamicAssemblyExists
  4. ShouldNotThrowWithLoadFromByteAssemblies

Is there a .NET 4.0 compatible test solution?

Thanks in advance.

Oct 20, 2009 at 8:34 AM
Edited Oct 21, 2009 at 5:34 AM

Same issue with VS2010 Beta 2.

Surely there are others trying to use PRISM on .NET 4. Is there anyone else with this problem?

Currently these issues cause the module loading system to fail if you use the DirectoryModuleCatalog.

EDIT: Ok I've fixed up the tests. Here's how:

DifferentTargetTypeInFilterThrows: This is a covariance issue. In the test, change the Predicate<object> to Predicate<int>, or anything that string doesn't inherit from.

DifferentTargetTypeInActionThrows: Also a covariance issue. Change Action<object> to Action<int>.

ShouldLoadFilesEvenIfDynamicAssemblyExists and ShouldNotThrowWithLoadFromByteAssemblies: These two are the same issue, and are to do with the way dynamic assemblies are built. To fix, open the Composite.Modularity.DirectoryModuleCatalog class, go to the InnerLoad method, and change this:

                                 var assemblies = (
                                     from Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()
                                     where !(assembly is System.Reflection.Emit.AssemblyBuilder)
                                           && !String.IsNullOrEmpty(assembly.Location)
                                     select assembly.Location
                                 );

to this:

                                 var assemblies = (
                                     from Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()
                                     where !(assembly is System.Reflection.Emit.AssemblyBuilder)
                                           && assembly.GetType().FullName != "System.Reflection.Emit.InternalAssemblyBuilder"
                                           && !String.IsNullOrEmpty(assembly.Location)
                                     select assembly.Location
                                 );

Oct 25, 2009 at 9:09 PM

This is great stuff, confirmed to work (on VS2008 as well). Thanks a bunch!

Nov 9, 2009 at 3:14 PM

Hi

I have migrated Prism 2 to Visual Studio 2010 Beta 2 and fixed this and some other issues while doing it. You can read more about it (and download the updated version) here.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman