mvvmlight icon indicating copy to clipboard operation
mvvmlight copied to clipboard

Two different versions of ViewModelLocator?

Open abgenullt opened this issue 5 years ago • 1 comments

Hi,

I've noticed, that you provide two different versions of the ViewModelLocator class. In the project template of the Visual Studio extension, there is one with a static constructor. But if you add the mvvmlight nuget package to your project, a class with a public constructor will be created.

The problem with the nuget version is, that the designer may call the public constructor more than once, if you rebuild the project and that results in some "class already registered..." errors. So, you need to add a .reset() call at the beginning of the constructor to fix that. So, I personally prefer the static version.

Is there a reason for that inconsistency and which one is the "correct" one?

Regards, abgenullt

abgenullt avatar Jan 09 '19 13:01 abgenullt

@lbugnion I'd also love to know the answer to this question.

yannduran avatar May 22 '19 13:05 yannduran