I had an abstract class Foo. I want to get a list of classes that derive from it. All my searches are returning how to do it via code, and really I'm just wondering if there's some built in feature of VS that will do it for me... seems simple enough just to get a list for non-programming purposes. Thanks
In VS2012 Solution Explorer expand the file icon, right click the abstract class and click Derived Types.
Alternatively open the class in Class View, right click and Show Derived Classes.
Go to the abstract class, right click on the class name and select option "Find All References".
Right click on the name of your class and choose Find all references.
Related
I have take App_Code folder to my solution and added two more folders saying Business and Data. Now when I add a class to these folders the class added should be under the same namespace as name of the folder.
I,e If I add a class under Business that class should come under Business namespace.
similarly, If I add a class under Data that class should come under Data namespace.
I am bit new to this. Please help me in getting this done.
I think what might have gone on here is that you were in the Folder View of the Solution Explorer when you made your classes.
If you click the icon to the right of the home icon in the Solution Explorer Toolbar (see the image below), then you should be able to switch back to the Solution View. Now when you add a class the correct namespace will be generated automatically in the template. A lot of other convenient features are not available when making new classes in the Folder View, too, not exactly sure why!
"Switch between solutions and available views"
I know this is an old question, but I had the same problem and couldn't find any solutions in all my googling, so I felt I had to answer.
I have a class diagram in C# and to test it out I'd like to use it to generate code and then go back and edit it. So I need to be able to go back and forth, generate code, update class diagram, rinse repeat.
However, for some reason I was only able to generate code once. If I try to generate code again it says "another project might exist in the same solution". How can I get around this?
Also when I update the generated code I'd like it to update the class diagram. Is that possible?
Thank you.
The difference is a .cd vs a .classdiagram. The .classdiagram does not update dynamically. The .cd or "logical class designer" does.
I have a class that inherits the built in System.Windows.Forms.Panel class. According to the metadata of the Panel class, it has an attribute named Designer. I am assuming this is what is causing my derived class to open in the form designer by default, rather than the code view. Is there a way I can override this attribute so that the file opens in code view?
I've found the answer. Thanks goes to Visual Studio: Make view code default using attribute.
[System.ComponentModel.DesignerCategory("")]
You could simply right-click and select "View Code" in VS, either in the Solution Explorer or in the designer view.
I found some code to help me in a project and when I first ran the code I received an error message indicating: "Visual Studio cannot start debugging because the debug target c:\path\'dirInfo.exe' is missing. Please build the project and retry, or set the OutPath and AssemblyName properties appropriately to point at the correct location for the target assembly."
Then I select OK and receive an error message indicating that partial is missing. I add partial to the code and receive 3 more error messages.
The type 'RecursiveSearchCS.Form1' already contains a definition for 'components'
does this mean I should delete this from the Form1.cs file?
Type 'RecursiveSearchCS.Form1' already defines a member called 'Dispose' with the same parameter types.
Type 'RecursiveSearchCS.Form1' already defines a member called 'InitializeComponent' with the same parameter types.
(I notice, when I comment out the InitializeComponent line and/or Dispose line, many more error messages populate in ERRORS)
By they way you can find the original code # MicrosoftSite.
Any help would be greatly appreciated.
Thank You
Just gut instinct, if you were following along and copy pasting remember one key thing:
The designer creates two files when you create a form: A "code" file, and a "designer" file. However, when microsoft (and others) release "templates", they like to merge these two files.
Just create a new .cs file and paste the code and all should be good. It's the code basically saying "in the designer, we already have this stuff". (a good way to note this is the "partial" keyword located before your Form1 declaration)
More info:
The Code file will house all your own implementations. That is click events, methods you personally override, events you bind to, etc. This is the default file when you select "View Code" from either your solution explorer or the dialog itself. Within this file is a construct that calls a "hidden" method, (InitializeComponent) that if you right click and "Go to Definition" will bring you to the next file:
The Designer file is the IDE's generated file. This takes everything you do in the designer and stores it for you. That includes new controls, location and properties of the controls, and the IDisposable implementation. The idea is to keep the "meat an potatoes" out of the way while you worry only about implementation.
Yes it sounds like you've copied the entire code which includes many things already contained within your Form in a partial class. Either remove these or remove the partial class and partial class declaration from your Form to get rid of these errors
I went to the Microsoft site to see what you did. The site shows code for an entire "one file" solution. We've all agreed that Visual Studio creates multi-file solutions, so you're duplicating code.
I don't know if the current answers/comments have helped you get this sample code working, so I thought I'd add my share. I was able to get this sample working by doing the following:
First, where the sample code at the Microsoft site shows declarations for button, textbox, labels, and combobox, rather than attempting to copy that portion, I simply used the toolbox and dragged a button, the labels, the textbox, and the combobox from the toolbox to my form.
You'll probably want to arrange these to your liking.
This process created my form correctly with the appropriate objects on it. All I had to do was use the properties window for each object and rename them according to what they were named in the sample. For example, my new button was originally button1, but I renamed it to btnSearch just as it is named in the Microsoft sample.
I noticed that the Microsoft sample has an established event handler setup for the Form1_load() event. I created this same event in my form by clicking the form in the designer, clicking properties, clicking on the Events button in that properties, and double-clicking the "Load" event. This automatically generated the appropriate code.
In a similar way, I had to create the btnSearch_Click() event. I did this by simply double-clicking the button in the designer.
After that, all I had to do was manually copy and paste from the specific sections of the sample to my code -- fill in the Form1_Load() event with what was in the sample. Copy the DirSearch() method over. Fill in the btnSearch_Click() event. That was it.
I hope this helps solve the overall issue and gives you more insight into how you can avoid these problems in the future.
You have duplicated functionality in the classes, you have a file that was automatically generated with that functionality already in it.
Is there any add-in for VS2008 Pro that provides me the ability to expand and see the list of members of each class - methods, properties,etc... - by expanding its tree node in Solution Explorer?
not possible from solution explorer, but is available via the Class View. go to the View menu and click on Class View to open it up.
Object Browser?
http://msdn.microsoft.com/en-us/library/exy1facf%28VS.80%29.aspx
In Solution Explorer you can click either on the project or individual file and select 'View Class Diagram'. It creates a diagram for all your classes. To see members of the class click on the down arrow next to the class name.