Reputation: 42185
I'm developing an application in WPF and I want to know how to begin configuring StructureMap. I'm coming from an MVC background where I would normally configure StructureMap in Global.asax.
The following article suggests that I put the configuration in the main()
method
http://structuremap.net/structuremap/ConfiguringStructureMap.htm
but in WPF the main()
method is located in App.g.i.cs
and states
This code was generated by a tool & Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
In WPF there doesn't seem to be a suitable equivalent of Global.asax, so where should the configuration go?
Upvotes: 2
Views: 1675
Reputation: 3227
Use App.xaml.cs for that.
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
//Do your stuff here
}
}
Upvotes: 3