views:

446

answers:

2

So,

Visual studio just started throwing "error BC30037: Character is not valid." at me (while validating a web site) whenever I use the nullable operator anywhere within one of my VB.NET 3.5 projects. This happened to a colleague some months ago but he doesn't remember how he fixed (I seem to remember it fixing itself eventually).

If I change a Double? to Nullable(Of Double), for example, it compiles just fine, and other usage of nullables in other projects in the same solution are continuing to work just fine.

I've tried cleaning the solution, closing Visual Studio, deleting the Temporary ASP.NET files, and restarted Visual Studio (my usual method to fix things) to no avail.

Anything else I could try?

ADDITION:

I thought I would mention that delegate syntax is also failing. I have this piece of code:

Dim hasSkips As Boolean = payments.Where(Function(p) p.Code = "SKIP").Count > 0
Dim isRegular As Boolean = Not hasSkips

payments is an IList(Of Payment). The Payment object has a string property called Code. Nothing fancy. There are no validation errors or anything visible in Visual Studio that makes it think it doesn't know what that line of code does. Intellisense works just fine (. As my previous problem with nullables, the code editor does not complain about the syntax (as in Double?).

The compiler has a fit with the syntax. The following two errors accompany the above two lines of code, respectively:

error BC30201: Expression expected.
error BC30451: Name 'hasSkips' is not declared.

It would almost seem as if Visual Studio has no knowledge of the VB.NET 3.5 features it's supposed to know about. I would hate to have to do it but I'm getting close to wanted to re-install Visual Studio.

A: 

I second Andrew's answer. Double? is C# syntax, it doesn't exist in VB. VB uses Nullable(Of Double).

Rudy Lacovara
You're as wrong as Andrew is ;-)
Meta-Knight
+1  A: 

I figured it out. The web site project needs to be instructed which version of the compiler to use, even after you choose the version in the property pages. Added this to my web.config fixed the issue:

<system.codedom>
 <compilers>
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
   <providerOption name="CompilerVersion" value="v3.5"/>
   <providerOption name="OptionInfer" value="true"/>
   <providerOption name="WarnAsError" value="false"/>
  </compiler>
 </compilers>
</system.codedom>

Well, good to know I guess.

Cory Larson