views:

850

answers:

2

I created an ASP.NET Web App project and it builds and works correctly now. However, I am trying to add this project to my website. So what I've done is I create a new Web Site from VS and then I added all of the .CS files from my Web App project to this Web Site.

Even though the Web App project builds successfully, when I use this same code in my Web Site and I build it, I get the error:

The type or namespacae name 'ADONET_namespace' could not be found (are you missing a user directive or an assembly reference?)

Here is the top part of my master.cs file:

using System;
using System.Collections.Generic;
using System.Collections;

namespace AddFileToSQL
{
    public partial class _Default : System.Web.UI.Page
    {

And the top of my ADONET_methods.cs file:

using System;
using System.Collections;
using System.Data;

namespace ADONET_namespace
{
    public class ADONET_methods : System.Web.UI.WebControls
    {

Finally the top of my child class:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using ADONET_namespace;

namespace AddFileToSQL
{
    public partial class DataMatch : _Default
    {

In this child class file, there is a squiggly line under ADONET_namespace and hovering over it returns the error specified above. I have this ADONET_methods.cs file stored in same file structure format on this Web Site as I do on my Web App project. So if it builds successfully in that project, why not in this Web Site?

I have searched Stack Overflow for similar questions and I found one question which was asking the same thing as me, but I tried all of the solutions listed there. I also googled this problem and tried all of the suggestions, but none of them worked either. And I have added this ADONET_methods.cs file to different locations within this Web Site to test out if it was being found or not, like under App_Data folder, References folder, and also in the same level as the other .CS files (like it is in the Web App project).

What else can I try? This code is written in C# by the way in VS 2008, running on an XP Pro with IIS6 Manager.

A: 

Try putting it in your App_Code directory.

womp
Yes, I already have this in my App_Code and References directory, as well as one copy at the same level as the other .CS files.
salvationishere
A: 

Not sure if this is causing any issues, but do you want your class in the ADONET_methods.cs file to be named ADONET_namespace? It seems odd to have both the class and the namespace with the same name.

ironsam
It shouldn't cause any issues, but it isn't exactly best practice either ;)
womp
Good catch guys, I originally did not have same name. I edited my question to how it matches my code now. Now, the class has a different name than the namespace.
salvationishere
Is there a "parent" namespace involved, such as the default namespace for the project that you need to include in the `using` statement on the `DataMatch` class, such as `using MyProject.ADONET_namespace;`?
ironsam
No, there's no "parent" namespace involved. I tried making it:using AddFileToSQL.ADONET_namespace, but this caused same error message. What about assembly reference? What does that mean? I included the ADONET_methods.CS file in the References folder. Does this satisfy this requirement?
salvationishere
Maybe you could try looking at the class view of the project and see if that shows you exactly where the compiler is expecting to find the ADONET_namespace. VS2008 menu -> View -> Class View. That shows you the classes and namespace tree.
ironsam