Namespace cannot be found? Help!

G

Guest

I'm trying to use a namespace i've created but i keep
getting a compile error at runtime. Here's the files and
problem i'm having. Any ideas?

index.aspx // file with html, etc
index_CB.cs // contains the code behind from index.aspx
testcomponents.cs // contains the namespace i'm trying to
use..

Everything COMPILES just file when I compile from the
command line, however, when I RUN the app (when I open
index.aspx in my brower) I get a 'compilation error:
namespace NSTestComponents cannot be found, (are you
missing a using directive or an assembly reference?)'

Here are the files (followed by the command i'm using to
compile)



CONTENTS FOR testcomponents.cs

using System;



namespace NSTestComponents

{

public class CTestClass

{

public void SomeFunction ()

{



}

}

}



NOW, CONTENTS for index.aspx



<%@ Page Language="C#"

Inherits="CMyCodeBehind"

Src="index_CB.cs"

ContentType="text/html"

ResponseEncoding="iso-8859-1"

ValidateRequest="false"

Debug="true"

%>

<%@ Import Namespace="NSTestComponents" %>

....



AND FINALLY FOR index_CB.cs



using System;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Collections;

using System.Data;

using System.Data.Odbc;

using NSTestComponents; // THIS LINE GIVES ME THE
COMPILATION ERROR WHEN I OPEN THE .ASPX FILE IN MY
BROWSER...



public class CMyCodeBehind : Page

{...




and here is the command line i'm using:
csc /target:library /out:testcomponents.dll
testcomponents.cs (and i've copied the .dll to my /bin
directory)

i'm GUESSING i need to edit the command line i just have
no idea how... my books are telling me this one should
work just fine, but that 'references' need to be added to
it when using webcontrols or htmlcontrols in the
component.. it just doesn't say which ones or even how..
so, i'm stumped...
 
N

Natty Gur

Hi,

I cant see where you reference testcomponents.dll from your web
application. you musr make a reference to dll in order to use it
namespace or types.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

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