Questions related to the SimpleIoc Class in C#
Questions tagged [simpleioc]
14 questions
4
votes
2 answers
Mvvm - How to get the instance key in SimpleIoC
I'am using mvvm light SimpleIoC in a Xamarin project and use an instance key to get some view model.
SimpleIoc.Default.GetInstance("contextIdentifier");
Is there a way to get this instance key in the instance itself like other…

j-guyon
- 1,822
- 1
- 19
- 31
1
vote
3 answers
Mvvm light SimpleIoC in usercontrol
I hope someone can shine some light on best practise for my usecase.
I am using mvvm light and the simpleIoC container in a wpf usercontrol. I register my model and view models, dataservice and designtime service to it (very much according to mvvm…

Johan
- 502
- 4
- 18
1
vote
1 answer
MVVM-Light SimpleIoc: Can't create multiple instances dynamically
I am building an WPF application using the MVVM Light Toolkit and specifically SimpleIoc.
I have a parent viewmodel that dynamically creates child viewmodels. When doing this I am using "standard" dependency injection to pass a IConfigService as a…

user3283677
- 11
- 3
1
vote
0 answers
Exception thrown while trying to use SimpleIOC as a ServiceLocator
My app installs on a native Win10 PC and is able to run with on issues.
However, when a user installs the app on a Win7/Win10 VM, the they encounter a crash with the following stack trace:
System.Reflection.TargetInvocationException: Exception has…
1
vote
1 answer
what happened when MVVMLight SimpleIoc registered multiple times?
I'd like to know when .Register() is performed multiple times. Based on my experiment, below Console.WriteLine gives same Init value.
So, does .Register() check already registered instance and ignore to re-register?
void Main()
{
// #1
…

Youngjae
- 24,352
- 18
- 113
- 198
1
vote
0 answers
SimpleIOC and generics
I'm trying to generalize some code so that it can be used between projects, but I'm having some trouble generating instances from templated classes.
public class GenericRepository : IGenericRepository, IDisposable
…

Keith G
- 4,580
- 5
- 38
- 48
0
votes
1 answer
How to add array to the paramter with SimpleIoc in the MVVM Light?
I using MVVM light library in my project.
I trying to add an array to the constructor of the ViewModel.
For example... if the code below is
public MainViewModel(ToolWindowViewModel[] toolItems)
{
// to do
}
I would like to know a way that…

jjw
- 282
- 3
- 20
0
votes
1 answer
MVVMCross SimpleIoc: how to Ungegister all service instances
I want to unregister all service instances of SimpleIoC.
CODE
public class IoCRegistry
{
private List RegistryList = new List();
public void Register() where TInterface : class where TClass :…

TheDeveloper
- 1,127
- 1
- 18
- 55
0
votes
1 answer
WPF MVVM How to create new Window instance with no input data
In WPF (MVVM) when I create new instance of window (view) it has no entry data - but when I enter some data, close window and reopen it contains the same data as window was closed with. How to provide "fresh" window (with blank fields which need to…

Tomasz Strączek
- 91
- 8
0
votes
1 answer
Type not found in cache: System.Func for injecting a type as a Func using MVVMLight SimpleIoc
I am registering a type in MVVMLight SimpleIoc,
SimpleIoc.Default.Register();
Then I do a constructor injection of this type as a Func,
public class MyConsumerClass
{
readonly Func _injectingClassFactory;
…

Rizan Zaky
- 4,230
- 3
- 25
- 39
0
votes
1 answer
MVVM Light SimpleIoC can't find instance
I'm using WPF MVVM Light SimpleIoC to implement access to my services. I don't have any problems with registering and using my VM but when I register a service, I can't use It.
There is my code:
public interface IDeviceDataAccessService
{
…

Redzix
- 170
- 3
- 15
0
votes
0 answers
Wpf Mvvm: ObservableCollection of ChildViewModels and Dependency Injection
I am a WPF application beginner and I'm currently using MvvmLight for my application.
I have a MainViewModel that holds a ObservableCollection of ChildViewModels(Type ViewModelBase). Each ChildViewModel is bound to a tab item in the XAML. So, I have…

Vini
- 13
- 4
0
votes
1 answer
SimpleIOC with MVVMlight register and use
Hi i try to register my class into serviceLocator and reuse it my code is:
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
SimpleIoc.Default.Register(true);
…

C.Fasolin
- 313
- 1
- 4
- 19
0
votes
1 answer
mvvm light simpleIoc constructor injection
i want to inject a list to my viewmodel constructor with the ServiceLocator
my viewmodel:
public class ShowEmployeeViewModel: ViewModelBase
{
private IList _empl;
public ShowEmployeeViewModel(IList emp)
{
…

Arh Hokagi
- 170
- 5
- 21