I've got an annoying issue with Gallio when I try to analyse my VS2012 C# solution with my sonar-runner. When Gallio try to launch my unit test I can find this issue in the logs :
[error] Assembly XXXX
Cannot run tests because MSTest executable was not found
I've already tried some propositions of solution exposed here and here (I have installed Agents for VS 2012 and I have added a registry key with the path of my VS2012 installation) but nothing seems to work.
Thank you by advance for your help.
EDIT :
It seems that this issue come from an hard coded registry value in Gallio source code because when I try to add the InstallDir registry key for VS2010 to point to my VS2012 installation I can see a new error message.
This new error is an I/O Exception relative to the following DLL : "Microsoft.VisualStudio.QualityTools.CommandLine.dll" version 10.0.0.0 which I'm able to find in my GAC_MSIL directory but in version 11. My conclusion is that Gallio isn't fully compatible with VS2012 and the corresponding version of MSTest.
I'm going to investigate to find a way to manually generate Unit testing reports that Sonar will be able to store.
EDIT 2 :
There is finally no way to collect mstest reports in sonar for now. The only solution I found is to convert every unit test made with MSTest into an NUnit test to be able to run it with gallio and gather the results in my Sonar server.
Add the following to your machine.config located at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.QualityTools.CommandLine"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0"
newVersion="11.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Then you will need to add a registry key called InstallDir with a value of
"InstallDir => C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\"
to the following location
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0
Then run the following command
regsvr32 "C:\YourSonarInstalation\opencover\x86\OpenCover.Profiler.dll
The issue is being discussed here. The potential solution above was posted a few days ago.
https://code.google.com/p/mb-unit/issues/detail?id=899
For Visual Studio 2013 and .net 4.5 This is a similar process.
Add the following to your machine.config located at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config and/or C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.QualityTools.CommandLine"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0"
newVersion="12.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Then you will need to add a registry key called InstallDir with a value of "InstallDir => C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\" to the following location HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0
Then run the following command regsvr32 "C:\Program Files (x86)\OpenCover\x86\OpenCover.Profiler.dll"
Related
The following build error is pestering me.
The "CompareCommonBuildTaskVersion" task could not be loaded from the assembly C:\Users\Thijs\.nuget\packages\microsoft.vssdk.buildtools\16.6.1026\tools\VSSDK\Microsoft.VisualStudio.Sdk.BuildTasks.dll.
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
I just checked the directory mentioned, and there is a Newtonsoft.Json.dll there, but it's version 12.0.2.23222 (File Version).
I'm using:
Visual Studio Enterprise 2019 Preview
Version 16.6.0 Preview 1.0
Visual Studio Enterprise 2019
Version 16.5.0
Upon reading the link EricEJ posted I checked my devenv.exe.config which has the following (correct) AssemblyRedirect:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="4.5.0.0-12.0.0.0" newVersion="12.0.0.2"/>
<codeBase version="12.0.0.2" href="PrivateAssemblies\Newtonsoft.Json.12.0.0.2\Newtonsoft.Json.dll"/>
</dependentAssembly>
Problem seems to be with the actual BuildTools package (see answer).
I tried the different BuildTools package versions again, starting from the newest and after installing, restarted VS and then did a rebuild of the solution:
Version 16.6.1026 -> March -> Not working
Version 16.6.1024 -> March -> Not working
Version 16.5.2044 - February -> Working
So far it seems the downgrade has resolved my issues.
I'm trying to write some unit tests, using NUnit, for code that relies on DbGeography.PointFromText(text, 4326), which requires Microsoft.SqlServer.Types be loaded. I'm trying to load it using:
[OneTimeSetUp]
public void Startup()
{
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
}
I have also tried to use load them in a [Setup] method. When the code that uses DbGeography is called, I end up with the lovely exception:
System.InvalidOperationException : Spatial types and functions are not
available for this provider because the assembly
'Microsoft.SqlServer.Types' version 10 or higher could not be found.
I do have the Microsoft.SqlServer.Types Nuget package installed, and it is working fine and dandy in my Web API 2.2 application.
You can install the libraries on the system, but then will also need to remember to install on build servers and production, etc.
Alternatively, have had success with doing the install of the Microsoft.SqlServer.Types NuGet and loading the assemblies as instructed. For xunit I included this in a TextFixure ctor.
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
Also, found I needed to add bindingRedirects:
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
I ended up installing the Microsoft SQL Server CLR types, and my unit tests were able to find the necessary types.
X86 - http://go.microsoft.com/fwlink/?LinkID=239643&clcid=0x409
X64 - http://go.microsoft.com/fwlink/?LinkID=239644&clcid=0x409
I'd like to publish the sample application CefSharp.MinimalExample (Make a .exe file) With visual studio 2015 by following this : Debug - CefSharpMinimal.Example.WinForm properties - Publish now and I still get the follwing error:
Could not find file 'Microsoft.Windows.Common-Controls, Version=6.0.0.0, Culture=, PublicKeyToken=6595b64144ccf1df, ProcessorArchitecture=, Type=Win32'.
As I did not edit anything in the source code, provided by the Sample App, I don't understand what is wrong
I had same problem, and I fixed it by removing or commenting this lines in the file app.mainfiest (in project where you see error):
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--<dependency>
<dependentAssembly>
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>-->
I get this error message:
Could not load file or assembly 'System.Spatial, Version=5.7.0.0,
Culture=neutral, PublicKeyToken=49ba329had364evz' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
I tried to uninstall/update System.Spatial and WindowsAzure.Storage Nuget packages but still get the error.
It's a dependency of WindowsAzure.Storage package, but funny thing is that I don't get this error when running my ASP.NET Web API project locally, but only on the Azure server.
I don't know where to find the assembly's manifest, is it packages.config?
How to get rid of this error? I already wasted two days :(
Changed the version details in configuration file based on DLL version present in bin folder of project having issue.
In configuration file it was referring to version 5.6.4 but I have changed to version 5.6.3 which resolved the error.
Before Change
<dependentAssembly>
<assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
</dependentAssembly>
After change.
<dependentAssembly>
<assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.3.0" newVersion="5.6.3.0" />
</dependentAssembly>
if you are using visual studio, go to nugget package manager and view installed packages, and use update pane to update system.spatial package,
this solved my issue
For some reason I don't know, Visual Studio wasn't uploading newer .dll file to the server.
So I manually uploaded System.Spatial version 5.7.0 on the server.
(although still I don't know how could I change the version in a so called manifest.)
Fit all dependencies to your current azure version by the following two steps:
open Package Manager Console window
enter PM> Install-Package WindowsAzure.Storage -Version [your_version_number]-preview -Pre
this is what solved the problem in my case.
I'm using AspNet Web Api Client 5.0 and i am trying to unit test a web api controller.
var encservice = new EncryptionService();
var acctservice = FakeServices.GetAccountService();
var controller = new AccountController(acctservice, encservice);
controller.Request = new HttpRequestMessage();
when the code
controller.Request.SetConfiguration(new HttpConfiguration());
is executed i hit an exception
Message: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source: System.Net.Http.Formatting
Stacktrace: at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters()
at System.Net.Http.Formatting.MediaTypeFormatterCollection..ctor()
at System.Web.Http.HttpConfiguration.DefaultFormatters()
at System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes)
at System.Web.Http.HttpConfiguration..ctor()
at EMR.Test.Controller.AccountControllerTest.Should_Get() in c:\PremiumProjectsCollection\emr\src\EMRAzure\EMRAzure\EMR.Test\Controller\AccountControllerTest.cs:line 34
the version of newsoft.json that i am using is 6.0
I also have a assembly redirection in my confguration file
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
The test runner that im using is MStest, VS2012
You'll need to add an assembly redirect:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
(assuming that the assembly version of Newtonsoft.Json is exactly 6.0.0.0.)
(note comment below is referring to a Web Api Client project having this issue)
I had the same problem with the version of Newtonsoft.Json so I deleted the older version references and used Package Manager Console to install the latest version of Newtonsoft.Json on my Web Api Client Library and Test Project.
Install-Package Newtonsoft.Json -Version 6.0.8
(note u might need to find out which is the latest version)
The problem remained so I realized there is a crash between System.Net.Http.Formatting and my latest version of Json.
To solve this, delete the System.Net.Http and System.Net.Http.Formatting references and install the WebApi Client Library via Nuget instead, as below:
Install-Package Microsoft.AspNet.WebApi.Client
This solved it for me.
I did not try this myself, but there seems to be a bug in 2012 mstest. Where you have to use .testsettings file for app.config to be picked up.
See the following link: http://social.msdn.microsoft.com/Forums/vstudio/en-US/234926d1-42c0-4ebb-af39-1626e72f6c39/why-does-assemblybinding-work-only-if-testsettings-file-is-used-vs2012rc?forum=vsunittest
I faced the same problem days ago and it took me hours to find a solution for this one.
I was testing a unit that had the latest version of NewtonSoft installed while my test project had an older version.
What i did to get around this was consolidate the versions of this library in my solution via the "Manage Nuget packages for solution" option by right clicking the solution in solution explorer.
This will update all NewtonSoft libraries present in your projects under the current solution and remove all old versions from the package control VisualStudio creates in a folder named packages in your solution directory.