Subject: Chapter 9, Try it out Page 338, C#
Posted By: tbroom Post Date: 9/12/2006 3:48:29 PM
Why am i getting this?

Server Error in '/Chapter09' Application.
--------------------------------------------------------------------------------

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'Vehicle' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 36: }
Line 37:
Line 38: public class Car : Vehicle
Line 39: {
Line 40:     public Car()
 

Source File: e:\Websites\Beginning ASP.NET 2.0_CS_CodeDownload\Begin\Chapter09\App_Code\Vehicles.cs    Line: 38



Show Detailed Compiler Output:


C:\Documents and Settings\tbroom> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /out:"C:\Documents and Settings\tbroom\Local Settings\Temp\Temporary ASP.NET Files\chapter09\26f59e91\ac283f13\App_Code.irzb5zoe.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699  "C:\Documents and Settings\tbroom\Local Settings\Temp\Temporary ASP.NET Files\chapter09\26f59e91\ac283f13\App_Code.irzb5zoe.0.cs" "C:\Documents and Settings\tbroom\Local Settings\Temp\Temporary ASP.NET Files\chapter09\26f59e91\ac283f13\App_Code.irzb5zoe.1.cs"


Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

e:\Websites\Beginning ASP.NET 2.0_CS_CodeDownload\Begin\Chapter09\App_Code\Vehicles.cs(38,20): error CS0246: The type or namespace name 'Vehicle' could not be found (are you missing a using directive or an assembly reference?)
e:\Websites\Beginning ASP.NET 2.0_CS_CodeDownload\Begin\Chapter09\App_Code\Vehicles.cs(48,21): error CS0246: The type or namespace name 'Vehicle' could not be found (are you missing a using directive or an assembly reference?)
e:\Websites\Beginning ASP.NET 2.0_CS_CodeDownload\Begin\Chapter09\App_Code\Vehicles.cs(58,27): error CS0246: The type or namespace name 'Vehicle' could not be found (are you missing a using directive or an assembly reference?)

 



Show Complete Compilation Source:


Line 1:    using System;
Line 2:    using System.Data;
Line 3:    using System.Configuration;
Line 4:    using System.Web;
Line 5:    using System.Web.Security;
Line 6:    using System.Web.UI;
Line 7:    using System.Web.UI.WebControls;
Line 8:    using System.Web.UI.WebControls.WebParts;
Line 9:    using System.Web.UI.HtmlControls;
Line 10:   
Line 11:   /// <summary>
Line 12:   /// Summary description for Vehicles
Line 13:   /// </summary>
Line 14:   public class Vehicles
Line 15:   {
Line 16:       protected int _wheels;
Line 17:       protected int _topSpeed;
Line 18:       protected string _warningSound;
Line 19:   
Line 20:       public int Wheels
Line 21:       {
Line 22:           get { return _wheels; }
Line 23:           set { _wheels = value; }
Line 24:       }
Line 25:   
Line 26:       public int TopSpeed
Line 27:       {
Line 28:           get { return _topSpeed; }
Line 29:           set { _topSpeed = value; }
Line 30:       }
Line 31:   
Line 32:       public virtual string Warning()
Line 33:       {
Line 34:           return _warningSound;
Line 35:       }
Line 36:   }
Line 37:   
Line 38:   public class Car : Vehicle
Line 39:   {
Line 40:       public Car()
Line 41:       {
Line 42:           _wheels = 4;
Line 43:           _topSpeed = 150;
Line 44:           _warningSound = "Honk";
Line 45:       }
Line 46:   }
Line 47:   
Line 48:   public class Bike : Vehicle
Line 49:   {
Line 50:       public Bike()
Line 51:       {
Line 52:           _wheels = 2;
Line 53:           base.TopSpeed = 30;
Line 54:           _warningSound = "Ring Ring";
Line 55:       }
Line 56:   }
Line 57:   
Line 58:   public class Skateboard : Vehicle
Line 59:   {
Line 60:       public Skateboard()
Line 61:       {
Line 62:           _wheels = 4;
Line 63:           _topSpeed = 15;
Line 64:       }
Line 65:   
Line 66:       public override string Warning()
Line 67:       {
Line 68:           return "No warning - you'll have to shout yourself";
Line 69:       }    
Line 70:   }
Line 71:   
 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

Reply By: DanM Reply Date: 10/3/2006 3:43:36 AM
Hi there,

It looks like your problem here is that in Line 14, you've called your class Vehicles (with an 's') rather than Vehicle (without an 's').
The error is raised on line 38 because the compiler is looking for a class called Vehicle which doesn't exist.

Hope that helps, Dan

Dan Maharry
Read the feed at http://feeds.feedburner.com/dansarchive

Go to topic 49797

Return to index page 158
Return to index page 157
Return to index page 156
Return to index page 155
Return to index page 154
Return to index page 153
Return to index page 152
Return to index page 151
Return to index page 150
Return to index page 149