Newbie: importing namespaces in ASP.NET and IIS

A

abdul bari

Hi if you have a page called name.aspx and in there you want to use
the methods available in a custom class such as:

using System;
namespace tester{
public class testclass {
public String myString;
public void setMystring(){
myString = "hello world";
}
public String getString(){
return myString;
}
}
}

In the import directive you have <%@ Import Namespace="tester" %> do
you have to compile the source file into a dll and if so where do you
put it in IIS. (i have tried in wwwroot\Bin\ and other levels but
keeps on coming up with the following error

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

I havnt got visual studio either!!

thanks abz
 
M

Morten Wennevik

Hi if you have a page called name.aspx and in there you want to use
the methods available in a custom class such as:

using System;
namespace tester{
public class testclass {
public String myString;
public void setMystring(){
myString = "hello world";
}
public String getString(){
return myString;
} } }

In the import directive you have <%@ Import Namespace="tester" %> do
you have to compile the source file into a dll and if so where do you
put it in IIS. (i have tried in wwwroot\Bin\ and other levels but
keeps on coming up with the following error

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

I havnt got visual studio either!!

thanks abz

I think you need to reference the dll when you compile the code.
I use visual studio, so I'm not familiar with the command line options.
Try something like csc /reference:tester.dll nameapp.cs
Have no idea if this is how you compile web applications.
 
A

abdul bari

Hi iv been trying the example in here and I still get the same error:
-

http://www.4guysfromrolla.com/webtech/112101-1.2.shtml

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

Source Error:



Line 7:
Line 8: void Page_Load(object sender, EventArgs e) {
Line 9: testclass myclass = new testclass();
Line 10: myword = myclass.getString();
Line 11: Label1.Text = myword;
 

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