Visual Studio solution explorer incorrectly identifies classes as custom controls - visual-studio

I have a project in Visual Studio which is misidentifying some of the files as 'user controls' as opposed to code-only classes. The project compiles and runs just fine, but it does leave a slightly annoying issue that when these files are double-clicked, the designer window is presented instead of the code editor.
Obviously, there are plenty of ways to get to the editor but, firstly it's annoying, and secondly, I don't know if this could lead to other issues later down the road so I'd like to resolve the problem sooner rather than later.
As you can see from the screenshot, there are 5 files, all of which are code-only classes, yet 4 of them are identified as custom-controls by the solutions explorer; only the final one is identified correctly.

Related

Small Basic - When would 'Graduate' be used?

So today I decided to take a look at the Graduate feature in small basic, I discovered that it allows you to convert your small basic code to a format for Visual Studio, Great I thought.
Until when I later tried it, Visual Studio reported that there were over 102 errors with the code, I found that this was because the compiler couldn't understand most of the small basic functions like GraphicsWindow, TextWindow, Mouse, Shapes etc. So, have I done wrong? As Visual Studio is my main programming language I couldn’t wait for the small basic code to be magically converted to work with VS. Some of the code could be manually translated such like TextWindow to Console, but what do you do with code that is specific to Small Basic like GraphicsWindow?
You are using the Graduate feature correctly, and you haven't done anything wrong; the reason you're getting errors is because Visual Studio doesn't seem to automatically import SmallBasicLibrary.dll correctly. The last time I used Graduate (~2 years ago) this wasn't a problem, so I imagine this issue is a result of Visual Studio updates.
Thankfully, this issue is easy to fix. You simply need to import SmallBasicLibrary.dll manually and then add a single line to the top of your Visual Basic code. Note that these instructions are for Visual Studio Community 2013, but I would imagine they're the same for most recent versions.
In Visual Studio, go to Project > [Project Name] Properties.
In the tab that opens, go to References on the side panel. Select SmallBasicLibrary in the list and click Remove.
Click the Add button (next to Remove), then in the window that opens select Browse in the side panel. Now click the Browse button at the bottom of the window.
Find SmallBasicLibrary.dll in your Small Basic installation folder (for me this was C:\Program Files (x86)\Microsoft\Small Basic) and double-click it. When you are taken back to the Reference Manager window, ensure that SmallBasicLibrary.dll has its checkbox checked, then click OK.
Select Application in the side panel and ensure that the targeted version of the .NET framework is 4.5.
Finally, open your Visual Basic code using the Solution Explorer and add this line to the top of it:
Imports Microsoft.SmallBasic.Library
The resulting code should look something like the following:
Imports Microsoft.SmallBasic.Library
Module UntitledModule
Sub Main()
TextWindow.WriteLine("Test")
TextWindow.Pause()
' Your Small Basic code here...
End Sub
End Module
All your build errors should be gone, as the Small Basic commands are now available.
Once you've done this, Graduate is ideal for using VB-exclusive commands or libraries along with your Small Basic code.

How do I get Visual Studio default icons in a custom project type without using MPF?

I'm creating a custom project type in Visual Studio; and currently all icons appear as placeholders. There are properties that Visual Studio requests that allow me to define the icons (_VSHPROPID Enumeration)
__VSHPROPID.VSHPROPID_IconImgList:
__VSHPROPID.VSHPROPID_IconHandle:
__VSHPROPID.VSHPROPID_IconIndex:
In the MPF sample from Microsoft; they return the same values as me (null) for the above properties, yet the default icons (eg. .cs) appear correctly!
I've spent many hours trying to strip MPF down (it's enourmous; with many tens of thousands of lines of code) but it either continues to work; or I remove something that causes it to fail to create the new project without a useful error/stack.
It seems that in addition to implemented IVsHierarchy, you need to implement the GetAutomationObjects and return ProjectItems too.
That's how MPF and some others do it, anyway. I was unable to make it work, so I'm giving up!

Microsoft visual studio screen problem

I am having a problem thats not about the code, it's about the screen in Microsoft visual studio 2008.
Actually problem is i created one utility from couple of weeks i didn't opened that utility today i opened (in Microsoft visual studio the screen appearing blank no controls are visible in that.But all the controls properties are there. I tried a lot but i didn't get solution. Last when the same thing happened i created the controls again. Now i don't want to go to create all the controls again. If any one have the solution please help me.
Before screen is like this:
Now its blank (like new page)
From your description I'm not sure if this is a application/code build issue or an IDE issue, what you could try is to reset the settings in visual studio and see if this helps.
You can do this by going to Tools -> Import/Export settings and then following the wizard to reset the settings, you may also want to perform a backup before resetting them (this is also part of the wizard) then they can be restored if this causes you further issues.
I don't have a copy of 2008 available at the moment so some menu entries may be slightly named different.
Hope this helps!
EDIT:
Now there is more information, this looks like there may be a problem with the code in the
InitializeComponent
method of the form.designer file (e.g. if you are using c# this would be something like Form1.Designer.cs and can be found by expanding the corresponding form in the solution explorer), if you remove/comment the lines that say
this.Controls.Add(this.NameOfControl)
(NameOfControl is where you would see your declared controls name)
then you get the behaviour that you are seeing, the controls do not render as they are never added to the forms controls collection but as they are declared you will still see them in the properties drop down and wont be able to add another control with the same name.

Visual Studio designer stops recognising changes occasionally

Using VS2008 visual designer occasionally the designer seems to stop recognising changes. Normally you get a * next to the filename in the tabs when a change is made but sometimes this stops appearing when I am making changes. When this happens may changes are getting "lost" so if I close/reopen the file all my changes are gone.
Has anyone else encountered this and know why it happens and if there's a fix/workaround?
Cheers.
We ran into a similar problem in Visual Studio 2010. When attempting to resize a user control, the designer simply refused to recognize that a change was made (no * shown), and when you rebuilt, all source file changes were lost.
I found this link from another person having the same problem.
After stepping back through source control and comparing the .designer.cs file for the user control and its child controls, it turned out to be the same problem. At some point, the line:
this.components = new System.ComponentModel.Container();
disappeared from the designer file of one of the child controls (not the user control that I was having problems with). Incidentally, within that designer file, all of the references to "this.components" were also removed.
After fixing the child control (restoring the creation of this.components, and fixing the original references), the top level user control then started recognizing changes again.
We're not sure what caused the corruption of the child control. Perhaps it was a source code merge or a designer bug.
It's a very difficult problem to debug. Even if you attach a debugger to debug the design time behavior of the user control (and its children), there are no exceptions thrown and there is no indication that anything is wrong.

Visual studio 2008 Professional Edition acting weird

I have a weird situation on a winform project.
I have user control (with 600 lines of code around) with a datagridview. I change de ColumnHeaderStyle of the font and save it. After I save the file I close it and open again, the changes were not saved (although the asterisk is dissapeared), because the ColumnHeaderStyle is back to the former value. This is driving me crazy because I cannot change any visual thing in the Designer.
Any clue?
Thanks in advance.
I've had occasional very strange behaviour with VS2008 developing WinForms apps too. Mostly designers that won't display (even though nothing has changed), but I've had cases of disappearing controls, too (and hence compilations that won't complete since code then refers to controls that are no longer being created). All very irritating.
Assuming that you've done all the standard things, like Cleaning the solution (on the Solution's context menu), deleting all the relevant Bin and Obj folders (no idea why this would cures VS weirdnesses, but it sometimes does) and rebuilding (ensuring that the Designer for your user control is closed when you rebuild)...
... you might try looking through the designer code for some strange 'bonus' controls that apparently have nothing to with you.
In one particularly intractable case, I eventually noticed some controls with names like Button_01, Button_02, etc, whose origin I couldn't identify. They were being defined but not instantiated, and not being added to any controls collections, and I just deleted all references to them.
When I recompiled, they didn't come back, and VS was behaving itself again.
I can't explain it, but it worked that time, and I offer it as an example of VS gremlins that seem to have rather irrational solutions.
Maybe it was just a strange planetary arrangement that did it, I guess I'll never know.

Resources