Visual Studio 2010 SP1 and unit test SharePoint 2010 w/ MSTtest - visual-studio-2010

Could someone please clarify this MSDN article regarding Basic Unit Testing Support for the .NET Framework 3.5 http://msdn.microsoft.com/en-us/library/gg442059.aspx#bkmk_basicunittesting which states "The following capabilities enable developers to write unit tests and integration tests for applications that target the .NET Framework 3.5, including SharePoint 2010 applications".
The testing I've done and my understanding of the .Net 4.0 CLR and MsTest is that you can load .Net 3.5 assemblies into the 4.0 runtime, which allows for unit testing assemblies that target the 3.5 framework with a unit test project that targets 4.0 framework. This should in theory make it possible to unit test SharePoint project with MsTest 4.0.
What MsTest does not do is run in a true 64 bit mode. Since SharePoint 2010 requires a 64 bit process you get "Error loading C:\PublicShare\64Bit - Copy\Test64Bit\bin\x64\Debug\Test64Bit.dll: Unable to load the test container 'C:\PublicShare\64Bit - Copy\Test64Bit\bin\x64\Debug\Test64Bit.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///C:\PublicShare\64Bit - Copy\Test64Bit\bin\x64\Debug\Test64Bit.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format." when you try to run a unit test against an assembly that targets the x64 framework, which SharePoint Object Model must do.
It seems to me that the statement made by Microsoft is misleading, incomplete or misleading. Can someone please clarify?

Did you try this with SP1 beta? SP1 was released today and I hear that this does work.

Related

.NET Compatibility Testing using Coded UI

I have a test scenario where i want to validate the 4.5.2 version .net framework is being installed on a fresh windows environment (Win7, 8.1 and 10 - both 32 and 64 bit) along with the .exe which is being installed (Installation being one of the critical test scenario). I did the scripting in MS CodedUI Test. I want this script to be distributed on different machines. For this, I am using Test Controller and Agent setup. I am using VS2015 and TestAgent 2015. As Test Agent 2015 comes with .NET 4.6, my script is getting failed. Can i use any older versions of test agent to accomplish this?
Surely, the installer should fail if 4.5.2 is not available on the target? Then there is no need to use CodedUI to validate it.

Cannot retarget VS 2010 project to .Net 3.5 after installing SP 1

I am trying to add unit tests to a sharepoint solution in VS2010. I have a test project but I cannot retarget the project to .Net 3.5 even after installing SP 1 for VS2010. Please advise.
Here are the steps that worked for me to make Unit tests work with Sharepoint:
Install Visual Studio 2010 Service Pack 1
Create a new C# unit test project
In Project Properties change Application ->Target Framework to 3.5 and Build -> Platform Target to x64
In Test - Edit Test Settings - local testsettings - Hosts tab : change run tests setting to "Run in 64 bit process on 64 bit machine"
Regards

Unit Test Explorer in Visual Studio 11 fails with reference to the Microsoft Smooth Streaming Client SDK Beta 1 assembly

Having a reference to the Microsoft.Media.SmoothStreaming.dll in a Metro Style App project, then attempting to run tests from a separate Unit Test project that references the Metro Style App assembly does not work in Visual Studio 11 (Ultimate Beta Version 11.0.50323.1 QRELB), even with the processor types both set to either x86 or x64 in the Debug compilation configuration.
The platform target of the Metro Style App must be set to either x86 or x64 (Any CPU won't work with the SmoothStreaming SDK assembly). The Unit Test project target must match the setting of the Metro Style App when it contains a reference to the Metro Style App assembly, otherwise you get the following error:
"Error 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "%APPROOT%\bin\x86\Debug\UVerseApp.exe", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project"
When both are set to x64, the solution compiles and runs fine but the Unit Test Explorer will not discover any of the tests from the unit test project, so you can't run them or even see them.
When both are set to x86, the solution builds fine and the Unit Test Explorer properly displays all tests. However, if you attempt to run any of the tests, you encounter an application error in vstest.executionengine.appcontainer.x86.exe every time. The Metro app will still run fine - this only happens when you attempt to run or debug tests methods using Unit Test Explorer.
Is this a known issue and/or are there any possible workarounds?

Windows CE project with libraries problem

I am developing a Windows CE application which uses some libraries provided by other parts of our company.
When I deploy my application on "My Computer" (.NET compact application running on standard PC), everything works, but when I deploy to the device, the application hangs when trying to use methods from the library. The system also hangs. My Visual Studio 2008 sometime hangs, but sometime throws an exception "TypeLoadException: Could not load type from assembly Culture=neutral, PublicKeyToken=nu".
I couldn't include .NET Compact framework 3.5 because the image wouldn't compile, so I am using version 2.0. I use Visual Studio 2008 with deploy .NET framework option.
Most probably the problem is with version of the library you are using. Please cross check it.
Hope this link will help you.
I'm a bit confused.
First of all, what are the libraries "provided by other parts of [y]our company" build against? Are they Compact Framework assemblies (they must be)? What version of the Framework were they build against? Reflector can tell you this if you don't know.
Second, why can't you compile it with 3.5? What sort of errors are you seeing? The code should be 100% forward compatible, so if it won't build, there's a red flag going up.
Lastly, what version of the CF is installed on the target hardware? FOr example, are you trying to push a CF 2.0 app to a device with CF 3.5 already installed? If so, do you have an app.config file that provides the framework compatibility options so it knows it can run your assembly?
The problem was that libraries were compiled with for 3.5 target framework, and the application which uses them form 2.0 framework. In that case, 3.5 framework wasn't depoloyed and application would stop working as soon as call to the library methods was made.

Warning - Targets a different processor than the application

My .NET 3.5 WPF application has started showing a bunch (14) of the the following warning (with different dlls):
Referenced assembly 'C:\WINDOWS\assembly\GAC_32\Microsoft.TeamFoundation
\9.0.0.0__b03f5f7f11d50a3a\Microsoft.TeamFoundation.dll'
targets a different processor than the application.
I am running on a 32 bit machine. The only project in my solution is set to compile to "Any CPU". (A rebuild all does not fix it.)
I would rather not recreate my solution. Does anyone else know another fix/workaround for this issue?
NOTE: I am using Visual Studio 2008 SP1 and Windows XP 32 bit.
Haven't seen that one specifically but the download samples for C++ by default build for Itanium - did you install the wrong version of those libs?

Resources