IntelliSense shows errors but still able to build - c#

Whenever I change something in any XAML file in my Solution every reference in the Code Behind file will be marked as an error and IntelliSense stops working. but if I build the Solution everything works fine and IntelliSense works. Also just the files which are currently open show this behavior. As soon as I close it the errors disappears.
Should I be worried?

The errors you see when opening/editing a XAML are somewhat by design. It tries to do a quick test if your markup is valid, but in my experience, especially when using advanced bindings with custom objects, it will fail more often than it doesn't. This check is done to prevent you get errors on run-time, since most of the XAML is run-time evaluated.
So what you should do is check the messages, if you sure they are okay, just continue and see if the code actually works. If you see this error often, just ignore it.

Related

C# Visual Studio Debug DoDragDrop causes Win32 Exception clipboard format registration did not suceed

So I've been trying to pass Tuple data types in the DoDragDrop method of a winforms control. This does not appear to possible. I do get a Win32 Exception saying that clipboard was unable to register the format. It works fine with other datatypes which are not Tuple.
Is there any way to pass a tuple in a DataObject?
This applies to both normal Tuples and Value Tuples.
This does not happen with every Tuple .... Currently the following has been observed:
Tuple<RefType, RefType> does not work
Tuple<RefType, baseType> does work
Tuple<RefType> does work
Tuple<object, object> does work
This appears to be somewhat specific to my project as I am currently unable to make a minimal example that shows the same behaviour ...
Apparently its specific to the solution. I did make a minimal test project in the solution the error appears in and made it an independent project that starts up by itself. The error happens. If I reference that project in a different solution and run it, the error does not happen.
The error also only happens in Debug mode. If I run the application outside of Visual Studio it does not happen.
It turned out that this had nothing to do with DoDragDrop or Tuples in the end.
Deleting the .vs folder inside the solution made the error go away. Apparently something was misconfigured/broken inside there. No clue what however.
You might try this if you run into a similar problem

C# After Debugging automatic saving

Hello guys I have a easy problem but I can't solve.
I open normal project and add something when I try to close without debugging client asks "Do you want to save" but when I use debug then I try to close project client don't ask "do you want to save" just saves automaticially I want to change this options i change a lot setting (tools>options) but I couldn't do it.this situation makes me crazy can you help ?
When you start debugging, it compiles the source code. In order to compile, it has to access the latest version of the files, so it has to save them, else the compiler (another program than Visual Studio) can't access them.
Conclusion: there is no way to change this unless you can change the entire working of Visual Studio and the compiler.
Sounds like you need to look into one of the Source Control options that will allow you to revert to older code if needed.

Permanently ignore winforms designer errors

I have a C# project in which the generated designer code throws an error at design time. Fixing the error requires me to modify the generated code, which gets overwritten every time I build.
The error is the generic full screen "To prevent possible data loss before loading the designer..." I can "ignore and continue" each time, but I can't seem to find a way to ignore it permanently.
Ignoring this permanently is highly dangerous and probably impossible. You'd be better served by determining the problem and fixing the bug in the offending control (assuming you are the author of that control -- if not, contact the author!).

VS 2005 Compile on Save C#

This is baffling me, I am unable to find this setting if it exists.
I am 90% sure that my code used to compile on save before.
I only started having this issue when using C#, .net worked fine.
But now I am only able to get rid of error lines etc, when choosing to enter debug mode.
For example when I have a method
public bool Method1(){
//No code added yet so I get a blue line saying return something
}
Even when I add what to return inside the method the line remains there on save. It only goes away when I build.
(This is just one example it seems to happen with lots of other things)
EDIT - In regards to options to compile on save.
The options in Build and Run are set Correctly
That should produce a red underline and an entry in the Error List window: "not all code paths return a value". It is produced by the IntelliSense parser, not the compiler. Saving the file does not remove the error hint, only opening another project does. And fixing the code of course.
There is a bug of sorts in this logic, in some cases the Error List doesn't get purged. The only workaround I've seen is to restart Visual Studio. I've only seen this with certain IntelliSense warnings and it only affects the Error List, not the editor. I can't remember the exact type of warning that triggers this, it only ever happened when opening a project with code I didn't write. These messages don't normally last long when I'm editing code. Which is by far the best solution.
Should it not be the other way around? Save on compile.
Anyway, you can simple change the ctrl+s key combination to build and save in the settings menu.

Reason for VS.NET 'current breakpoint will not be hit' warning?

Trying to debug a controllers action method, and when I attach to process the debug icon goes hollow and says the 'current breakpoint will not be hit'
But I am doing a response.write at that point and when the page renders it does output the test text.
So that section is indeed being executed, why does debug mode not work?
Your source code may be different than the version of the corresponding process that you are attaching to. Your other process may also be built in release mode, i.e., there is no debug info.
There are a few reasons why you may see this message:
You are attached to the wrong process
You are attached to the right process but the AppDomain hasn't loaded the assembly yet
You are attached to the right process but you have forgotten to build so the source code and the PDB file are out of sync
I've noticed this happen when using reflection and dynamically loading .dll projects. If the code isn't specifically reference (i.e. you are using interface animal but dynamically loading implementations of animal such as cat/dog) it will say it won't hit the breakpoint, but actually does.
I do not like to play with knives but the only thing that worked for me involves editing the .csproj file itself. So, unload the project file, edit it by cutting and pasting the three asp.net files so that they are together in the ItemGroup. However, sometimes it is necessary to go further as explained here: http://carnotaurus.tumblr.com/post/4130422114/visual-studio-debugging-issue-with-files-of-the-same - Also, I give a list of other proposed solutions that did not work for me. I hope it helps.
Another reason is when you attach to the process to quickly.
For example, when I attach to Excel to debug a VSTO add-in (I am using Add-In Express), if I Build, then Start > Run > Excel, then quickly press Ctrl+Alt+P to attach to process, then press E to highlight Excel and press Enter I see this, before Excel has loaded:
The result is no Breakpoints will be hit.
However, if I give Excel a couple of seconds to load and then press Ctrl+Alt+P, notice the Title is showing:
The result is Breakpoints will be hit.
It also tells me your source code is different from the version but it is not true. I build the whole solution, then attach to process, but still it says the breakpoints won't be hit because the source code is different. Maybe it is a bug?

Categories

Resources