Prism 2.2 and Expression Blend SDK Conflicts?

Topics: Prism v4 - WPF 4
Oct 23, 2010 at 5:02 PM

Hi all,

I am building WPF application with Prism 2.2 + one DLL from Expression Blend SDK System.Windows.Interactivity.dll.

In my bootstrap I have configured to load modules from same directory of EXE file

		protected override IModuleCatalog GetModuleCatalog() {
			var catalog = new DirectoryModuleCatalog() { ModulePath = @"./" };
			return catalog;
		}

In my satellite projects System.Windows.Interactivity.dll is referenced, thus this DLL is also copied to same directory of EXE and all modules.

When I run the application Prism 2.2 throws exception

System.TypeLoadException was unhandled
  Message=GenericArguments[0], 'System.Windows.FrameworkElement', on 'System.Windows.Interactivity.Behavior`1[T]' violates the constraint of type parameter 'T'.
  Source=mscorlib
  TypeName=""
  StackTrace:
       at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
       at System.Reflection.RuntimeAssembly.GetExportedTypes()
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.<>c__DisplayClass2b.<GetNotAllreadyLoadedModuleInfos>b__27(FileInfo file)
       at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(String path)
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.GetModuleInfos(String path)
       at Microsoft.Practices.Composite.Modularity.DirectoryModuleCatalog.InnerLoad()
       at Microsoft.Practices.Composite.Modularity.ModuleCatalog.Load()
       at Microsoft.Practices.Composite.Modularity.ModuleCatalog.Initialize()
       at Microsoft.Practices.Composite.Modularity.ModuleManager.Run()
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.InitializeModules()
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration)
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run()
       at HardySoft.Clinic.App..ctor() in D:\Projects\HardyTest\HardyTest.Shell\app.xaml.cs:line 15
       at HardySoft.Clinic.App.Main() in D:\Projects\HardyTest\HardyTest.Shell\obj\x86\Debug\App.g.cs:line 49
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

The file which throws exception is Prism 2.2\CAL\Desktop\Composite\Modularity\DirectoryModuleCatalog.Desktop.cs in function InnerLoad at line of

this.Items.AddRange(loader.GetModuleInfos(this.ModulePath)); 
Any clue how to solve the problem?
Thanks
Hardy
Oct 26, 2010 at 10:26 PM
Edited Oct 26, 2010 at 10:30 PM

Hi Hardy,

I checked this and found no issues when referencing the System.Windows.Interactivity assembly in a module using the DirectoryModuleCatalog class. So, I think that this might be related with the usage of System.Windows.Interactivity.Behavior<T> in your module.

Based on the message you are passing a non supported type in the creation of a behavior. Please, take into account that you must assign an type that derives from DependencyObject.

Hope this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero

Oct 27, 2010 at 12:48 AM

Hi Fernado,

I physically copyied System.Windows.Interactivity.dll to the same directory of my modules. I am not sure when you refer to "when referencing the System.Windows.Interactivity assembly", do you mean you reference to the GAC or local DLL?

Thanks

Hardy

Oct 28, 2010 at 3:10 PM

Hi Hardy,

I copied the System.Windows.Interactivity assembly in the same directory of the module and found no issues.

Please, take into account the following text from the MSDN documentation: The directory catalog will scan the contents of a directory, locating classes that implement IModule...

If you continue experiencing this in your scenario, could you share a repro sample? For example you could use Windows Live SkyDrive.

Fernando Antivero
http://blogs.southworks.net/fantivero

Aug 15, 2012 at 1:48 AM

Hi Hardy,

were you able to resolve this? I'm having the same issue with v 4.1 of Prism.

Initially using System.Windows.Interactivity.Behavior<TextBox> and even forced TextBox to DependencyObject but still getting the same error.

 

Thanks,

JP

Developer
Aug 15, 2012 at 9:04 PM
Edited Aug 15, 2012 at 9:05 PM

Hi,

So far, I couldn't reproduce the error mentioned in this thread, I tried defining a Behavior in a TextBox like you suggested, but didn't face any issues.

On the other hand, based on my understanding  in order to use interactions in Prism, you need to add a reference to the System.Windows.Interactivity assembly in both the Shell and the Module projects to avoid errors like this: "Could not load file or assembly 'System.Windows.Interactivity". Perhaps this could be related to your problem.

If this is not your case it would be helpful if you could provide us with more information about your scenario and the error you are receiving.

Regards,

Agustin Adami
http://blogs.southworks.net/aadami

Sep 17, 2012 at 3:28 AM

Hi,

I faced the same issues, This is because of there's a few version, I don't know when I got those a few version of "System.Windows.Interactivity"

Just change to new version then solved.