Search code examples
c#attributesmshtml

C#:The type or namespace name '?Attribute' could not be found (are you missing a using directive or an assembly reference?


I was coding my program and out of nowhere I get the following:

The type or namespace name '?Attribute' could not be found (are you missing a using directive or an assembly reference?

I got it after trying to add the dll: mshtml

I removed it but the error doesnt go away.

Another error I get is:

Invalid token '(' in class, struct, or interface member declaration

and...

'System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window, string)' is a 'method' but is used like a 'type

I tried closing out of the IDE and reopening it to see if the error went away but it didnt.

Any help is appreciated, thanks :)

EDIT: Here is a sample code where the error comes from. Note several other items in my code have the same of similar errors:

The error is in

if (webBrowser1

and

Show

if (webBrowser1.DocumentText.Contains("Text here"))
                {
                    MessageBox.Show("TText.......");
                }

Solution

  • Reference to ?Attribute name suggests you have malformed attribute declaration, most likely followed by non-ASCII unicode character - check your code file for misplaced occurrences of "[" (open square bracket) before any other errors.