Unable to set TestContext property - c#

I have a visual studio 2008 Unit test and I'm getting the following runtime error:
Unable to set TestContext property for the class JMPS.PlannerSuite.DataServices.MyUnitTest. Error: System.ArgumentException: Object of type 'Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext' cannot be converted to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestContext'
I have read that VS 2008 does not properly update the references to the UnitTestFramework when converting 2005 projects. My unit test was created in 2008 but it inherits from a base class built in VS 2005. Is this where my problem is coming from? Does my base class have to be rebuilt in 2008? I would rather not do this as it will affect other projects.
In other derived unit tests built in 2005, all that we needed to do was comment out the TestContext property in the derived unit test. I have tried this in the VS 2008 unit test with no luck. I have also tried to "new" the TestContext property which gives me a different runtime error.
Any ideas?

I had the same problem in Visual Studio 2012 when I upgraded an older project (i think 2005).
The Reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework needs to be removed by right clicking it in the Solution Explorer then removing it.
To add the right one:
Add New Reference
Extensions, find Microsoft.VisualStudio.QualityTools.UnitTestFramework, there are likely several
Mouse over to display the path, choose the one in ../IDE/PublicAssemblies
Clean
Rebuild
Rerun tests

I'm posting this here in the hopes that it helps someone unit testing a smart device project. I got a very similar error when I first tried to run a unit test for a method in a smart device project I was working on in Visual Studio 2008:
Error: System.ArgumentException: Object of type 'Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext' cannot be converted to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestContext'
Googling the error returned results that suggested it was caused by upgrading a test project from Visual Studio 2005 format to 2008, and that the reference to the UnitTestFramework.dll was still for the old version (8.0) and required updating. This did not apply to me as I had not upgraded my test project from VS2005. So I continued searching.
After hours of searching for other causes for the error without success, I stumbled upon the following references in the smart device project:
Microsoft.WindowsMobile.dll
Microsoft.WindowsMobile.Status.dll
Visual Studio was obtaining these references from the following folder:
C:\Program Files\Windows Mobile 5.0 SDK R2\Managed Libraries
However, the smart device project's target platform was the Windows Mobile 6 Professional SDK. I didn't notice this before as I did not originally create the smart device project. So I removed the references to the two DLLs and readded them from the following folder:
C:\Program Files\Windows Mobile 6 SDK\Managed Libraries
After rebuilding the smart device project, running the test method succeeded.

I ran into the same issue. Turned out that one of my projects was referencing the 8.0 assemblies and the other was referencing 9.0. The solution compiled, but I got a runtime exception.

Related

A custom debug visualizer stopped working in VS 2019. VS is unable to load it anymore

I have a custom debug visualizer in my project that derives from the DialogDebuggerVisualizer class. I am using the DebugVisualizerAttribute to annotate the classes that can be supported by the visualizer. Visual Studio 2019 shows the visualizer option during debugging, but when I choose to use open this custom visualizer, I get the following error:
Unable to load the custom visualizer.
The debuggee-side visualizer type
'MyProjectName.DebugVisualizers.MyCustomVisualizer'
could not be resolved. This may be due to an older version of
Microsoft.VisualStudio.DebuggerVisualizers.dll being loaded in the
debugged process. Please ensure that there are no references to older
versions of this DLL in the debugged process and instead use the
latest reference to build against.
This used to work fine until recently. It seems like one of the recent updates to VS 2019 is now causing it to fail to load.
My project correctly references the "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll" assembly, which is the location that the documentation mentions to use.
So not sure what is causing this issue. Has anyone experienced a similar problem and know how I can resolve this issue?
Thanks.

Visual Studio 2015 CodedUI Test can't load 2013 dll after 2017 check in

I didn't run into this problem, but a member of my team did. Most of the team is working in a Windows 10 environment, using Visual Studio 2015 Enterprise. This one particular team member is using Windows 7 (we started upgrading last year, but they have chosen not to do so...though this may force them to). However, that is the only difference that I can see (they are using Visual Studio 2015 Enterprise).
We have another team that we work closely with that is using Visual Studio 2017 (our team should be upgrading soon, but we're not there yet). One of those members made a check in to our Testing solution (which is all CodedUI tests) that altered all of our project files. However, the only change that I can see is that the false property was added to the Microsoft.VisualStudio.QualityTools.CodedUITestFramework reference (it didn't change the version called out, which is 14.0.0.0).
My environment handled this changed just fine (Windows 10, VS2015) but the one team member with Windows 7 is seeing the following error when they try to run a test:
Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified..
I guess I should note that we started writing our Testing solution in VS2013, originally. That's why the reference is to 12.0.0.0. Also, the environment in question has both versions of the dll available.
It doesn't matter which test they try to run, all of our tests throw this error. The Testing solution builds just fine on their environment, so everything is compiling fine.
Any suggestions? I think our immediate solution is to get all of our environments upgraded, but I'd like to understand why this error is happening. We've seen it before (around the time when we upgraded from VS2013 to VS2015), but just never took the time to investigate.
I'm sure I haven't gotten to the exact root of the problem, but we found that by uninstalling Visual Studio 2013 from the environments in question fixed the error. The problem actually had nothing to do with Windows 10 vs. Windows 7.

TeamCity - Missing 'Microsoft.Web.Infrastructure'

I've been browsing around StackOverflow exploring possible solutions to my issue. For some reason TeamCity is unable to find 'Microsoft.Web.Infrastructure' but I have installed all the required .Net packages. However, I've ran all the tests locally and building the project within Visual Studio returns a successful build.
This is the error which I am experiencing:
App_Start\NinjectWebCommon.cs(9, 40): error CS0234: The type or namespace name 'DynamicModuleHelper' does not exist in the namespace 'Microsoft.Web.Infrastructure' (are you missing an assembly reference?)
Solutions I have tried
Within Visual Studio I was instructed by one StackOverflow thread to set the reference 'Microsoft.Web.Infrastructure' option 'Copy Local' to true. This returned the same result of the error above.
I've deleted all references of 'Microsoft.Web.Infrastructure' and performed a fresh install of this package, I'd had also reinstalled Ninject as well. I didn't specify a particular version. Again, building locally was successful remotely not so much - same error occurred.
Has anyone encountered such issue before? I had also done a fresh clone of the GIT Repository, restored all the NuGet Packages (Which TeamCity does as well) and it built completely fine.
After asking this question I'd continued my investigation. While my continuous integration server is running multiple windows virtual machines, and since TeamCity load balances the builds across these virtual machines some of their configurations were out of sync with the rest. Some of the team code purely in C++, so the version of Microsoft Visual Studio which was installed (Visual Studio Professional 2013) was the incorrect version for my C# project. After attempting to open the project with Visual Studio on one of the selected VM's, I found that Visual Studio didn't understand the csproj file extension.
I installed Visual Studio 2013 Ultimate - this is version I use on my workstation - and thankfully it complied. sometimes within my project, when I request a build it would use older files as TeamCity would cache the files locally. I found setting the to 'clean and re-download' within the VCS options also remedied this issue.

Error while trying to run the Program Visual Studio

Every time I create a new project in Visual Studio it gives me this error
Error while trying to run project:could not load file or assembly '[project_name_here]' one of its dependencies. The module was expected to contain an assembly manifest
I am not able to understand what is the problem with Visual Studio or .NET Framework, today I even tried to re-install the .NET Framework but still I don't get it to work.
It always keeps saying this message, even if I just Start the Build process as soon as Creating the project. This happens even if I create the project of (Empty) Console Application and run it, with just a Main method.
When I create the projects in C++, they run, but when I try to run the projects in C# they give me this error. I have tried almost all the methods provided on Stack Overflow, CodeProject, MSDN forums etc. But, nothing works.
What should I do or write to my application so that it would work.
I have, Visual Studio 2013 Ultimate update 2 running on Microsoft Windows 7 SP1 with no extensions or updates, just a pure Visual Studio from Microsoft.

Upgrading build server to Visual Studio 2013 has broken deployment process

My build manager has been banging it's head on this for quite sometime.
We were using Visual Studio 2012 Professional with MSDeploy. Everything ran fine, we were able to do builds, Xml transforms, database deployments, web deployments, etc. to various environments.
We recently upgraded our build server to Visual Studio 2013 Professional and pretty much all hell has broken loose.
We get the following errors during our build process since upgrading:
Error Code: ERROR_EXCEPTION_WHILE_CREATING_OBJECT
More Information: Object of type 'manifest' and path 'C:\Builds\90\Code\Staging - Project\Binaries\Website Deployment\Project.Web.manifest' cannot be created. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXCEPTION_WHILE_CREATING_OBJECT.
Error: One or more entries in the manifest 'sitemanifest' are not valid.
Error Code: FileOrFolderNotFound
More Information: Could not find file 'C:\Builds\90\Code\Staging - Project\Binaries\Website Deployment\Project.Web'. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#FileOrFolderNotFound.
Error count: 1.
We have done everything possible to fix this issue. We have tried everything to get this building again. Even updating the project .prj file itself to point back to older .targets v10.0 from v12.0.
When we do "change" targets, it give us this new error:
C:\Builds\90\Code\Staging - Project\Sources\Project.Web\Project.Web.csproj (3290): The "TransformXml" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Windows\Microsoft.NET\Framework64\v4.0.30319" directory.
So it seems Visual Studio 2013 has modified something pretty significant in our environment to cause these errors during our Deployment process (the verbose log indicates that everything is building, just not deploying correctly).
Any help would be awesome!
I also recently upgraded to Visual Studio 2013 and found problems with deployment of a database project where the "Deploy" option didn't do anything and the publish didn't produce the differencing script I was expecting.
I installed the SQl Server Data Tools - Business Intelligence for VS 2013 and it resolved the problem for me. Perhaps it may help in your situation.

Categories

Resources