Namespace Issue
-
Hi, all... I'm an ASP developer that's getting into ASP.Net w/ C#. Love it! I've got an issue with the NameSpace deal, though. I'm trying to do things the right way, and write manageable code. So I've got the namespace for my company, GBG, and the namespace for my project, GBG.thefightison. I'd added a namespace for the data access classes for the app, GBG.thefightison.Data. Good up to this point? So I'm writing a page that allows a user, once logged in, to change their images in the Testimonials section. (ImageChange.aspx and ImageChange.cs for the code-behind.) .cs file is wrapped in the namespace GBG.thefightison. Tried to access the "DataAccess" class in GBG.thefightison.Data. Wasn't able to. Got an error when I did GBG.thefightison.Data.DataAccess oDA = new DataAccess(); So I dropped the "Data" namespace from the DataAccess.cs file Tried GBG.thefightison.DataAccess oDA = new DataAccess(); Errored out... So I changed ImageChange.aspx's CodeBehind page to DataAccess.cs, and cut/pasted the WebForm1 class to GBG.thefightison namespace. Code works... But I don't want to use one .cs file for the entire app!!!! So I've been playing around with SharpDevelop. WOW!!! I open up a new .cs file, use GBG.thefightison as the namespace, and what does SharpDevelop do? It drops down all my classes in the GBG.thefightison namespace... from the other .cs files! So I'm like "Wow! Now we're getting somewhere!"... Nope. Had SharpDevelop autoComplete the code for me, and it seems to think I'm doing a decent job of it. But it still won't work.. I get the following error.... Compiler Error Message: CS0234: The type or namespace name 'DataAccess' does not exist in the class or namespace 'GBG.thefightison' (are you missing an assembly reference?) Now this code is a dead copy from a different class method in the DataAccess.cs file. And it works... Does anyone have any suggestions?
-
Hi, all... I'm an ASP developer that's getting into ASP.Net w/ C#. Love it! I've got an issue with the NameSpace deal, though. I'm trying to do things the right way, and write manageable code. So I've got the namespace for my company, GBG, and the namespace for my project, GBG.thefightison. I'd added a namespace for the data access classes for the app, GBG.thefightison.Data. Good up to this point? So I'm writing a page that allows a user, once logged in, to change their images in the Testimonials section. (ImageChange.aspx and ImageChange.cs for the code-behind.) .cs file is wrapped in the namespace GBG.thefightison. Tried to access the "DataAccess" class in GBG.thefightison.Data. Wasn't able to. Got an error when I did GBG.thefightison.Data.DataAccess oDA = new DataAccess(); So I dropped the "Data" namespace from the DataAccess.cs file Tried GBG.thefightison.DataAccess oDA = new DataAccess(); Errored out... So I changed ImageChange.aspx's CodeBehind page to DataAccess.cs, and cut/pasted the WebForm1 class to GBG.thefightison namespace. Code works... But I don't want to use one .cs file for the entire app!!!! So I've been playing around with SharpDevelop. WOW!!! I open up a new .cs file, use GBG.thefightison as the namespace, and what does SharpDevelop do? It drops down all my classes in the GBG.thefightison namespace... from the other .cs files! So I'm like "Wow! Now we're getting somewhere!"... Nope. Had SharpDevelop autoComplete the code for me, and it seems to think I'm doing a decent job of it. But it still won't work.. I get the following error.... Compiler Error Message: CS0234: The type or namespace name 'DataAccess' does not exist in the class or namespace 'GBG.thefightison' (are you missing an assembly reference?) Now this code is a dead copy from a different class method in the DataAccess.cs file. And it works... Does anyone have any suggestions?
hi, deanofharvard wrote: Good up to this point? yes :) uuuh, deanofharvard wrote: GBG.thefightison.Data.DataAccess oDA = new DataAccess(); So I dropped the "Data" namespace from the DataAccess.cs file Tried GBG.thefightison.DataAccess oDA = new DataAccess(); Errored out... I don't see
using
anywhere. You have to writeusing GBG.thefightison.Data;
at the begining of code, or reffer to classes in this namespace with full name (e.g. GBG.thefightison.Data.DataAccess oDA = new **GBG.thefightison.Data.**DataAccess(); ) I don't see anything else wrong, bt I got little lost in changes you made :-O Never forget: "Stay kul and happy" (I.A.) -
hi, deanofharvard wrote: Good up to this point? yes :) uuuh, deanofharvard wrote: GBG.thefightison.Data.DataAccess oDA = new DataAccess(); So I dropped the "Data" namespace from the DataAccess.cs file Tried GBG.thefightison.DataAccess oDA = new DataAccess(); Errored out... I don't see
using
anywhere. You have to writeusing GBG.thefightison.Data;
at the begining of code, or reffer to classes in this namespace with full name (e.g. GBG.thefightison.Data.DataAccess oDA = new **GBG.thefightison.Data.**DataAccess(); ) I don't see anything else wrong, bt I got little lost in changes you made :-O Never forget: "Stay kul and happy" (I.A.)Well, to simplify things I removed the .Data from my NameSpace. I've tried GBG.thefightison.DataAccess oDA = new GBG.thefightison.DataAccess(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ using GBG.thefightison; .... DataAccess oDA = new DataAccess(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ using GBG.thefightison; .... GBG.thefightison.DataAccess = new GBG.thefightison.DataAccess() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ and various other permutations of this theme... I constantly get "Compiler Error Message: CS0234: The type or namespace name 'DataAccess' does not exist in the class or namespace 'GBG.thefightison' (are you missing an assembly reference?)" I'm still lost... Thanks for the info, though... Could it be that I've got 3 classes in the DataAccess.cs file? Would you like to see all of the source code? It "should" work, right? F~
-
Well, to simplify things I removed the .Data from my NameSpace. I've tried GBG.thefightison.DataAccess oDA = new GBG.thefightison.DataAccess(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ using GBG.thefightison; .... DataAccess oDA = new DataAccess(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ using GBG.thefightison; .... GBG.thefightison.DataAccess = new GBG.thefightison.DataAccess() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ and various other permutations of this theme... I constantly get "Compiler Error Message: CS0234: The type or namespace name 'DataAccess' does not exist in the class or namespace 'GBG.thefightison' (are you missing an assembly reference?)" I'm still lost... Thanks for the info, though... Could it be that I've got 3 classes in the DataAccess.cs file? Would you like to see all of the source code? It "should" work, right? F~
sorry, somehow I missed this post. deanofharvard wrote: and various other permutations of this theme. this is NOT good way how to solve (programing) problems! deanofharvard wrote: "Compiler Error Message: CS0234: The type or namespace name 'DataAccess' does not exist in the class or namespace 'GBG.thefightison' (are you missing an assembly reference?)" How many project do you have? If you're using classes from different assemblies, you have to add their (assemblies') references to your project. deanofharvard wrote: Would you like to see all of the source code? If nothing else helps, send me that damned code :) at no-hail(at)seznam.cz David Never forget: "Stay kul and happy" (I.A.)