Simple Keyword does not name a type.

pswg

Member
Joined
Feb 26, 2008
Messages
9
Programming Experience
5-10
I'm new to .NET - just started developing on it this week - and cannot figure this out. What am I doing wrong?

Dim obj = New With {.text = "Hello World"}
Error BC30180: Keyword does not name a type.
I also seem to get this warning:
Variable declaration without an 'As' clause; type of Object assumed

Thanks in advance
 
The code works fine in my VB 2008 (with options Explicit, Strict and Infer on), you're creating an anonymous type. However if you attempted to do this with an older VB you'd be in trouble because that language construct is new in VB 2008. Is your forum profile correct?
 
I am using VWD 2008 Express. I do not know how to set options - the old method of just typing 'Option Explicit' doesn't work.

Yes, my profile is correct. I have several years of programming in general, but .NET is very new to me. From everything I've read this should work.
 
I see, moving thread to ASP.Net section. But that doesn't make a difference, it works for ASP.Net code behind also when I test it (as would be expected). If you configure the web application for different Framework than .Net 3.5 it will not work, this is different from a VB 2008 windows application where you can use language like that also when targeting for example .Net 2.0. Reason for this difference is web applications aren't pre-compiled like windows executables, they are compiled from source files by web server and have to be fully compatible with the Framework version runtime used at web site. This is called Website Compilation Model, there exist other models but not integrated in VWD, read more about ASP.Net Compilation Models if you're interested. Most likely will Web Application Compilation Model make IDE behave similar to windows applications in this regard, but you need a full version Visual Studio to try this.
 
I'm not entirely sure that I understand, but let me describe my setup:
I have downloaded and installed the newest version of the framework. In my web.config file, everything says version=3.5.0.0 or in some cases version=3.6.0.0 (except for the compilers, version=2.0.0.0). VWD never gives me the option to use a different version of the framework, so I don't think I'm targeting another platform.

I've also added <compilation ... explicit="true" strict="true"> to web.config, but I can't figure out how to enable option implicit.

I am building and running the application on my local machine at the moment, so I don't think versioning is the problem.

I'm getting this error when when I try to view it in a browser and when I build the project from within VWD. But as I understand it, the different compilation models do not effect how the compiler handles your code, only when it's compiled and how it's executed. If this code is valid in one compilation model it SHOULD be valid in all compilation models.

Is this a problem with the VB.NET compiler in VWD? Is there something I'm missing in the setup?
 
I think I may have figured something out...
The IIS application pools only give me the option of using .NET Framework 2.0.50727 - I had seen this before but assumed this was not big issue since .NET 3.5 supposedly runs on top of 2.0. I have read a number of other forum posts like this one, but I cannot seem to find the suggested Hot Fixes online.

Is there something else I need to do or install to use .NET 3.5 in IIS7/Vista Ultimate?
 
So your VWD actually uses IIS when it is present? That's surprising, since VWD includes its own private webserver engine normally used for debugging. When installing .Net 3.5 it should have registered with IIS also if present, that's what previous .Net versions did. I don't know if you need other configuration of your application in IIS, didn't think VWD was able to neither detect nor interact with it actually since it is a simple self contained development tool. The only deployment in VWD I'm aware of is the xcopy functionality "copy web site". I don't have IIS currently, and no other suggestions.
 
You are right, I do believe VWD uses its own web server for debugging. But if IIS isn't the problem, I think I'm back to square one.

I'll download the trial VS later today and give that a shot.
 
I never got around to downloading VS08, but I think I finally solved the problem - at least ASP.NET 3.5 programs are actually compiling now. My fix was to install the hot fixes mentioned in other forums, KB110806 and KB929300. However, I was unable to find these anywhere on Microsoft's site; every time they were referenced as being located on the VS08 installation disk. I was able to find them downloadable here.

I hope this is useful for someone else.
 
Back
Top