Wow, so this error has got me stomped. I am using this with xamarin. It has worked for some time now and I am not sure if this is a xamarin issue or not. The code that is the issue has been the same since I created the app. Just trying to get some ideas on what is going on. I just do not know. Any information or ideas you guys might have on it would be awesome. I also sent a email to xamarin. If I get any information on it I will update this issue.
This is in a Xamarin.iOS project.
So here is the deal. I am using SimpleIoC from the MVVMLight libraries to inject all my classes using the register on the SimpleIoC. In my App.xaml.cs file I register all of my IoC stuffs. Here is the issue. When I compile the app on my physical phone I get a exception that is below:
"Microsoft.Practices.ServiceLocation.ActivationException: Cannot register: No public constructor found in ModuleRegistryService."
This exception takes place on this line of code:
SimpleIoc.Default.Register<ModuleRegistryService>();
If I change this line of code to this it works fine (With the notable issue of not being about to resolve the other dependencies with this method.):
SimpleIoc.Default.Register(()=>new ModuleRegistryService());
Here is the code for the public constructor on the ModuleRegisteryService:
/// <summary>
/// Creates a new Registry Service for use within the app.
/// </summary>
public ModuleRegistryService()
{
modules = new List<IModule>();
mainMenuItems = new ObservableCollection<IMainMenuItemsViewModel>();
}
Well here is the kicker that has got me completely stomped on this one. If I run this same code above on the simulator it runs fine. So what I am thinking is for some reason when it is complied against the phone it is for some reason making my constructors private and/or hiding it???? I just do not get it. Any ideas on this one?
Thanks,
Bob
Comments: Can you try adding the [Preserve] attribute on your default constructor in the VM, and see if it solves the issue?
This is in a Xamarin.iOS project.
So here is the deal. I am using SimpleIoC from the MVVMLight libraries to inject all my classes using the register on the SimpleIoC. In my App.xaml.cs file I register all of my IoC stuffs. Here is the issue. When I compile the app on my physical phone I get a exception that is below:
"Microsoft.Practices.ServiceLocation.ActivationException: Cannot register: No public constructor found in ModuleRegistryService."
This exception takes place on this line of code:
SimpleIoc.Default.Register<ModuleRegistryService>();
If I change this line of code to this it works fine (With the notable issue of not being about to resolve the other dependencies with this method.):
SimpleIoc.Default.Register(()=>new ModuleRegistryService());
Here is the code for the public constructor on the ModuleRegisteryService:
/// <summary>
/// Creates a new Registry Service for use within the app.
/// </summary>
public ModuleRegistryService()
{
modules = new List<IModule>();
mainMenuItems = new ObservableCollection<IMainMenuItemsViewModel>();
}
Well here is the kicker that has got me completely stomped on this one. If I run this same code above on the simulator it runs fine. So what I am thinking is for some reason when it is complied against the phone it is for some reason making my constructors private and/or hiding it???? I just do not get it. Any ideas on this one?
Thanks,
Bob
Comments: Can you try adding the [Preserve] attribute on your default constructor in the VM, and see if it solves the issue?