Missing "Define debug and define trace constant" checkbox in visual studio 2022 - visual-studio-2022

I'm missing two checkboxes for defining constants in my properties screen. Am I missing something?
It should look like this
I'm using a Microsoft.NET.Sdk.Web project in net6.0

Somewhere along the way, Visual Studio streamlined these options to what you are seeing instead of what you are expecting to see. Actually, I don't think this is a Visual Studio-specific change, but rather it depends on what kind of project and what SDK you are using - those being:
.NET Framework
.NET (.NET Core)
I am guessing you are coming from one of my other answers, which sparked you to ask this question. In my post, that screenshot is from a .NET Framework project. I should have probably been slightly more specific in my reply to you. In your project, you are clearly using .NET 6 (as you mentioned above). Because of that, your properties menu looks way different. This is the streamlining I am talking about.
So where are your checkboxes for defining DEBUG and TRACE constants? They are gone! However, you are looking right at the control that replaced them - or rather, you are looking at how these controls work now. Essentially, the $(DefineConstants) replaces these checkboxes, and you can specify additional constants in the same textbox, separating each by a semicolon. If you hover over the "Conditional compilation symbols" controls and click the gear icon, you can toggle it to vary by configuration, which I think is more clear and useful to do:
Then, if you wish to add custom constants, simply add them to the configurations. In the below screenshot, I added an ONLY_DEBUG to the Debug configuration, and an ONLY_Release in the Release configuration:
In the code, you can use them as so:
Microsoft Documentation can be found here.

Related

Highlight things marked as obsolete

I recently did some refactoring in our code and marked some widely-used functions as obsolete. The problem now is, that I get not visual indicator when I use an obsolete function right away. I have to hover over the function call to get the popup with further information about that function, and even there the "deprecated" warning is not very prominent. As these functions are to widely-used and cause no real treat, setting the isError property is not an option.
I know that somewhere I saw obsolete functions that were highlighted with some kind of underlining, but I can not find an option that does that. Where is that option, or how else can I achieve a more eye-catching indication?
I have created a simple toy VB.Net console application in MSVS, as you can see in the image the items marked obsolete are underlined in green where they are used.
If you are not seeing this then you will need to provide some more details on your solution's settings - what type of project is it, what version of visual studio are you opening it in, is it the same version it was created in, do you have any third party code linter (eg ReSharper) in use... etc
EDIT: As you mention in your comment, the project's properties, including the Code Analysis settings, will affect whether this underlining show's correctly or not; you will need to ensure the correct rule-set is selected there.

VB.NET RowCount not an accessible property of DataGridView? [duplicate]

I am using VB.NET in Visual Studio Community 2017. I noticed that in some cases the list of available properties and methods for an object is incomplete.
One example can be seen here:
As depicted, I want to use the RowCount property of the dgv object, that is of type System.Windows.Forms.DataGridView. You can see, that right above it the property is there and working fine, I can just type it by hand. It just takes a second or two, before the background compiler (for lack of better term) acknowledges it as correct. The behavior messes up the typing flow, since often IntelliSense autocorrects what it perceives as typos.
Note: This is not exclusive to the shown property. I noticed it for other examples, and also in function calls and other random places, but I could not find a clear methodology of what is missing and what isn't.
Looking around I found e.g. this question, however it deals with a completely different problem.
Is this just a bug in Visual Studio (and if so, is it reported somewhere?), can someone confirm this, and does someone know of a fix?
Followed your steps and I got the same result like yours, I already reported this issue to the VS Product Team, please check this: VS 2017--VB: the intellisense for the DataGridView control not works like VS 2015, you can vote it or add a comment, then we need to waiting for the confirmation from the VS Product Team, thank you for your feedback.
Meanwhile, I tried it in C#>Windows Forms application and the intellisense works fine just like the VS 2015.
Albano Gheller posted an answer on the Visual Studio Community page.
To quote him and the required step for a fix:
I've fixed the problem in this way:
1. I've exported my settings from Tool - Import/Export settings
2. I've set the property HideAdvancedMembers = true inside
<ToolsOptionsSubCategory name="Basic" RegisteredName="Basic" PackageName="Text Management Package">
because C# has true and works
3. I've imported this modified settings.
So to summarize:
Find the part: <PropertyValue name="HideAdvancedMembers">false</PropertyValue> in the exported settings document's Basic ToolsOptionsSubCategory.
Change this to <PropertyValue name="HideAdvancedMembers">true</PropertyValue>, save, and then reimport the settings.
I don't know why hiding members leads to showing more members, but whatever ;-)
In supplement to Jens answer/to save anyone else some work:
Take the following XML, which is the minimum set of settings required to flip the problem attribute:
<UserSettings>
<ApplicationIdentity version="15.0"/>
<ToolsOptions>
<ToolsOptionsCategory RegisteredName="TextEditor" name="TextEditor">
<ToolsOptionsSubCategory PackageName="Text Management Package" RegisteredName="Basic" name="Basic">
<PropertyValue name="HideAdvancedMembers">true</PropertyValue>
</ToolsOptionsSubCategory>
</ToolsOptionsCategory>
</ToolsOptions>
</UserSettings>
Save it on the desktop in a file called a.vssettings
Go to Tools.. Import and Export Settings
Choose Import
Choose No, just import
Browse for the file you saved, do Next, Finish
I presume that there's a bug in VS where they got the boolean logic upside down for the intellisense, and advanced members are hidden when this attrib is false and shown when it's true

VB2010 Unable to open two applications derived from same code at the same time

This may be a simple question, but I'm not even sure of the search terms to find the answer.
I have two winforms applications which have been derived from the same code. One supersedes the other, but occasionally we have to us the older VB app for legacy information.
The problem is, if one app is already open, when the icon of the other app is clicked, nothing happens. The currently open app's window becomes selected like it has just been opened. Nothing else.
What I would like to happen is that both apps can open at the same time. They reference different DB's so there's not clash there.
I thought it might be something to do with the name spaces, so I changed those, but to no avail.
Any thoughts, I'm sure its a simple answer.
Mark
Look at Project Settings (Double Click on "My Project" in the Project Explorer).
In the Application-Tab you'll find the setting "Create Single Instance Application"
(I'm translating from German Version, may be slighlty different).
Better Alternative:
Basicly it is useful to keep this setting as it is and go for the alternative:
In that same spot, you find a button "Assembly Information". Click on that and change the first number of the "Assembly Version". Now the older and newer versions are two different programs for Windows and will run parallel.
Go to, 'project properties', Tab 'Application', section 'Windows application framework properties'. There is a checkbox called 'Make single instance application'. Maybe that's on...
I had the same problem with two applications. They had different assembly versions and I wanted to avoid unchecking "Make single instance application", so I kept looking until I found that they had the same GUID. Just changed one of them and problem solved. You can change the GUID in the Assembly Information dialog. Hope it helps.

Inspecting XAML in Windows 8 Store Apps / VS2012

I'm looking for a way to inspect running XAML in a Windows 8 store app. Essentially, I want firebug / chrome inspector style functionality where I can look at the XAML source generated at runtime, to debug simple layout and style issues.
I've tried Snoop, Pistachio and WPF Inspector but none work for Windows Store apps. The only one I can find which seems to work for Store apps is XAML Spy, which is €90. I can't justify that cost.
Is there any other way to inspect running XAML?
WinRT XAML Toolkit now has an actual visual - visual tree debugger.
Get it from NuGet: nuget.org/packages/winrtxamltoolkit.Debugging then call WinRTXamlToolkit.Debugging.DC.ShowVisualTree() to display the debugger tool inside of your app. It's the third option so now you can use
the WinRTXAMLToolkit.Debugging.VisualTreeDebugger class - that enables you to debug the tree in your Visual Studio
XAML Spy - which is a great commercial visual tree debugger that runs in a separate window
and now this visual tree debugger in the WinRT XAML Toolkit that works inside of your app.
The VisualTreeDebugger class from WinRT XAML Toolkit is what you could use if you want a free tool. It doesn't do as much as XAML Spy, but you get what you pay for. I thought of adding more features to it like actual visualization of what you debug, but the work required would not justify the time investment + I didn't want to step on Koen Zwikstra's turf. I am sure he is doing a great job on that tool. Anyways - VisualTreeDebugger is enough for me, so maybe it would also be enough for you.
The way you can use it is add the class to your code, add a reference in your XAML like
xmlns:debug="WinRTXamlToolkit.Debugging"
then put a hook on a control where you would like to start debugging, like
debug:VisualTreeDebugger.BreakOnLoaded="True"
which will dump the core visual tree details as text in your debugger output window (Ctrl+W,O) and break in the code that dumped your tree where you can investigate the "path" variable, which contains the list of all visual tree elements from the debugged control to the root, so you can watch their values if what you need wasn't already dumped in the output window.
Other options include
debug:VisualTreeDebugger.BreakOnTap="True"
debug:VisualTreeDebugger.BreakOnLayoutUpdated="True"
debug:VisualTreeDebugger.BreakOnLoaded="True"
debug:VisualTreeDebugger.TraceOnTap="True"
debug:VisualTreeDebugger.TraceOnLayoutUpdated="True"
debug:VisualTreeDebugger.TraceOnLoaded="True"
Since it is source code and really a single simple class - you can easily add additional things to the code to do any custom debugging you need.
XAML Spy is what you need. You find it at http://xamlspy.com.
there is a new free tool called XAML Inspector. It's available through NuGet. Just search for "xamlinspector" or get if from the project page: www.xamlinspector.com
Greetings
Christian

What happened to Intellisense for enum types in Visual Studio 2010 using VB.NET?

I am using Visual Studio 2010 Prof.
In C# I can create my own Enumerator and use it like this:
MyEnum value =
Now, Intellisense will suggest a value of MyEnum.
In VB, when I write:
Dim value As MyEnum =
I get a huge list of every types. When starting to write my enumerator value (could be a word like "sunny") it filters out some types but I would like to have it like in C#. Anyway I will use the MyEnum type and no "String nor Objecte nor IntPtr...".
Any idea?
Screenshot
Also I made a short video:
Video with sample (new)
Regards
Simple, all you have to do is click the "Common" tab at the bottom of the Intellisense drop-down.
To prove it, here's a screenshot of what I see in VS 2010, immediately after typing =:
But, even if you have the "All" tab selected, the values defined in the enum will still be automatically displayed first, and even appear grouped together. You will indeed see all possible members and types, even those that are completely unrelated, but it's still pretty easy to find the ones you want.
And no, I'm not using any third-party add-ins or extensions to achieve the demonstrated feat. As best I can tell, I also haven't reconfigured any relevant options from the default settings.
This is a documented issue in VS 2010, pre-SP1. See: https://connect.microsoft.com/VisualStudio/feedback/details/551699/intellisense-enum-values. It has been fixed in SP1. If you can't install SP1, the only workaround is to use the mouse or Alt + , to switch from the "All" to the "Common" tab.