I have a WPF solution in .NET 4.0 that includes a Unit Test project which tests the different commands used in the ViewModels. Everything was working fine, but then I installed .NET 4.5 and VS2012.
Now when I try to build the solution I get error messages, like -
SomeProject.UsersViewModel_Accessor.AddUserToAccountsCommand' is not supported by the language
I have noticed and tried the following -
1. Reference of UnitTestFramework.dll
:
Before installing VS2012, the UnitTestFramework.dll
was referenced from -
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\
which is now changed to be referenced from -
C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v4.0
So, it is now taking the reference from within VS2012 directory. I manually restored that reference to previous state. But no luck.
2. Assembly of ICommand
:
The AddUserToAccountsCommand
is an ICommand
object and in .NET 4.0 it resides in PresentationCore.dll
. In .NET 4.5, however, it is in System.dll
. So I checked those references too, but they seems OK, as they were previously.
3. Instantiation of Test Target :
The error message displays only where the test target is created as an Accessor, like UsersViewModel_Accessor
, but not when instantiated directly. That means while the following code generates error -
UsersViewModel_Accessor target = new UsersViewModel_Accessor();
Assert.IsTrue(target.AddUserToAccountsCommand.CanExecute(null), "Failed to perform can exetuce of add user command");
target.AddUserToAccountsCommand.Execute(null);
the following code does not -
UsersViewModel target = new UsersViewModel();
Assert.IsTrue(target.AddUserToAccountsCommand.CanExecute(null), "Failed to perform can exetuce of add user command");
target.AddUserToAccountsCommand.Execute(null);
So, can anyone share any thought about what exactly is the cause of this issue, and how to solve it?
EDIT :
After started getting the error I also installed VS2010 SP1. Still no luck.
EDIT-2 :
On the same machine I need to use VS2012 too for other projects. So it won't be a solution to uninstall .NET 4.5/VS2012.
Just to check, I took the solution on a different machine, installed .NET 4.5 only, and not VS2012, and tried to build. But same story. So, the issue is not related to VS2012, it's something that's conflicting between .NET 4.0 and .NET 4.5. To Reflect this I'll change the Title of the question.