47

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.

atiyar
  • 7,762
  • 6
  • 34
  • 75
  • 3
    check out this question : http://stackoverflow.com/questions/13048879/vs2012-tfs2012-unit-test-major-issues – radu florescu Jan 30 '13 at 13:58
  • 1
    Do you have SP1 installed for VS2010 ? There were some known similar problems with unit tests after installing VS2012 and they were fixed in the SP. One of the reports here: http://bit.ly/11ewjJa – Adrian Fâciu Jan 30 '13 at 14:01
  • 1
    @AdrianFaciu: yes i have :( – atiyar Jan 30 '13 at 14:04
  • 1
    before installing VS2010 SP1, did you uninstall .net 4.5? looks like VS2010 SP1 is still using .Net 4.5 framework underneath – Anand Feb 07 '13 at 17:29
  • 1
    @Anand: please see the EDIT2 section – atiyar Feb 08 '13 at 23:35
  • recently we released windows update for .NET framework 4.5. Can you please install this update and let me know if this fixes the issue?http://support.microsoft.com/kb/2750149 for windows 8 and http://support.microsoft.com/kb/2750147 for Windows 7 platform. I am trying to narrow down the issue before involving someone from product team. Thanks for your quick response on this issue. If issue still persists post windows update... please email a small repro code on netfx45compat@microsoft.com – Anand Feb 09 '13 at 00:57
  • @Anand: I just installed the update you referred, but the issue is still not solved :( – atiyar Feb 09 '13 at 16:04
  • @NerotheZero I am from .NET Framework compatibility team. I would like to understand this better. can you email at netfx45compat at Microsoft dot com with sample project that reproduces the issue? Thanks – Varun Mar 26 '13 at 23:25
  • @Varun: Sure, I will, very soon – atiyar Mar 28 '13 at 09:40
  • Have you tried using [Visual Studio 2013 Community Edition](http://go.microsoft.com/fwlink/?LinkId=517284)? – Tim Hansson May 26 '15 at 07:03
  • was the project added as test project ? – Muds Sep 09 '15 at 16:17
  • The methods tested on their UnitTest are all public? – Guilherme Fidelis Oct 25 '15 at 12:52
  • Is UsersViewModel_Accessor and UsersViewModel your own class or from framework? – Daniel W. Nov 19 '18 at 10:24
  • Have you tried to Rebuild all solution after deleting all metadata files – Prashant Manjule Mar 28 '20 at 08:55

0 Answers0