Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Problem with class Not existing that does

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tshad - 31 Oct 2007 06:09 GMT
I get the following error:

PageInit.cs(43,71): error CS0246: The type or namespace name 'User' could
not be
       found (are you missing a using directive or an assembly reference?)

The error is from the last line in this snippet of code
*****************************************
using System;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.SessionState;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Microsoft.VisualBasic;
using MyFunctions;

namespace MyFunctions
{

   public class PageInit
   {

       public static void PageSetup(MyFunctions.Page thePage)
       {
            HttpContext.Current.Session["LastPageVisited"] =
(User)HttpContext.Current.Session["User"].LastPageVisited;
**************************************************************

I have stored and object "User" in my session variable and am trying to get
access to LastPageVisited.  I originally didn't have the (User) in front of
the line and got the error that LastPageVisited didn't exist.  So I typecast
the whole string - but got the error:

I have a User Class in the MyFunctions namespace that is in the compiler
line:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc /t:library PageInit.cs
/r:system.web.dll /r:system.data.dll /r:system.dll
/r:Microsoft.VisualBasic.dll /r:refresh.dll /r:User.dll

And the User Class is setup like:
*************************************************
using System;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using MyFunctions;
using FtsData;

namespace RolesBasedAuthentication
{
[Serializable]
public class User
{
 private string lastPageVisited = "";
...
 public string LastPageVisited
 {
  get { return lastPageVisited; }
  set { lastPageVisited = value; }
 }
**************************************************

So do I need to change the following line to work?

(User)HttpContext.Current.Session["User"].LastPageVisited;

The problem seems to be the User doesn't exist but it does (doesn't it?).

Thanks,

Tom
Peter Duniho - 31 Oct 2007 07:42 GMT
> I get the following error:
>
[quoted text clipped - 9 lines]
>
> I have a User Class in the MyFunctions namespace

If the User class is in the MyFunctions namespace, then why does it
appear in the RolesBasedAuthentication namespace in the code you posted?

Without a concise-but-complete sample of code to look at, it's
impossible to tell.  But the code you posted does not match your
assertion about it.  If the code is correct, your assertion is
incorrect and you can access the class simply by specifying the correct
namespace for it (or including the namespace in your "using" section).

Pete
tshad - 31 Oct 2007 08:32 GMT
>> I get the following error:
>>
[quoted text clipped - 17 lines]
> If the User class is in the MyFunctions namespace, then why does it appear
> in the RolesBasedAuthentication namespace in the code you posted?

You're right.

I had thought User was in the MyFunctions namespace and it was actually in
the RolesBasedAuthentication namespace.

Thanks,

Tom

> Without a concise-but-complete sample of code to look at, it's impossible
> to tell.  But the code you posted does not match your assertion about it.
[quoted text clipped - 3 lines]
>
> Pete
Peter Bromberg [C# MVP] - 31 Oct 2007 18:30 GMT
Please try to avoid multiple posting the same theme, it just gets people that
are trying to help frustrated. If you are getting answers, stick to the same
thread.
-- Peter
Recursion: see Recursion
site:  http://www.eggheadcafe.com
unBlog:  http://petesbloggerama.blogspot.com
BlogMetaFinder:    http://www.blogmetafinder.com

> I get the following error:
>
[quoted text clipped - 74 lines]
>
> Tom

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.