Problem with class Not existing that does

T

tshad

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
 
P

Peter Duniho

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?)

[...]
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

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
 
T

tshad

Peter Duniho said:
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?)

[...]
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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top