Missing a using directive or an assembly reference error when I'm not missing anything - visual-studio-2005

I have a solution with 4 projects. In the first one I reference the other three, not with Browse, but with Add reference->Project tab.
I have all three using statements in the beginning.
The program works fine. I tested it and it works. But I'm not able to build it.
I get the error "Missing a using directive or an assembly reference".
None of my projects are on client profile. (I think .Net 2.0 doesn't even have client profile).
Why is VS doing this? How to resolve it?

Clean build was the solution. Duh.

Related

Deleted files gives CS0246 compiler error in VS2022

I've added 3 default Blazor projects to my solution.
Blazor WebAssembly1
Blazor WebAsssembly2
Blazor Server
The first WebAssembly project is converted to a razor library in order to share code between server and webassembly projects. I also deleted the default pages like FetchData.razor and such.
On compilation I still get compile error on this (the app runs fine though), and I can't seem to resolve them. I've search through the entire solution but can't find any of the files that results in the compile errors.
How to locate the reason for the errors and remove the references? The files are deleted from the project.
Example of compiler error:
CS0246 The type or namepace 'WeatherForecastService' could not be found (are you missing a using directive or an assembly reference?)
The errors in FetchData indicate a problem with the using statements.
Try to check if you have global using, try to remove and declare explicit in the razor page.
Check your CSPROJ and verify the project type, in the RCL the type must be:
<Project Sdk="Microsoft.NET.Sdk.Razor">
In the RCL you haven't a Program/App structure, you have only components and wwwroot elements.
My RCL is composed as follow:
I have also a _Imports.razor with:
#using Microsoft.AspNetCore.Components.Web
...
The issue resolved itself when I restarted Visual Studio.
Sorry for the wild goose chase

Error MT2001: Could not link assemblies. Reason: Error while processing references

I'm getting this error trying to build a Xamarin.iOS project referencing a .NET Standard 2.0 library.
None of the MT2001 issues online seem to have this specific "Error while processing references" reason, so I'm at a loss as to how to diagnose this. I've tweaked and fiddled about as much as any one person can and stay sane, but I'm really in the dark.
Can anyone out there point me in a direction?
Adding -v -v -v -v to "Additional mtouch arguments" in the project iOS Build settings will help diagnose the issue. After that, you can search the build output for MT2001 and view the inner exceptions. Obviously, each project may differ as to what assembly causes the linker to fail. You may need to add, remove or fix your references based on the output.
For example, I was trying to use SignalR from AspNetCore 2.1, which has a dependency on System.Threading.Tasks.Extensions 4.5.1 in my project, which it seems Mono does not yet support. Mono does not provide its own version of the assembly yet, so when mtouch goes to link the assembly, it's unable to do so and throws an exception:
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Removing all references to this assembly (and therefore the whole feauture in my case) allowed the build and linking to succeed.
I've found that I get this when using a Xamarin library that is dependent on System.Reactive 4.1.0. There's a bug in there associated with System.Threading.Tasks.Extensions, and since it is a library I'm writing, I had to roll back to System.Reactive 4.0.0.
For me the error is as follows.
one of the package is mentioned in package.config file but it was not available in packages. So i added the missing package from nuget and the app works fine

GENERATEFAKES fails with CS0234

My project builds for my teammates, but not for me.
Project:
Errors:
I deleted reference to mscorlib fake, recreated Fake for System, but got the same error.
If I try to add reference to mscorlib, I get message:
A reference to
'C:\Windows\Microsoft.NET\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
could not be added. This component is already automatically referenced
by the build system.
I tried to add <Reference Include="mscorlib" /> to the project file, but this did not resolve the issue.
I use VS 2017.
Will appreciate any clue.
Thank you #Abhitej, for the answer. It resolved the issue. In addition to switching to higher version of framework I added tags like <Remove FullName="System.Security.Cryptography.CryptoStream"/> for each failing class to both ShimGeneration and StubGeneration in .fakes file.
In most cases like this one its tied to the version of .Net Framework installed on the box. As long as your test project targets the highest version of the Framework on your box, this should work out. Also when dealing with System* namespace please be sure to only generate fakes for types you need excluding others. That should help Fakes deal with API changes over versions and resolve any build errors you might be seeing because of this.
-Abhitej.

Resharper 7: MSTest not working - "Test wasn't run"

Since I upgraded to VS2012 and Resharper 7, my previously working MS Tests are not running anymore.
The tests are run in an ASP.NET environment. I use the following Attributes:
[TestMethod]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\Projekte\\****\\Website", "/")]
[UrlToTest("http://localhost:7924/")]
Any idea how to fix this?
As odd as it is, using VS2012, using Resharper 8.0, using NUnit, I was receiving this error because of an entry in my app.config file. I added an EntityFramework connection string and this behavior started. Removing the entire connection strings section shows the test runner starts/works again. Viewing output shows the app.config is not valid - this was causing this specific behavior in the test runner - "Test wasn't run".
I had the testproject set to AnyCPU and the project set explicitly to x86 when this happened. Setting the testproject to x86 solved it for me.
I'm using VS2012 R#8 and nUnit
Try running the Unit Tests using the MSTest Test Explorer. You might find more details in the output window of the root cause.
For me, it was a referenced assembly that was using a more recent version of NUnit than the one that was referenced in the test project. Using the same up-to-date version fixed the problem.
System.IO.FileLoadException: Could not load file or assembly 'nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
I'd same problem I just..
Changed methods access modifier from private to public.
Removed static keyword from methods.
That's it. It worked for me. But that is for C#.
In my case it was the NUnitTestAdapter nuget that needed to be removed.
Check that any references that you have in the test project are set to Copy Local True.
I had the same problem. Couldn't get the Visual Studio test runner to work, so I tried debugging a test instead. This threw a ConfigurationErrorsException, which didn't have much of a stack trace but contained the phrase "ClientSettingProvider". I searched my solution and found that something had added a appSetting key for "ClientSettingProvider.ServiceUri" to my app.config. I deleted this (along with an empty connectionStrings element) and rebuild everything - fixed the problem!
Double check your app.config and try deleting any empty elements or anything that looks fishy.
Another (silly) problem it might be; I accidentally had the project set to not build. Go to Build/"Configuration Manager", and ensure the project is set to build.
Using VS2010 and ReSharper 9.1 the issue was that the file LocalTestRun.testrunconfig was missing but was referenced in my .vsmdi file.
The test without VS were running properly but I always had the "Test wasn't run" error in ReSharper test UI.
So I simply restored my old LocalTestRun.testrunconfig file and everything run perfectly.
I probably could have updated my .vsmdi file to not reference the missing file... I did not test that.
On VS2012, Test Project don't work on Shared Folders like \XXXXXX\XXX
I solved it copied the Test Project on local devices.
Good Luck
I found that the settings file for the unit test may need checking as to which one is being pointed to by ReSharper. I had the same thing happening and it was down to my unit tests for the RS Harness pointing to the wrong file.
I had the same issue because the test class name had the characters '<' and '>' in it (also '(' and ')' caused this issue).
Removing those symbols fixed the problem.
I could use symbols in identifiers thanks to F#'s Unicode support.
I had the exact same issue and nothing helped.
eventually I saw that I had a mismatch in my namespaces of the unit project and the unit test project.
The namespace of my unit project is unit.project and the test project was named unit.project.tests but the default namespace of the test was the same as the unit, both was unit.project.
Once I've updated the namespaces to be different (one namespace for each project) everything worked!
I had a similar problem with NUnit test, which would not be executed, but R# would only mark them as "Test wasn't run".
Executing them with the native NUnit runner revealed, that the app.config file had an error (actually, 2 ConnectionString sections). Fixing this also made the tests running in R# test runner.
I kept getting "Test wasn't run" in Resharper.. I tried all the recommendations but nothing worked. What solved it for me was running Visual Studio as Administrator. (VS2013 w/ Resharper 8.1)
Just an excerpt from MSDN regarding
Assert.Inconclusive:
The code generated by Visual Studio when creating unit tests includes
an Inconclusive statement as a placeholder.
It happens if something is wrong with the solution, the most often a misconfiguration, like wrong or mismatched namespaces, inconsistent build targets etc, what leads to the fact that UnitTestExplorer is unable to use provided unit tests properly. So the general solution is to check latest changes and fix errors.
I had the same problem in C#: Unit tests run by ReSharper all just stopped with "Test wasn't run". No other information.
It turned out to be due to my custom section in App.Config. Removing that and it worked.
Configuration: Visual Studio C# 12, ReSharper 8.2.3
It could be also that Your solution contains multiple versions of i.e. nUnit installed in different projects. In my case this was the reason of the problems. After unifying the nUnit version in the solution, the problem was gone.
Just to add to this, I had written over my app.config file with a new one that was missing some sections I needed. I added the sections back in, at which point I got this same error in resharper. Thanks to the comments above I compared it to an older version and found that I was missing the section names in the configSections.

Custom building SGEN assemblies and including in installer

I've been rather confused by some SGEN stuff. I've enable the generation of serialization assemblies for one of my projects. Originally I got the follow error which I believe I've solved by doing some caspol stuff on a remote assembly.
Unable to load one or more of the request types. Retrieve the
LoaderExceptions propery for more information
Now however, I don't get an assembly generated. Adding some debugging/verbose output provides the message "SS.dll does not contain any types that can be serialized using XmlSerializer". I've read that this is because of a proxy switch applied by VS. The odd thing is it doesn't seem to be a problem with any other project.
So if I disable the proxy switch (example here) it seems to work. The linked build events however seem to do all projects. I don't know enough about MSBuild to tweak to just a single project, does anyone know what I need to change?
Additionally, if this change is made, is there a way I can automatically include this in a installer (VDProj)? I can't statically link to the SS.XmlSerializers.dll because the each dev uses a custom path.
Discovered the following post which talks about adding the <SGenUseProxyTypes>Off</SGenUseProxyTypes> to the csproj file which seems to work :)

Resources