namespace name could not be found

S

Steve Richter

I have a simple project that builds ok in Visual Web Developer, but
which fails when I navigate to it at //localhost. The error is
"namespace 'ac' could not be found".

the problem page is at
inetpub/wwwroot/DemoSite/Page1.aspx

which I navigate to at
//localhost/DemoSite/Page1.aspx

I manually created a /bin directory within the /DemoSite directory:
c:/inetpub/wwwroot/DemoSite/bin

So DemoSite is my application root directory and /bin is my ~/bin
directory? Is that correct?

I built a class library "ac" using the C# compiler and copied ac.dll to
the ~/bin directory.

Visual Web Developer liked this arrangement because I was able to
successfully build a single page web site that referenced a static
method in the "ac" namespace.
c://inetpub/wwwroot/DemoSite/Page1.aspx

However, when I navigate to my website page at
//localhost/DemoSite/Page1.aspx
two odd things happen:
- IIS compiles the page again. But I had built the website thru
Visual Web Developer. Why is IIS compiling it again?
- the IIS build fails because namespace "ac" is not found. Why does
the IIS build not find the namespace in /DemoSite/Bin/ac.dll just like
VWD2005 does?

Source code and error messages follow.

-Steve

<%@ Page Language="C#" Trace=true %>
<%@ Import Namespace="ac" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

void Page_Load(object sender, EventArgs e)
{
Trace.Write("AutoCoder", ac.Common.GetConnectionString());
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

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

Source Error:
Line 1: <%@ Page Language="C#" Trace=true %>
Line 2: <%@ Import Namespace="ac" %>
Line 3:
Line 4: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Source File: c:\Inetpub\wwwroot\DemoSite\Page1.aspx Line: 2
 
M

Mark Fitzpatrick

DemoSite is only an application root if you made it an application root in
the IIS management console. If not, then wwwroot is still the application
root and DemoSite is just a normal directory. Chances are this is what is
happening. Try moving the bin directory up to the wwwroot directory and see
what happens. To create the directory as an application in the IIS MMC
right-click the directory name and select properties. On the directory tab,
under application settings click the create button to begin the process that
designates it as an application.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
S

Steve Richter

Mark said:
DemoSite is only an application root if you made it an application root in
the IIS management console. If not, then wwwroot is still the application
root and DemoSite is just a normal directory. Chances are this is what is
happening. Try moving the bin directory up to the wwwroot directory and see
what happens. To create the directory as an application in the IIS MMC
right-click the directory name and select properties. On the directory tab,
under application settings click the create button to begin the process that
designates it as an application.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

that did it, Mark. One click - done!

thanks,

-Steve
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,520
Members
44,996
Latest member
rainocode

Latest Threads

Top