I am getting the following error message:
The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?)
I added Just Mock to my testing project and I followed the configuration instructions at
http://www.telerik.com/help/justmock/integration-ncrunch.html
All I did was add the Proxy file path to on my test project in the ncrunch configuration : C:\Program Files (x86)\Telerik\JustMock\Libraries\JustMockRunner.exe
Did I miss something?
This is usually caused by having installed ngen'd assemblies for the /Profile scenario. Some profiler-based tools do that upon installation to speed up their loading.
The fix is to uninstall all /Profile assemblies from the GAC, by executing the following command in an elevated command prompt:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe uninstall * /profile
Adjust the framework version and bitness to match the .NET version installed on your machine.
If you see messages like Uninstalled assembly mscorlib. then you know that was the case.
The entire operation is also explained in the Troubleshooting section of the JustMock documentation.
I think this is because the Telerik.JustMock.dll isn't in the GAC, which is why when you add the reference you point it at the JustMock Libraries folder. Just add the Telerik.JustMock.dll in the Additional Files To Include option in NCrunch for your test projects.
Related
I've got a C# MsTest project that targets net48. I've change the project it tests to the newer style Microsoft.NET.Sdk csproj format and that went ok. Now I want to convert the unit test project too.
I get errors about namespace Microsoft.VisualStudio.TestTools.UnitTesting cannot be found: error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'
To solve that, I added the assembly reference to the csproj:
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
But I get errors that it can't be found.
warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
This was found ok when the old csproj format was used.
How can I get this assembly reference to be found, or what is the preferred way of making this work?
Here are 3 possible solutions:
Upgrade to MSTestV2 by adding the nuget packages MSTest.Framework and MSTest.TestAdapter.
CAVEAT: MSTestV2 only supports .NET Framework 4.5 and later.
Continue using MSTestV1 by helping visual studio find the Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll reference, by adding this to your csproj:
<PropertyGroup><AssemblySearchPaths></AssemblySearchPaths></PropertyGroup>
see this explanation for why that's necessary
Continue using MSTestV1 by browsing to the dll's path when adding the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Depending on your version of VS the path will be something like: Program Files\Microsoft Visual Studio\2019\Professional\Common7\IDE\PublicAssemblies
I used #2 because we target net40 and have multiple developers working on different versions of VS.
Add the nuget packages MSTest.TestFramework and MSTest.TestAdapter.
The test framework allows the unit tests to build and brings in the required namespaces. The second allows the test runner to find the tests in the project.
I upgraded to VS2015, and MVC was updated to 5.0.
I am able to build successfully on my local PC, but when I checkin to Visual Studio Online, and my CI build builds, it fails:
"The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)"
I've used nuget manager to remove, and re-install MVC on my project - same results.
Looking at my references in the project, all looks OK.
I also notice in the log before the error happens:
Installing 'Microsoft.AspNet.Razor 3.2.3'.
Installing 'Microsoft.AspNet.Mvc.FixedDisplayModes 5.0.0'.
Successfully installed 'Microsoft.AspNet.Mvc.FixedDisplayModes 5.0.0'.
Successfully installed 'Microsoft.AspNet.Razor 3.2.3'.
All packages listed in packages.config are already installed.
But it seems when it builds, it doesn't know what MVC is. How can I resolve this?
Late to the game here, but I was having a very similar issue: Error CS0246: The type or namespace name 'blank' could not be found (are you missing a using directive or an assembly reference?).
This was building locally but not in VSTS. My solution was to delete the reference under the project's references, and then just add it back in again. The reference was to a namespace in a local project to the solution. For some reason it was being found locally but not found when checked into and built on VSTS.
Deleting the reference and then re-adding it worked for me.
Check the version number mentioned in all web.config files. I mean also those in the view folders; that they match the version 5.2.3.0
Scan all your references and ensure, that all of them related to MVC have Copy Local property set true. Not only Mvc one.
I fixed this by removing all the folders within my Packages folder, leaving only repositories.config. This forces VSOnline to restore all the packages on each build.
I'm trying to install the Autofac nuget package in my project using the command
Install-Package -Prerelease Autofac
but it fails with the error
Install-Package : Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache.
I've tried re-installing .NET Framework 4.5.2 (which is the version my project targets) but got the message ".NET Framework 4.5.2 is already installed". However, searching C:\Windows\assembly\ for System.Runtime.dll doesn't find any exact matches (although there are a few instances of System.Runtime.ni.dll, which (seem to indicate) that they are really the same assembly...).
What can I do about this?
Update: apparently I was confused about the location of the GAC. Amy enlightened me, and searching in C:\Windows\Microsoft.NET\assembly instead I do find System.Runtime.dll. Why doesn't Visual Studio?
I had the same problem.
Found the solution here: https://github.com/aspnet/WebHooks/issues/18
To fix it, I added <Reference Include="System.Runtime"/> to the .csproj
file for the project, rebuilt it and it worked.
Please make sure that it is in the Global Assembly Cache.
That is an excessively unhelpful error message. It not only doesn't describe the real problem, it also leads you drastically astray to find a workaround. An assembly reference for a .NET Framework assembly must never come from the GAC. The kind of failure modes when it does can be exceedingly nasty to diagnose. Reference assemblies must come from the C:\Program Files (x86)\Reference Assemblies directory.
Looking at the .nuspec file for the Autofac nuget package you are trying to install, it supports two distinct targets. One is for DNXCore version 4.0.10-beta-22816. Hopefully you are not using it, that project is changing rapidly.
The other is .NET Portable, profile 259. Which allows your project to target .NET 4.5.x, Store, Phone80 and Phone81. What the blunt error message is telling you is that it has trouble finding that profile. Use Windows Explorer to have a look-see, the profile is stored in the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile\Profile259 directory. It has the required System.Runtime.dll reference assembly.
Well, surely it awol, I can't guess at the underlying reason.
They did make subtle mistakes in the .nuspec file. Do consider a more stable release of Autofac, you probably don't want to be a beta tester. And don't target 4.5.2, there is no point to that. It doesn't add anything interesting and forcing your user to update his .NET install is not very reasonable.
I have a project that is working perfectly on my computer, but when trying to build it on Team City i get the following build error for source files where i have
using System.Data.Entity;
using System.Data.Entity.Validation;
CS0234: The type or namespace name 'Validation' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)
Do I need to install Entity Framework manually on the server running Team City for this to work?
Update after activating Nuget Restore:
This must be some kind of configuration issue.
I can see in the build log that the build process is copying the .dll:
[Copy] Copying file from "D:\TeamCity\agent1\work\541c9f462afc285d\packages\EntityFramework.5.0.0\lib\net45\EntityFr amework.dll" to "bin\Release\EntityFramework.dll".
[16:51:55][Copy] Copying file from "D:\TeamCity\agent1\work\541c9f462afc285d\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.xml" to "bin\Release\EntityFramework.xml".
But shortly after, it is considering a bunch of different locations, but not including the bin\Release\EntityFramework.dll" folder.
Update 2:
Manually copying the .dll to the bin/release folder of my class library helped the build to pass, but obviously this is no viable solution, so will need to keep on finding out how to configure this correctly.
Update 3:
Never did find a satisfying solution for this I am sad to say, so any genius that can solve this are very welcome. :)
As an error suggested you are missing assembly. And as #Shriroop suggested this is in EF packge.
Before your compile step, add Nuget Installer step. There are few options you should set, Path to solution name and I suggest you use nuget 2.7+ and Restore mode: Restore.
To install latest nuget version in teamcity go to Administration > Nuget Settings > NuGet.exe and fetch latest version.
Here is a sample of NuGet Installer step: http://img.hihi.si/Upload/5PUm.png
I've added a Fakes assembly to my Visual Studio 2012 unit test project, corresponding to my application project (the System Under Test), as described in Peter Provost's article. However, the project will no longer build, on account of an unresolved type reference in the generated Fakes code:
The type or namespace name 'FieldDefinition' does not exist in the namespace 'bc::ProductStudio' (are you missing an assembly reference?)
[C:\Users\arvek\Projects\Project\Project.Tests\obj\Debug\Fakes\bc\f.csproj]
C:\Users\arvek\Projects\Project\Project.Tests\f.cs
What's going wrong here? From what I know, this is supposed to just work, so it would seem to me there's a bug in the Fakes facilities.
This bug is present in VS2013 as well. Link to MSDN bug.
Work Around: Delete file .messages from FakeAssemblies folder.
The error is most likely due to bug in Fakes triggered by the faked assembly. I've submitted the issue to Microsoft.
One option that may help you diagnose the issue is turning on diagnostics for you fakes. On your .fakes file.
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011" Diagnostic="true" Verbosity="Noisy">
Also, make sure that your "MSBuild project build output verbosity" is set to Diagnostic. You can find this in Tools -> Options -> Projects and Solutions -> Build and Run.
Rebuild you test project and now your output window should be full of info including any failures for Fakes
Deleting Fakes folder will resolve this issue.
You're not going to believe this, but I was able to get the fakes working again by simply adding a new line to the file, removing that new line, and then saving what is effectively an unmodified file. After the next build everything was fine.
Things that make you go... hmm...