Home Dashboard Directory Help
Search

Even after installing VS2010 SP1, unit tests targeting 3.5 framework fail if they are using private accessor by avinash.kumar.vaidhya


Status: 

Closed
 as Fixed Help for as Fixed


9
0
Sign in
to vote
Type: Bug
ID: 677203
Opened: 6/28/2011 1:16:39 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
2
Workaround(s)
view
6
User(s) can reproduce this bug

Description

Unit tests targeting framework 3.5 fail if they are using private accessor. The "xxxxLib.accessor" file is generated
    (a) At path: "\Test References\ xxxxLib.accessor".
    (b) Contains: just two lines
         1.    LibraryName.dll
         2.    Desktop

I guess they (or any dependency of them) are compiled using a framework version < 3.5.
Details
Sign in to post a comment.
Posted by JamnC on 6/14/2012 at 9:44 AM
I am still having this issue with the latest updates to Visual Studio 2010 SP1.

I switched the test project to .NET 3.5, regenerated the accessor dlls and still received this error.

When I switch back to .NET 4.0 it runs correctly.
Posted by Kerray on 4/23/2012 at 4:11 AM
I'm trying to unit test using accessor classes in a SharePoint 2010 project.

I have Visual Studio with latest patches.

Despite switching the test project to target .NET 3.5, the generated accessor dlls are for .NET 4 - and unusable.

If this is solved, how do I change also the accessor dlls to 3.5 without a workaround through VS2008 please?
Posted by forty7 on 4/10/2012 at 7:53 AM
This is marked "Fixed" but I see no indication of which release or patch fixes the issue.
Posted by kiroc on 9/6/2011 at 1:19 PM
This fails with me as well. I have VS 2010 SP1. It seems to fail only when I use resource files. I can build and use a test project with private accessors that targets the 3.5 framework. But, when I add a default resources file, the build breaks with a BadImageFormatException similar to the others mentioned here. It seems this is fixed in TFS 2010 TeamBuild (see adamroot's response to the question about VS 2010 RTM):

http://blogs.msdn.com/b/adamroot/archive/2009/12/10/building-vs-2008-unit-test-projects-in-msbuild-4-0-beta-2.aspx#10004576

Could we get the TeamBuild targets file that (Microsoft.TeamTest.OverrideTasks) that would fix our local builds? It is not possible for some of us to move the test project to the 4.0 framework. In my case, we are using a 3rd party library that doesn't support the 4.0 framework.
Posted by PeteA on 7/6/2011 at 10:32 AM
I am using VS 2010 SP1. I opened a project created by VS 2010 prior to SP1 and was seeing the issue of previously working tests failing with "System.BadImageFormatException: Could not load file or assembly 'ActiveDirectoryUCMPersonalizationConnector_Accessor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."
Posted by MS-Moderator07 [Feedback Moderator] on 6/29/2011 at 10:37 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by avinash.kumar.vaidhya on 6/29/2011 at 6:35 AM
sorry, I think , I have attached the same zip two three times by mistake.
Please remove duplicate attachment if possible or else I will do it, if it is allowed.

Thanks,
avinash
Posted by avinash.kumar.vaidhya on 6/29/2011 at 6:30 AM
I tried to add "ConsoleApp.Zip". But it is not showing up in details Attached file section.
I hope it has been submitted & attached.
Posted by MS-Moderator07 on 6/28/2011 at 2:01 AM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by MS-Moderator01 on 6/28/2011 at 1:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by PeteA on 7/6/2011 at 10:35 AM
I was able to work around this issue by changing the target framework for the test project to fx4. After regenerating the private accessor, the test worked as expected. Changing back to 3.5 (and regenerating the accessor) caused it to fail; changing back to 4 worked around the problem. I'd say the accessor is being generated as a fx4 assembly even though the target framework of the project being tested is 3.5.
Posted by Rick Sladkey on 6/28/2011 at 6:45 PM
The workaround I chose was to manually generate the private accessor assembly using Visual Studio 2008 toolchain and add a manual reference to it from the unit test project.

I've described this workaround in this Stack Overflow answer:

http://stackoverflow.com/questions/5397251/vs2010-sp1-unit-tests-targeting-3-5-framework-fail-if-using-private-accessor/6514931#6514931
File Name Submitted By Submitted On File Size  
ConsoleApp.7z (restricted) 6/29/2011 -
ConsoleApp.zip 6/29/2011 59 KB