Hi Jon/Adam,
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
is all that I have...I also thought it was the using directive and possibly
even a "Reference" or "include" directive in the .aspx page but that did not
work either...different error message I think though, not sure. FYI, I do
not use any namespace {} code in both projects and it's also referenced
straight up "Database.somefunction()" or "Constants.somefunction()" with no
other prefix and works fine in ProjectA.
Database.cs is one of the files but the main one I am trying to also include
is called Constants.cs which holds some variables/functions. I use about 3-4
of these exact same classes in all my projects and none of them work in this
one but work in every other project..ProjectC, D, E, F, G for example all
fine except this one doesn't.
Does it matter where the file is placed? ProjectA has them in the App_Code
directory I forgot why I put them there. ProjectB I put it in App_Code as
well as the root just to cover all grounds but still no luck.
Do you think that because the code sounds/looks correct that maybe it has
something to do with IIS, or how the aspnet_client folder was installed? A
configuration setting maybe?
If you like, I could possibly even send over a small set of "compiler" files
just to get a general idea of what my project looks like: default.aspx,
default.aspx.cs, constants.cs/database.cs, web.config, and a .css. My bet is
that it would work on your computers but not on mine because I have something
configured incorrectly on IIS possibly.
I understand it's a holiday weekend so feel free to reply to this thread
whenever you please. Also, this is a personal project so I am in no rush to
solve it but am definitely looking for answers. Gonna play around with it
now again...
I'll keep you posted if I solve it myself. Thanks again for your help,
most appreciated.
"Jon Skeet [C# MVP]" wrote:
R Reyes <RR****@discussions.microsoft.comwrote:
I have a public class called Database.cs. It has public static functions and
I call them from ProjectA. The code looks something like:
int intConnectionSuccessful = Database.ConnectToDatabase();
Works great.
Now, I have another project, ProjectB on a different server. I copy and add
Database.cs to the project and also call the functions the exact same way as
above. However, I always get this error message:
'The name 'Database' does not exist in the current context'
OR
The type or namespace name 'Database' could not be found (are you missing a
using directive or an assembly reference?)
Right. Database is probably in a namespace like ProjectA, which you
don't have a using directive for - just as the compiler is telling you.
--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com