Including another assembly (dll) in a project.

Aug 12, 2011 at 2:22 AM

I’m working on a project where I am placing all my Business Modules into separate assemblies.

When I tried to activate a WorkspaceData object that resided in my business Module assembly the follow error message appeared – “A fatal error occurred ViewResolver could not CreateView using Key <keyname>”

I figured this meant I had to change some code on the OnStartup method in the App.xaml.cs file, so I changed the line:

CinchBootStrapper.Initialise(new List<Assembly> { typeof(App).Assembly });

 To

List<Assembly> assemblyList = new List<Assembly> { typeof(App).Assembly, Assembly.LoadFrom("assemblyName.dll") };

CinchBootStrapper.Initialise(assemblyList);

 I could not find this solution documented anywhere so I thought I would post it here for reference and also to ensure what I’d done was correct.

 If there is a better way – please advise?

__Allan

Coordinator
Aug 12, 2011 at 8:32 AM
Edited Aug 12, 2011 at 8:37 AM

No that is a good way to solve it. Or once you have loaded you business Module assembly, and you know the types you can register things manually with the ViewResolver like

 

ViewResolver.Register("SomeView", typeof(SomeView)

But the way you have done it is fine, and will carry out the registration automatically for you using the ViewnameToViewLookupKeyMetadataAttribute that you have used on your Views in the business Module assembly

At some point I should do away with the boostrapper all together and just use MEF to find the correct types based on some new custom MEF attribute, but that will not happen right now, as I am pretty busy of late.

Sounds like you have it all working anyway, and the way you did it is correct.


BY the way if you are doing Modules I would strongly recommend using PRISM and Cinch together, as I discuss here : http://www.codeproject.com/KB/WPF/CinchV2AndPRISM4.aspx