0

I want to run my project, and I have one class that makes errors - I will fix it later ,but now I want to run the project without reference to the class that makes errors. How can I do it?

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
Tehila
  • 73
  • 1
  • 7
  • make comment to error. – Anand Nov 11 '13 at 10:27
  • Do you references that class throughout the code in other classes? Since you say that the class `makes errors`, I assume you do have other references throughout your code. Excluding the class from your project or commenting out its content will not help in this situation. – Andrei V Nov 11 '13 at 10:31
  • as mentioned by tehila... " that makes errors - I will fix it later".. She\he is aware about the error but okay to resolve them later. Please correct it Andrei V.. – Jigar Pandya Nov 11 '13 at 10:43
  • 1
    @JigarPandya, I'm sorry, I don't understand what exactly I should correct. I wasn't talking about the code inside that class, but the code in other classes that reference the "bad class". As far as I know, code doesn't execute just because a class is declared in a project, but you need an explicit call/reference. Hence, you need to reference the "bad class". That's what I'm asking for: are there any references to that class? It is not clear from the question where and what those errors are. Are there logical or compilation errors? – Andrei V Nov 11 '13 at 10:49

3 Answers3

6

You can do right click on that file and select exclude from project for now.

It is something like Image bleow.

enter image description here

Other way is to comment the logic that is not desired and continue working on without excluding.

Jigar Pandya
  • 6,004
  • 2
  • 27
  • 45
  • And how to bring it back later? – Tehila Nov 11 '13 at 10:30
  • Right click on the file and include it again. – germi Nov 11 '13 at 10:30
  • You can always do include in project see it here http://stackoverflow.com/questions/8305205/how-to-undo-exclude-from-project-in-visual-studio-2008 – Jigar Pandya Nov 11 '13 at 10:31
  • You will NOT see the file after EXCLUDing it from project. First, you must check the "Show All File" option on the tool bar on the Solution Explorer. Mind that the button shows up ONLY when you have a "Project" selected in the tree. – quetzalcoatl Nov 11 '13 at 10:31
  • 1
    Also, mind that when you exclude-a-**file**, this file will be totally ignored. That is, if you have three classes in that file, all three will "temporarily evaporate". – quetzalcoatl Nov 11 '13 at 10:32
  • What about existing references to the excluded class? Since it `makes errors` it is references by at least another object. You exclude the "logic error" but you create a "reference problem". – Andrei V Nov 11 '13 at 10:36
1

Comment out its inner code. This way you can still reference that class from your code but it will no longer show errors unless you are refering to method or property of this class which is commented out.

public ProblemClass
{
    // public string Name { get; set; }
    // ...
    // ...
}
Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
1

You need to comment your class and all usages of this class. It can be done by selecting code block that you need to comment and pressing Ctrl+K, Ctrl+C.

If you need to uncomment - Ctrl+K, Ctrl+U on selected commented block.

Also you need to note that commenting your class usages in project also might produce new errors.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
Vladimirs
  • 8,232
  • 4
  • 43
  • 79