user316117
user316117

Reputation: 8271

Viewing a VB6 file in Visual Studio 2010 without trying to "build" it

I have a C#/.Net 4.0 project in Visual Studio 2010. Parts of this project were originally from an old VB6 program that was converted to C#.

Sometimes I need to look at the old VB6 code side-by-side with the C# code, and so it's very convenient to just open and view the file in Visual Studio. V.S. even displays comments and keywords in appropriate colors for easy viewing. To open the VB6 file I'm doing a File>Open>File. The VB6 file has a .cls extension.

The problem is that when I do that it also tries to do background compilation of it, so as soon as I open it, it registers hundreds of errors because VB6 isn't a supported language and even if I do a Build Solution or Rebuild Solution it includes those results in the build so I can't build my C# project when the VB6 file is open.

1. Why does it do this, considering that the VB6 file is not part of the current solution or project?

2. How do I turn it off so I can view the file but not have Visual Studio try to compile it?

Upvotes: 2

Views: 216

Answers (1)

JaredPar
JaredPar

Reputation: 754665

Why does it do this?

The cls extension is mapped to the Visual Basic language service. It will interpret any file with that extension as a VB.Net file and process it as such.

The Visual Basic Language service is always compiling files to a degree in the background. It doesn't actually produce EXE / DLL but will go far enough to provide semantic information to the front end. This is used in intellisense, code highlighting, error squiggles, etc ...

How do I turn it off?

Unfortunately you can't. Visual Basic background compilation is not configurable. Hence any file which it believes to be VB.Net code will be processed in the background and errors will be displayed.

The only way to view it without errors is to rename the file to an extension not thought to be VB.Net code (like txt)

Upvotes: 2

Related Questions