I've been having this weird problem in my WPF project. I keep getting errors of the following format: The name "..." does not exist in the namespace "clr-namespace:..."
Here's a screenshot of what it actually looks like: http://i.stack.imgur.com/wrJQk.png
I've tried pretty much everything: Restarting visual studio, cleaning the solution, rebuilding the solution, reverting to an earlier point in git commit history, moving files around etc. And yes, I've done some research before posing my question here, none of the 'solutions' that I came across worked for me.
In my eyes, these errors shouldn't pop up at all as these namespaces/files simply exist and visual studio should not have any problems finding them. Here's the project on github if you're looking for more information: https://github.com/Reverp/Toxy
Now here's the fun part, visual studio can build/debug the project just fine. The only thing that doesn't work is the design view because of 'invalid markup'. But it gets even weirder, after trying it on different machines, some seemed to have the same issues but others didn't have them at all. The machines that didn't have this problem were all running Windows 8 (my machine runs 8.1), but that shouldn't matter, right?
Also, once I start working on the project despite the errors, more similar errors will start to pop up over time!
In case you want to try to reproduce this you should do the following: Clone the repository, open the solution file in visual studio and open MainWindow.xaml. After that, the errors should appear.
Has anyone had this issue before and/or do you know how to resolve it?
Thanks in advance.
Looking at your code on Github, your friend class takes a parameter on construction. Since your error is in XAML, I am guessing that parameter is not being set.
Try adding a parameterless constructor to the three types causing the issue and see if they resolve.
You will have to pass the MainViewModel as a property assignment:
<viewModels:MainViewModel x:Key="myViewModel" />
... to create an instance of your main view model
<viewModels:FriendControlViewModel x:Key="friends" MainViewModel="{StaticResource myMainViewModel}" />
... to link that to your friends :)
I know this isn't directly linked to your error, but XAML does tend to throw a wobble if there is an issue in the code - but doesn't relay that back in the error.
Related
Sometimes my class is becoming highlighted for a few second but soon the problem shows again. I tried build cleaaning, restoring visual studio, deleting my pages as I saw some people had similar issues and it was because of the xaml files.
Everything was great until last week.
I haven't noticed the reason of this bug. Also i tried using different namespaces and changed some folders, created new classes. Nothing helped
Please help me fix it as I have a lot of code to be done and my inspiration dies every time I see my class with white color)
This bug appears while using XamarinCommunityToolkit since version 1.3.2
https://github.com/xamarin/XamarinCommunityToolkit/issues/1815
While trying to do test driven development in vs code. I have the tester code in one window and the code I'm testing in another. The tester and program are different projects with the tester referencing the program.
I have to reopen the window I'm the writing test in to have vs code stop underlining errors I've fixed or show errors I've just introduced in the programs code (which the tester code is referencing).
I've tried to restore, build, and clean my test to have vs code detect the changes. I've also reset the settings in vs code to see if that was the problem. Only closing the window and reopening works.
Is there a simpler way to get vs code to detect that the issue is fixed?
P.S.
I'm writing in C# if that matters.
Also sorry if there are any issues with the way I've asked this question it's my first and if there's any feedback I'd be happy to hear it.
Ok, I seem to have found a fix for the issue so I'm posting it here.
I've added the parent folder containing both projects to a workspace and now it updates when I fix or break something.
P.S.
This may not be the correct way to do this if it isn't let me know.
What might cause an ASP.Net Core web application to display hundreds of build errors suddenly without explanation? I started working on an app I had not worked on for awhile and when I clicked publish I got hundreds of build errors that never existed before.
Some were quite simple. Like this block of code used for a Blazor component (file extention .razor) that never had problems before. This block displays red squiggly lined underneath both instances of the string "crumbicon" I can think of no reason why there would be a problem with this:
#using PostAlmostAnything.Models
#crumbiconHome
#code {
string crumbicon = "<<";
}
The exact errors say that there is "ambiguity between filename.crumbicon and filename.crumbicon "the type [blazor file name] already contains a definition for crumbicon". This error has never been encountered before, but now exists on every .razor file that was designed this way.
The other error appear related to various assemblies or variables on pages. They typically say that something has already been defined someplace else, but if the code were the problem then it would have been an error long ago and not suddenly.
When I try to update Nuget packages they say the updates are not compatible with version 3.1 of .Net Core.
Try to close Visual Studio and reopen. That always works for me to get the libraries back
Short version: jiggle it until it works.
This happens a lot. I think it's a conflict between an old assembly that didn't get cleared out of Intellisense and a new one or something like that. You can try any / some of:
clean and rebuild
close all open files and re-open them
just ignore the errors and run the app
delete the bin folder from your project
restart Visual Studio
go get yourself a coffee and wait for Visual Studio to figure it out
on its own
Visual Studio is never stable nowadays.
Try cleaning and rebuilding or cleaning obj and bin directories. this may help too
Of course, try the other suggestions mentioned in the other great answers here.
Another option is to comment out the offending lines that are giving you problems, then rebuild. Keep commenting/building until it works. Once it builds and starts again, uncomment sections one at a time until you are back up and running.
As an extra bonus you may find an errant "}" or missing tag that helped cause the issue in the first place.
I am working with a Xamarin application where I have already built both IOS and Android applications. I am using Visual Studio 2019 for the development and use iPhoneSimulator to test the application, after connecting to the mac device. Suddenly I am getting an error as preceding.
Error The file 'Resources/LaunchScreen.xib' conflicts with 'Resources/LaunchScreen.xib'.
Anyone ever faced this issue before, I am 100% sure that it is not related to any recent code changes, thus providing codes wouldn't help here.
As I was sure that the issue is not related to the recent code changes. I did the preceding things first.
Clean the solution and rebuild
Delete the bin and obj folder manually and then rebuild
But I was getting the error again, the only thing which worked for me is restarting the visual studio and open the project again. Hope it helps.
I get this error a lot, or various other errors that seem to be related with items being duplicated. The easiest fix is to just disconnect from the Mac and reconnect. This is assuming that you are developing on a PC and pairing to a Mac. I suggested to the developers that they simply include disconnecting and reconnecting as part of the build process until they can figure out the actual cause.
If you are on the actual Mac, the process that Sibeesh Venu describes may be what occurs each time Xamarin pairs with the Mac.
The developers asked me, and others that have reported this issue, to turn on diagnostic debugging so that they can be provided with a log for when it happens. I did this, and noticed that it occurs less frequently for me. This makes me suspect that it's related to timing when files are processed.
https://github.com/xamarin/xamarin-macios/issues/6770#issuecomment-575310911
I encountered this same issue after after doing a merge in source control. It turns out that there was a duplicate instance of the .xib registration in my iOS.csproj file. In other words, there were duplicate lines that looked like this:
<InterfaceDefinition Include="Resources/LaunchScreen.xib.xib" />
Once I removed the duplicates, everything worked perfectly.
For anyone that doesn't already know what a tag helper is. This is what a tag helper is.
<input asp-for="Forename" class="form-control" />
Previously, when I begun typing "asp-for" intelisense would suggest all the properties of the model. As you can imagine, this was extremely useful.
However, not only has intelisense stopped working, but Visual Studio seems to have completely forgotten that tag helpers exist.
Previously, these tag helpers were shown in green, and they would be flagged up as errors if the property you'd used, for example, did not exist.
Now, I have no such luck. Visual studio now just renders them the same it would any other HTML element.
How they look now:
How they should look: (taken on another computer)
Importantly these tag helpers -do- work. The ones that I wrote before the problem work fine, and if I manually and very carefully copy paste the names of the model properties over, they work fine too. This is just an extremely inefficient way of doing it, and makes things hard to debug when something goes wrong.
Additional Information
This is not a code problem. This is a project, and everyone is using the same project. It works perfectly for them
I have reinstalled the ASP.NET stuff in the VS installer, I have "repaired" my install of Visual Studio, then I reinstalled Visual Studio by uninstalling it and reinstalling. I have no plugins running.
Another bizarre factor here is that this problem started out intermittent, being fixed when I closed and re-opened the project, then being fixed when I restarted the computer, and then eventually not working at all, ever.
In case anyone finds this in the future, I never did solve the issue. However I did find the source of the problem.
It was something to do with the project file, although I have no idea what was actually wrong with it.
I fixed the issue by transfering all the files into a new project (with a non-broken project file) and then re-installing all the nuget packages. I wish I could have found a better way of doing this, but I couldn't. Hope this helps if you're ever in this situation.