The tests are present at Test Explorer but run command has no effect.
Looking at Output windows, for Test outputs it shows many errors like this:
MSTestAdapter failed to discover tests in class 'UnitTests.Adhoc' of assembly 'some test.dll' because Method not found: 'System.String Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute.get_DisplayName()'..
Found out that had some assembly conflict not signal by visual studio as usual on the references tree node.
Removing Microsoft.VisualStudio.TestPlatform.TestFramework reference and adding again did the trick.
Here de difference at the project file:
Before:
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\MSTest.TestFramework.2.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\MSTest.TestFramework.2.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
After:
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
For me, the other solutions didn't work as I e.g. did not have a reference to the package 'Microsoft.VisualStudio.TestPlatform.TestFramework'. It turned out that the solution for me was updating the Target Framework of the test projects from .NET Core 2.0 to .NET Core 3.1. Everything was working as before when changing that.
I'm not sure what caused the issue, but I think it was a combination of three packages.
For full reference, these are the ones (with version) I am now using with .NET Core 3.1:
Microsoft.NET.Test.SDK
MSTest.TestAdapter 2.1.1
MSTest.TestFramework 2.1.1
On Visual Studio 16.5.2
My problem was that I had tests in one specific class that weren't recognized.
Turns out I'd cut and pasted a TestInitialize method that contained a TestContext that I wasn't using. For instance:
[TestInitialize]
public void ClassInitialize(TestContext context)
When I removed the unused TestContext all my tests were recognized:
[TestInitialize]
public void ClassInitialize()
You can go to the test options (Test -> Options) and turn up the logging level to trace, and then you might find more information. for me, it was because the test classes were not public, even though te.exe (https://learn.microsoft.com/en-us/windows-hardware/drivers/taef/) found the tests fine even when the classes were non public
[MSTest][Discovery][C:\Users\mgrandi\Code\git\blah\src\Services\blah\Test\blah.Tests\bin\Debug\net472\blah.Tests.dll] UTA001: TestClass attribute defined on non-public class blah.Tests.blah.Common.BondObjectSanitizerTest
Related
Tying to build a freshly cloned project, when i build i get this error
Could not load file or assembly 'Microsoft.Configuration.ConfigurationBuilders.Azure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
Things I've tried
Removing the reference and adding back in
changing build properties from debug to release
disabling strong name verification via command line using the command "sn -Vr
Microsoft.Configuration.ConfigurationBuilders.Azure.dll"
i've tried updating the reference to latest / previous versions
Everything I try and nothing seems to work, any other ideas?
In app.config or Web.config, delete the following:
, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
download this nuget package and this will work for you.
.NET Framework:
For me the issue was that I had to change the Version=1.0.0.0 in my web.config to match what was loaded and referenced in the web application references. Right click [Microsoft.Configuration.ConfigurationBuilders.Azure] and go to properties and you'll see the version at the bottom. For me it was Version=2.0.0.0.
I got an InvalidOperationException when the MVC controller tried to FindView while using the PrecompiledMvcEngine.
Using on a machine that has VS2012, MVC4 and deployed to IIS
After looking at the source code of ControllerBase.FindView to ViewEngineCollection.FindView to VirtualPathProviderViewEngine to PrecompiledMvcEngine, found that _mappings in PrecompiledMvcEngine had a count of 0. (Tx to Reflection and Open source.)
The reason is that there was not Type assignable to WebPageRenderingBase in my project's DLL. On decompiling my dll, it actually had the compiled views, and the views extended from WebPageRenderingBase.
After writing a unit test to do the same thing that PrecompiledMvcEngine does to load views, found that they are using different versions of the WebPageRenderingBase class. RazorGenerator.Mvc uses System.Web.WebPages v1.0.0.0 to precompile at build time. The PrecompiledMvcEngine uses System.Web.WebPages v2.0.0.0 when loading types from the compiled assembly. Fixed this by changing my MVC csproject to also load v1.0.0.0 at runtime.
Changed
<Reference Include="System.Web.WebPages" />
which picked up 2.0.0.0 to
<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
forcing it to always pick up 1.0.0.0. This problem will often be faced if you are deploying precompiled views to a machine with VS2012 and MVC4 installed, without specifying the correct version in the csproj file
I have a complex Windows Phone 7 class library which has been working well for months. However, making only a one line change to the class library, in the csproj file, causes failure of the code. The one line in question is this one:
from:
<Reference Include="System.Windows.Interactivity, Version=3.7.5.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL" />
to:
<Reference Include="System.Windows.Interactivity, Version=3.8.5.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL" />
the failure I refer to is the fact that the OnApplyTemplate() overload, essential to the correct functioning of our class library, is no longer called.
Can anybody please give me any insight into this problem?
Many thanks.
You're not "making only a one line change to the class library". You're referencing a different version of an external, albeit system, library.
If there were two different versions of a library I would expect there to be a difference between them. (Otherwise have the 2 versions?) It just so happens that the change between the 2 versions appears to be a breaking change for you.
Why change to v 3.8.5.0 in the first place?
I have a vsixmanifest file that has an assembly attribute. The file looks like:
<Content>
<ProjectTemplate>Solution</ProjectTemplate>
<Assembly AssemblyName="SolutionNameWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c39bfcc-223f-4c12-a5dc-55eeca7c61f7">
Assemblies\SolutionNameWizard.dll
</Assembly>
I know that the assembly name and public key are correct.
Now, I am trying to use this assembly in one of my templates. Right now I have:
<WizardExtension>
<Assembly>SolutionNameWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c39bfcc-223f-4c12-a5dc-55eeca7c61f7</Assembly>
<FullClassName>SolutionNameWizard.IWizardImplementation</FullClassName>
</WizardExtension>
Is there something that I am missing? When I run the vsix I get the following error:
A problem was encountered creating the sub project 'test.Web' Error: this template
attemtped to load component assembly 'SolutionNameWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c39bfcc-223f-4c12-a5dc-55eeca7c61f7'.
I know that templates require the assembly to be in the GAC, is that also the case when I am using vsix? I was hoping to avoid the GAC and still use my wizard.
EDIT: I changed the public key to the proper string as suggested in the answers, but am still having the issue.
Edit 2: in addition to the helpful answer below, here is a blog that I wrote after I finished this process. It links to a bunch of articles that I found to be very helpful: https://thebhwgroup.com/blog/2013/10/visual-studio-templates
If your assembly is being provided via your VSIX, it does not need to be in the GAC.
Your PublicKeyToken is definitely not correct. You're using a Guid when it should be a 16-character hex string (8 bytes). See the following example:
MyAssembly, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
You can find the PublicKeyToken value for your assembly by running sn.exe -T MyAssembly.dll from a VS command prompt.
If anyone else happens to stumble upon this question, I ended up following this guide: http://blog.tonysneed.com/2011/09/14/build-a-multi-project-visual-studio-template/
It made the process (mostly) very easy. If anyone happens to run into similar issues, feel free to contact me and I can try to share what I learned.
Edit: here is short blog article I wrote after completing this process. It might be helpful for someone who stumbles upon this: http://www.thebhwgroup.com/blog/2013/10/visual-studio-templates/
I am working within a Solution (a jokes website). The Solution has 2 Projects:
Model (C# Class Library)
MVC 3 Empty Application
I am trying to get my view to list the Jokes in the Database, but I get the following error:
Could not load file or assembly 'System.Data.Entity, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified
As you can see from the Error message, I have already added the System.Data.Entity to the web.config of the MVC 3 application.
No matter what I do, I seem to be unable to fix the error! I have added using statements for the Entity class, to the HomeController and the Index.cshtml.
To use an external Entity Framework model (embed in a DLL for example) with ASP.NET MVC 3 you must :
Add the following reference to your MVC project : System.Data.Entity (Version 4.0.0.0, Runtime v4.0.30319)
Add the following line in your web.config
...
< compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
To resolve this error:
Go to references section in your project
Right click it and than go add library package reference.
search in online tab for entity framework
you will get a lot of installed packages if u have internet connection enabled
Select EF4 package, and finally, add it
If you have any entity frame work installed and you are getting an error then click for add reference and in Browse tab go to below location:
C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
Select to find System.Data.Entity.dll and then add it. This will resolve this issue.
I was getting the same error, and it was because the MVC3 project used Entity Framework 4.1, and my domain model (in a class library project, same solution) grabbed 4.2 when I added the reference.
I uninstalled EF from my Web project, then reinstalled, now both have 4.2 and are working fine.
Currently working with the Apress title, Pro ASP.NET MVC Framework (Freeman).
another way to solve this is to add empty edmx file (Add -> Class -> Data -> ADO.NET Entity Data Model) and delete it afterwards.
I am not sure what the Visual Studio Wizard does, but it`s a common problem at my machine and i always fix it like that.
Make sure you have referenced the System.Data.Entity assembly in your project. Not only in the web.config assemblies section but also those assemblies being referenced. Also make sure that the System.Data.Entity, V4.0.0.0 is present in the GAC on the server you are running this application.