How to use Catel within an Addin application/ class library app? (remove app.xaml?)

Topics: Questions
May 1, 2013 at 2:04 PM
Dear all,
I am beginning with Catel MVVM framework, and I have trouble with the following use.

I would like to develop an add-in application, which means my main C# project is a class library.

Here is what I would like to do... but maybe it is not the standard way to use Catel framework...
  • Use Catel object model framework to store objects (as I need a lot of serialization to XML for instance)
  • Use ViewModels/Views to display windows, but these windows would be independent as they launch actions in the main app.
I see 2 solutions:
  1. Create a 2nd project with a Catel standard template. But I did not find a way to remove the starting point of the app, and launch my windows independently
  2. Implement Catel structure in the main class library app. In that case I need to remove the app.xaml file, and find another way to initialize everything and open the views independently.
Do you have an idea of the way to proceed with this request?
Thanks a lot
May 1, 2013 at 5:49 PM
This should be no problem for Catel. There is always an entry point for a module, but sometimes it's a bit hard. If you don't have an App instance that you can access, you can do a little trick.

If you don't need any other custom initialization, then you don't have to do anything because Catel already uses this technique internally. If you need custom initialization, you can use a little trick in .NET called Module Initialization. This is a hidden feature, but you can enable it using Fody and ModuleInit.Fody. This way, you will have an entry point where you can do your initialization code that you normally execute in the App class.
May 4, 2013 at 5:41 PM
Thanks for your reply.
In that case, I have trouble to define the initialization of the viewModelLocator.
How can I define this resource if I don't have any app.xaml ?

Thanks a lot
May 5, 2013 at 7:04 PM
That's the whole point. The ModuleInitializer will kick in as soon as your assembly is loaded (thus is a replacement of your app.xaml).