Can't figure out the error

D

DaveF

IAny idea what this error is?

C:\Documents and Settings\dfetrow\My Documents\Visual Studio
Projects\FTPTimer\Service1.cs(15): The type or namespace name 'TimedItem'
could not be found (are you missing a using directive or an assembly
reference?)


namespace CodeGuru.TimerService

{

public class TimerService : System.ServiceProcess.ServiceBase

{

private System.Diagnostics.EventLog _AppEventLog;

private Thread[] _WorkerThreads;

private TimedItem[] _Timers; ********************************Error
 
R

RayO

It means just what it says, you're missing it's
namespace and/or it's assembly reference.
You need to ask yourself:
Where is TimedItem defined? Is it's assembly
added in the list of References? What is it's namespace?

RayO
 
M

Morten Wennevik

Hi David,

That is one of the most common errors you will encounter.
When the compiler encounters TimeItem[] it cannot find any description of the object in the current namespace or in any "using" namespaces.

As TimedItem isn't defined anywhere in the code, figure out where it is defined and add a using to that namespace as well as a reference to that assembly.

Beware, it may also be caused by simple typos where for instance TimeItem is defined but TimedItem is not. Check your spelling as well.
 
D

DaveF

I am new to C#
I am trying the following code:

http://www.developer.com/net/net/article.php/11087_3335731_1


--


David
http://www.helixpoint.com




Morten Wennevik said:
Hi David,

That is one of the most common errors you will encounter.
When the compiler encounters TimeItem[] it cannot find any description of
the object in the current namespace or in any "using" namespaces.
As TimedItem isn't defined anywhere in the code, figure out where it is
defined and add a using to that namespace as well as a reference to that
assembly.
Beware, it may also be caused by simple typos where for instance TimeItem
is defined but TimedItem is not. Check your spelling as well.
 
M

Morten Wennevik

Hi David,

A bit down on that page you will notice

public class TimedItem

This is where TimedItem is described and it is defined under the CodeGuru.TimerService namespace, same as the rest of the code.

Either put both classes in the same file and in the same namespace {} or if you put them in separate files, make sure you add the TimedItem file when compiling.

ie

csc TimerSample.cs TimedItem.cs TimerService.cs

As long as the files use the same namespace you don't need to add a "using", but if they weren't you would need to add

using CodeGuru.TimerService;

so the compiler will check that namespace for the TimedItem definition.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Dave,


It means that you mispelled a variable name or that you forgot to include a
namespace.

The compiler will give you different errors when you make reference to a
nonexisten variable:

if you do

mispelledVariable = 4;

will result in a msg like "mispelledVariable does not exist in ..."

but if you do this

mispelledVariable.value = 4;

will gives you the error you are seeing.


Hope this help

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top