Reputation: 9805
I get a resolve error when I try to inject into a FSharp library but not wen I do so with a CSharp library.
I have 3 projects :
Resolution of the dependency failed, type = "ModuleDBGraphFS.ModuleEntityGraphFS", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The current type, Microsoft.Practices.Unity.IUnityContainer, is an interface and cannot be constructed. Are you missing a type mapping?
At the time of the exception, the container was:
Resolving ModuleDBGraphFS.ModuleEntityGraphFS,(none) Resolving parameter "container" of constructor ModuleDBGraphFS.ModuleEntityGraphFS(Microsoft.Practices.Unity.IUnityContainer container, Microsoft.Practices.Prism.Regions.IRegionManager manager) Resolving Microsoft.Practices.Unity.IUnityContainer,(none)
Application class in the 1st project (WPF project, you add prism, remove the startupuri from app.xaml, add on the code behind for the bootstrapper )
namespace WpfApplication
{
class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return this.Container.Resolve<Shell>();
}
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)this.Shell;
App.Current.MainWindow.Show();
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;
// OK moduleCatalog.AddModule(typeof(ModuleDBGraph.ModuleEntityGraph));
// KO moduleCatalog.AddModule(typeof(ModuleDBGraphFS.ModuleEntityGraphFS));
}
}
}
In the C# project
public class ModuleEntityGraph : IModule
{
private IUnityContainer _container;
private readonly IRegionManager _manager;
public ModuleEntityGraph(IUnityContainer container, IRegionManager manager)
{
_container = container;
_manager = manager;
}
void IModule.Initialize()
{
}
}
in the F# project
type ModuleEntityGraphFS(container:IUnityContainer, manager:IRegionManager) =
do printfn "hi"
interface Microsoft.Practices.Prism.Modularity.IModule with
member x.Initialize() =
do ()
Upvotes: 3
Views: 847
Reputation: 9805
For some reason, the Nuget script for prism added reference in my module project to
C:\windows\assembly\GAC_MSIL\Microsoft.Practices.Unity\1.2.0.0__31bf3856ad364e35\Microsoft.Practices.Unity.dll
While the shell project itself was referencing
WpfApplication3\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll
A fresh solution that I started made me see the problem. Hence the odd message that it could not resolve UnityContainer itself (which should be registered somewhere by Prism Unity extensions....)
Upvotes: 0