This project has moved and is read-only. For the latest updates, please go here.

MVVM SimpleIOC Expression Blend can't create instance of ViewModelLocator

May 18, 2015 at 1:26 PM
Hello, Laurent

This is a duplicate post from StackOverflow.

I've a trouble with setting up a design data with SimpleIOC.

I'm using a System.Net.Http.HttpClient class.

By registering it: SimpleIoc.Default.Register<HttpClient>(); I'm receiving a error message form MVVMlight about multiple constructors. So I've searched for a workaround:

SimpleIoc.Default.Register<HttpClient>(()=>new HttpClient());

It's working in runtime but not in design mode. I'm receiving a error about already registered factory methods. And finally a message:
A first chance exception of type 'Microsoft.Expression.Platform.InstanceBuilders.InstanceBuilderException' occurred in Microsoft.Expression.Platform.DLL

Additional information: Cannot create an instance of "ViewModelLocator".
Is there any workaround?

Made things working by making the ViewModelLocator constructor static. I don't know if it is a right thing to do.

Thank you for your time.