When I try to run my test suite, which works fine under Visual Studio 2008, I get the following error in the Output window:
Error loading J:\VBProjects2010\Libraries\PFTest\PFTest\bin\Debug\PFTest.dll: Could not load file or assembly 'file:///J:\VBProjects2010\Libraries\PFTest\PFTest\bin\Debug\PFTest.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Note that these same tests can be viewed in the Test View windows, and run well under Visual Studio 2008, but fail only under VS2010.
Note that PFTest.dll is the test project's name, and the dll is the file created when I compile (which compiles ok).
strong textIn addition to the above, I realised I could not step through code either since the compiled dlls and exe could not be loaded from the shared drive.
This solved the problem.
Edit C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config
Add <loadFromRemoteSources enabled="true"/> under <runtime> so that it looks like this:
<runtime>
<loadFromRemoteSources enabled="true" />
<UseSmallInternalThreadStacks enabled="true" />
...
The gouderadrian's anwser did not worked for me.
I am on a VirtualBox machine with Windows 7 64 bits and Visual Studio 2012.
I had to move the output to a local folder : open the unit tests project properties and in the Build tab, browse the Output path to a local folder. The tests are now detected and can be run.
For Visual Studio 2010 Express for Windows Phone the file you're looking for has the name VDPExpress.exe.config.
MS's docs here: http://msdn.microsoft.com/en-us/library/dd409252.aspx
Related
Error : No tests found to run - while debugging/running C# Unit test
cases -- Visual studio 2017 15.5.1 not discovering test cases.
Framework
Microsoft.NET framework 4.6.1
Added Test adapters as below
MSTest.TestAdapter.1.2.0
MSTest.TestFramework.1.2.0
Test explorer not showing the test cases.
This started happening after upgrading visual studio.
Some unit test projects test cases do not get discovered in the test explorer.
When try to debug or run it says "No tests found to run."
I tried deleting project and recreating it again .. but didn't worked.
Output
[4/3/2018 2:59:25 PM Informational] No tests found to run.
I have updated VS to 15.6.4
Deleting VS test cache files DEL %TEMP%\VisualStudioTestExplorerExtensions
Restarted Visual studio
Test cases got discovered but not debugging
Problem
If I understand you correctly, this is something you observe:
when you run the tests, the following can be seen in the console:
[4/3/2018 2:26:13 PM Informational] ------ Run test started ------
[4/3/2018 2:26:14 PM Warning] No test is available in d:\...\UnitTestProject1.dll. Make sure that test discoverer & executors are
registered and platform & framework version settings are appropriate and try
again.
and the test explorer shows:
What could have happened, and it happened to me a couple of times, that the test discovery is set up for another architecture than your currently set one.
Example
Your current configuration is x64
but, the default test settings might have another one (e.g. x86):
Solution
If you _align the test settings with your current architecture (x86 → x64), the tests should run.
Manual cleanups should not be necessary nowadays, if the solution is configured consistently
I had same problem, make sure you set TestClass to public !
[TestClass]
public class CSharp_JavaScript_ServerResponse_Test
{
}
I had may versions of the Nuget Package installed, I consolidated them into the latest one and it fixed the problem
MSTest.TestAdapter
MSTest.TestFramework
As of today, me using NUnit # VSCode and .NET Core 5.0
was missing Microsoft.NET.Test.SDK NuGet package..
As soon as I added it to ALL test assemblies (i.e.: all .csproj files in solution .sln), everything works fine.
HTH to many who reach this far.
These PackageReferences are in my TestProject.csproj
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.1"/>
<PackageReference Include="NUnit.Console" Version="3.12.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0-beta.2"/>
<PackageReference Include="NUnitTestAdapter" Version="2.3.0"/>
<PackageReference Include="NUnit.Extension.NUnitProjectLoader" Version="3.6.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0-release-20210422-02"/>
</ItemGroup>
The accepted answer didn't work for me in isolation but along with this it did:
Exit MSVS
Delete the .vs folder (you may lose a few settings related only to that solution)
Restart MSVS
From the accepted answer, ensure the Test -> Settings -> Def Arch-> matches the code
Load playlist (if applicable)
Build
Test!
Try clearing temp files located in the %TEMP% directory
Delete folder : VisualStudioTestExplorerExtensions in %temp% directory.
Note: This path is generally at C:\Users\(yourusername)\AppData\Local\Temp
In my case, "Build -> Clean Solution" did the trick.
Also, make sure you have both MSTest.TestFramework AND MSTest.TestAdapter Nuget packages installed
Guys
I was having the same problem, and fix it by adding the [TestClass] and [TestMethod], and got my Selenium Automated test library working on VS 2015.
Cheers,
[TestClass]
public class GigHubAutomatedTest
{
[TestMethod]
public void StartApplication()
{
using(IWebDriver googleDriver = new ChromeDriver())
{
// 1. Maximize the browser
googleDriver.Manage().Window.Maximize();
googleDriver.Navigate().GoToUrl("https://www.google.com/");
}
}
}
I did below thing and it resolved my problem
I have updated VS to latest version 15.6.4
Deleting VS test cache files DEL %TEMP%\VisualStudioTestExplorerExtensions
Restarted Visual Studio
Then test cases got discovered but not debugging.
It was giving error as:
Dependency finder domain): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT
VISUAL
STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'.
Cannot find or open the PDB file.
and similar error for other DLLs as below:
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL
STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.Common.dll'.
Cannot find or open the PDB file.
So PDB is a debug information file used by Visual Studio. These are system DLLs, which you don't have debug symbols for.
Go to Tools->Options->Debugging->Symbols and select checkbox "Microsoft Symbol Servers", Visual Studio will download PDBs automatically.
Then I downgraded:
MSTest.TestAdapter.1.2.0 to 1.1.18
MSTest.TestFramework.1.2.0 to 1.1.18
Then restarted VS studio and rebuild.
Still got below error:
System.IO.FileNotFoundException: Could not load file or assembly
'System.Net.Http, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
Then I set version to newVersion="4.0.0.0"
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.0.0.0" />
</dependentAssembly>
And it started debugging.
My issue was I was using async-await, and the return type was void. It needs to be Task.
Changed this:
public async void MyTest()
To this:
public async Task MyTest()
You can get this error message if you make the mistake of right-clicking inside the editor then choosing Debug Test(s) when you are NOT in a unit test method (e.g. you have a method Foo() and you put a breakpoint in there and want to run the tests so they cause the breakpoint to be hit...nothing will happen if you choose Debug Test(s) while inside the body of Foo()...you have to go to Test Explorer and choose Debug or use the shortcut Ctrl+T,Ctrl+R).
I'm trying to organize my unmanaged .dll dependencies in my Visual Studio solution but unless the DLLs are strewn about the top level of my solution they do not get built into the application's directory and then the application fails to run. I have done a lot of Googling on the subject and there seems to be a solution in the form of an app.config setting:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatepath="lib" />
</assemblybinding>
</runtime>
</configuration>
I have a folder in my solution called "lib" and Copy Local is set to true for all files in the folder but the application is still unable to run. How can I keep my Visual Studio solution organized without breaking my application?
The only way I have found to solve this issue is through windows .bat files.
If there is a way to encode extra search paths into an unmanaged executable, I would like to know!
Here is an example of what I do:
SET PATH=$~dp0plugins\MY_PLUGIN\Debug;%PATH%
vcvars32.bat
devenv build\MY_PROJECT.sln
The first line adds the path of where I want visual studio to find my dll's in.
The second line ensures that the 'right' visual studio will open up. IE: if I have my environment set for VS2010, I dont want VS2012 to open up by default.
The last line invokes the IDE to open up my sln file.
The visual studio that opens up now has a path to the Debug folder of one of my plugins. When I debug my application, the correct dll will be found, loaded, and debugged with no issue - I verify this under the Debug->Windows->Modules panel.
This only works for the Debug configuration. If I want to run the release configuration, I change the .bat file to say 'Release', close Visual Studio and re-run the .bat file.
I apply this same pattern to running my executable. Set up the environment of where I want my dll's to come from and then execute my executable:
SET PATH=$~dp0plugins\Debug;%PATH%
... Repeat for other dll locations
"%~dp0Debug\MY_EXECUTABLE.exe" %*
SS64 is an invaluable resource to figure out what you can do in .bat files
I work with Visual Studio 2012, and I just switched my deployment tools from NSIS to InstallShield. I've added new projects to my solution for InstallShield installers. When I build in Visual Studio (the IDE) I've no errors, no warnings and I'm happy.
Now, I want to have a script that build the full solution without launching the IDE. But when I run MSBuild in the command line, like that
MSBuild MySolution.sln /t:Build /p:Configuration=Release
I get following error MSB4062
C:\Program Files (x86)\MSBuild\InstallShield\2012SpringLimited\InstallShield.targets(21,3): error MSB4062: The "Microsoft.Build.Tasks.AssignProjectConfiguration" task could not be loaded from the assembly Microsoft.Build.Tasks.v3.5. Could not load file or assembly 'Microsoft.Build.Tasks.v3.5' 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.
My searches lead me to the conclusion that I must buy the Premier Edition of InstallShield to take profit of ISCmdBuild. But I can't afford it, and I think there might be another solution.
Any idea?
Using Fusion logging the MSBuild checks for the DLL here: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Tasks.v3.5.DLL.
I copied
c:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Build.Tasks.v3.5.dll
to
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Tasks.v3.5.dll
And the error is gone.
Alternatively open your *.isproj file and change from "3.5" to "4.0" on top on the tag:
<Project ToolsVersion="3.5"...> --> <Project ToolsVersion="4.0" ...>
Another solution is to force MSBuild to use the x86 platform. See https://stackoverflow.com/a/1074699/870604
If you're building from a TFS build, this can be configured from the build options:
I found the solution. Use the command devenv.exe instead of MSBuild.exe. It will be similar to launching Visual Studio and clicking the Build button. That's all!
devenv.exe MySolution.sln /build Release
I am using Bamboo [from Altassian] and it uses the devenv.com builder to build solution files. Currently, I seem to be getting a "false" error in my builds - that I've tried to solve by myself but just can't - so I thought I would ask.
Each build succeeds normally - without errors stemming from code - but seems to instead give this error
Package 'Microsoft.VisualStudio.TestTools.TestCaseManagement.QualityToolsPackage, Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed to load.
I've no idea why this is causing problems in the devenv.com environment and I can't figure out either how to "ignore" this error by some build command?
Try this ( from MSFT support )
Can you check if the dll is in the global assembly cache (open a VS 2010 command prompt
(Start | All Programs | Microsoft Visual Studio 10.0 | Visual Studio Tools))
Type in
Gacutil –l > list.txt
Notepad list.txt
Do you see an entry like
Microsoft.VisualStudio.QualityTools.TestCaseManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
If so, from the same command prompt, run fuslogvw, go to settings, select log bind failures to disk, select ok
Run your command line
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com /Build "Release|Mixed Platforms" "D:\Builds\19\Test VizXView\VizXView v1.8 Test Release Build - Weekly\Sources\VizXView v1.8\VizXView 1.8.sln"
Click on the refresh button in fuslogvw. Do we get any bind errors?
I had a similar issue related to running unit tests on a build server that was using devenv.exe (not devenv.com). I had a premium VS installed on the build server but I'd written the unit tests with ultimate (which 'has' load testing, even tho I'd not used it). I used fusion viewer to work out that the missing dll was LoadTest.dll which I copied from my laptop to the buildserver, I also removed references in my solution that were in version control to: *.vsmdi and *.testsettings (they're deprecated) and I removed from the build def a reference to a .testsettings file.
My guess would be that even though I wasn't running a load unit test the build agent was trying to load the LoadTest libs just in case. Hope that helps
edit ---
ok, my own problem here was that I've got both vs2010 and vs2013 on my laptop. When I added the first test project to my VS2010 solution, the project added actually has a dependency on the 2013 version of the UnitTestFramework.dll. My build server only has vs2010 on it so I got the missing assembly error. Switching the reference to the 2010 version fixed this.
I am experiencing a strange issue with VS2010. We use TFS to build our API dlls and we used to reference them in our projects usign a mapped network drive that was fully trusted. We have been working like that for at least two years and everything worked perfectly.
Today, I converted a webapp to vs2010 and when I compile it in Release, it's giving me:
SGEN : error : Could not load file or
assembly 'file:///L:\Api\Release
API_20100521.1\Release\CS.API.Exceptions.dll' or one of its dependencies. Operation
is not supported. (Exception from
HRESULT: 0x80131515)
The strange thing is that it's working when it's under the Debug profile...
I tried adding the
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
into app.config and still no luck (See http://social.msdn.microsoft.com/Forums/en/msbuild/thread/d12f6301-85bf-4b9e-8e34-a06398a60df0 and http://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx)
I am pretty sure that this issue is from visual studio or msbuild, as our code won't run from a network share when in prod because all the referenced dll's are copied into the bin folder.
If anyone has an solution (or just an idea for a search path) please let me know !
Edit : It turns out that it was working in Debug mode because generation of serialisation assemblies was turned Off. As the title say, it's really a SGEN problem since it is this utility that says that the path is not trusted...
I was able to fix this error by finding the assembly DLL in Windows Explorer, right clicking, choosing Properties, and then pressing the "unblock" button. The DLL has a stream that is marking it as an external file - and by clicking unblock you remove that designation.
I just had the same/similar issue on a TFS build server where a build was referencing dll's from a network share.
The problems is that the CLR v4 security policy model has changed since previous versions and are not sandboxing assemblies as before.
To fix your issue just find the location of sgen.exe and create a sgen.exe.config in the same folder with following contents:
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
sgen.exe is usually at
"C:\Program Files\Microsoft SDKs\Windows\v[current version]\bin\NETFX 4.0 Tools"
You can read about some of the changes around CAS policies in .NET 4.0 in this blogpost: Link
Had the same problem and the config change didnt work. Only when i set Generate Serialization Assembly to off in the project properties did it work.
I had the same error and found my DLL was "blocked". Open up the DLL in explorer, right click -> properties -> press 'Unblock'.
http://cantgrokwontgrok.blogspot.com/2009/10/visual-studio-unknown-build-error.html
I had this exact same problem and fixed it by adding the sgen.exe.config under C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
with this simple config as others have said
<?xml version ="1.0"?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
For those of you running a 64bit version of the TFS build service, I had to create the config file in the following path:
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64
And the file contents:
<?xml version ="1.0"?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
I had the same issue, loaded the assembly in the GAC and worked
Adding the snippet below to the app.config file worked in my case. I'm Running Windows XP, with VS2010 service pack 1.
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
In my case bunch of dlls were blocked.
To unblock all files in folder I used power shell with following command
dir -Path [directory path] -Recurse | Unblock-File
Just as an FYI if you are running Windows 7 the sgen.exe file can be found at:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
I had to create a sgen.exe.config and place it there and then this problem went away.
Neither the unblock nor the config worked for me.
What did the trick for me was this tip about caspol.
I ran
%windir%\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -m -ag 1.2 -url file://UncPathName/UncSubPath/* FullTrust
And I was ready to go, not even a VisualStudio restart required.
I got a similar problem and I finally got over with it by removing the licenses.licx file in the Properties folder of the solution.
Just in case like me, Unblock was not a solution, as Unblock does not appear on my dll file properties. Kept looking and ended up closing my solution file and re-opening using the local C: copy instead of network UNC path to project sln file. Was able to publish after going this route.