views:

115

answers:

2

I have included a resource in my Visual Studio 2005 solution that was a file on the hard drive. It is a text file, that contains text, and has a .htm extension.

For months it worked fine, until I wanted to edit the contents of the text file. Suddenly Visual Studio insists on syntax checking the file as though it were an HTML file - when it is not.

i would really rather not workaround this bug in Visual Studio by forcing the file to be named:

SomeFilename.htm.VSbug.doNotRemove

rather than

SomeFilename.htm

Not everything that uses the file is Visual Studio, and it would be a shame to force everyone to change because of issues with Visual Studio.

Even more to the point - what did i originally do so that VS would (correctly) ignore randomly added text files - and how do i do that again?


Update One

Since some people are, of course, curious - here is the contents of the file:

SomeFilename.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"&gt; 
<HTML>
<HEAD>
    <TITLE>New Document</TITLE>
    <META http-equiv="X-UA-Compatible" content="IE=edge">
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
</HEAD>

<BODY style="margin: 0 auto">
    <DIV style="text-align:center;">
     <A href="%PANELLINK%" target="_blank"><IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%"></A><BR>
     %CAPTIONTEXT%
    </DIV>
</BODY>
</HTML>

As you can see, the file does not contain html. Don't forget - the file's contents are beside the point.


Answer

Editing the file through Visual Studio is what triggers Visual Studio to think it has some jurisdiction over the contents of the resource file.

Deleting the file and re-adding it, as well as only editing the resource text file outside of VS, ensures that VS will not try to parse the file's contents.

+1  A: 

This obviously begs the question – why do you use a wrong file extension on a system, where file type is determined by these extensions?

Sorry, the answer is of course wrong. I was pretty sure I had done it that way already. Still, I think the above comment is still valid, even if not applicable universally. Marking the answer “offensive” is just rude and doesn’t change that.

However, your problem can be solved relatively easily. Instead of opening the file through double-click, you can right-click it and choose “Open with ...” in its context menu. There you can select the text editor.

Konrad Rudolph
I think "open file as" in VS2005 might work, but I like my answer better. I think it resolves the issue better.I found nothing offensive in your post - but note that I have in the past accidentally clicked on the offensive link. I agree that the htm extension is questionable.
Tim
The comment is valid.
Chris Lively
You are correct, editing the file in VS breaks it.
Ian Boyd
That is to say: The striked out portion (???) of your answer is correct.
Ian Boyd
A: 

Perhaps this?

http://weblogs.asp.net/scottgu/archive/2007/09/18/vs-2008-support-to-treat-html-css-and-jscript-validation-issues-as-warnings-instead-of-errors.aspx

I opened my 2005 and went to Tools -> options -> text editor -> HTML/XML -> HTML specific and uncheck the "enable html validation" box. I think it should solve your problem.

Tim
Correct me if I'm wrong, but doesn't this universally disable HTML checking? Quite some side-effect. ;-) Still, interesting technique.
Konrad Rudolph
Sure, but he leaves little room. Can't have it both ways. If he isn't using html files as the html that VS expects, then this solves the issue. It is simple to turn on and off once you know where to go.
Tim
That turns off all html validation.
Ian Boyd
That is what i thought you were asking for. Based on the content of your question at the time this was totally appropriate.
Tim