views:

1920

answers:

4

I'm concerned that the web hosting that I'm paying for is not configured correctly. ASP.NET Web Sites which compile and run correctly on my local machine don't work once they're deployed.

The issue I'm dealing with is a compilation error: CS0246, "Type or namespace could not be found (Are you missing a 'using' directive or assembly reference?)

My Web Site contains the following files and folders:

websitedemo/Default.aspx
websitedemo/Default.aspx.cs
websitedemo/App_Code/HelloClass.cs

The compilation error occurs if I attempt to use any code contained in my App Code folder. I've included the entire /websitedemo/ folder in this archive if it helps troubleshoot the error: http://kivin.ca/websitedemo/source.zip

I've left the folder in debug mode. The compilation error screen may be viewed at http://kivin.ca/websitedemo/

Best regards.

-- update:

If it helps troubleshoot this error, I've got the behaviour that occurs when I attempt to deploy an ASP.NET WebApplication instead of Website.

In the case that my aspx file includes a @Page direct like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myproj._Default" Debug="true" %>

The compilation error I get is: 'Parser Error Message: Could not load type 'myproj._Default'.'

The webapps are being deployed via ftp using Build -> Publish -> [X] Replace matching files, [X] Only files needed to run this app. [X] Include App_Data folder.

A: 

If you build your site locally and upload the resulting dll (that will contain HelloClass) to the bin directory, I bet it will work.

Torbjørn
As a matter of fact, it wont. I've tried that, too.
Kivin
My initial attempts were with web apps rather than websites. I ran in to the same thing, though a bin/*dll file was being built, only symbols from the aspx.cs codebehind were available. I gave up on it since a website is better suited to my needs.
Kivin
A: 

Try putting your HelloClass.cs in a namespace and put Using at the top of your default file

vishvananda
Tried it. Doesn't work. Thanks, though.
Kivin
Sorry, to be a bit more verbose, I wrapped my helper class in namespace demo.util and added using demo.util to my codebehind. The new compilation error is: CS0246: The type or namespace name 'demo' could not be found (are you missing a using directive or an assembly reference?)
Kivin
A: 

http://msdn.microsoft.com/en-us/library/54dwfbb7.aspx

i think this may help you... if you have subfolders

also, app_code was introduced in framework 2.0, can you check that the web application on the live box is set to use framework 2.0 ? otherwise the classes wont get compiled in there

Matt
Thanks, how do I check this? The information I have available to me so far is: The provider advertises IIS7 and ASP.NET 3.5, and the detailed compiler output shows "C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe"
Kivin
With regards to your link, I'm aware of how to add subfolders to web.config, but App_Code can't be explicitly added.
Kivin
The error message on http://kivin.ca/websitedemo/ (not present now) said that the site was running under asp.net 2.0, so this was not the problem.
Torbjørn
so is your site deployed onto a server 2008 box ?
Matt
only other thing that springs to mind is that the classes in app_code are in there as content instead of to compile (although this wont compile in my case)
Matt
@ Matt, It's IIS7, ASP.NET 3.5 /w SQL Server 2008. As for the content/compile setting, I think that's a Visual Studio only setting. No solution or project files are getting deployed.
Kivin
+1  A: 

I'd like to thank everyone for their support. It's most appreciated. I've been in contact with a specialist at my web hosting company and they've advised me that this isn't a code or server configuration error, but just a missed step in my control panel. Setting my website working directory as a virtual dir resolved the issue.

Thanks to the stack overflow community and the outstanding support people at Softsys Hosting.

Kivin