I'm not able to instantiate the viewmodel when the viewmodel dependencies spread across different projects.
The ViewModel constructor is as follows:
public MyViewModel(IMyBusinessLogic businessLogic)
{
...
}
public class App : Cirrious.MvvmCross.ViewModels.MvxApplication
{
public override void Initialize()
{
CreatableTypes().
EndingWith("BusinessLogic").
AsInterfaces().
RegisterAsLazySingleton();
RegisterAppStart<MyViewModel>();
}
}
IMyBusinessLogic is in different project of the same solution. The actual implementation of this interface is in a different project.
I have added business logic interface project as a reference in viewmodel project.
Can anyone help in resolving this issue?
The Error log:
mvx:Diagnostic: 0.12 Showing ViewModel MyViewModel 'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs{9E891FD9-C43E-4ED3-9EDC-153E29371D89}\Install\BusinessLogic.Interface.DLL'. Symbols loaded. mvx:Warning: 0.38 Problem creating viewModel of type MyViewModel - problem MvxIoCResolveException: Failed to resolve parameter for parameter myBusinessLogic of type IMyBusinessLogic when creating ViewModel.Core.MyViewModel at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.GetIoCParameterValues(Type type, ConstructorInfo firstConstructor) at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.IoCConstruct(Type type)
at Cirrious.CrossCore.Mvx.IocConstruct(Type t) at Cirrious.MvvmCross.ViewModels.MvxDefaultViewModelLocator.TryLoad(Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, IMvxViewModel& viewModel) 'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
@ Stuart: As it was mentioned in the wiki, i have override the method GetViewModelAssemblies() in the Setup.cs which exist in the platform specific UI project.
protected override Assembly[] GetViewModelAssemblies()
{
var list = new List<Assembly>();
list.AddRange(base.GetViewModelAssemblies());
list.Add(typeof(BusinessLogic.Core.MyBusinessLogic).Assembly);
list.Add(typeof(BusinessLogic.Interface.IMyBusinessLogic).Assembly);
return list.ToArray();
}
But now what i have observed is the sequence of call is first App.Initialize() and then Setup.GetViewModelAssemblies(). so again i'm seeing the same issue that it is not able to find the required type from IoC to craete the viewmodel. Any suggestion on this?