473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Property missing

I pulled this from my last question to hopefully make it more clear.

After fixing my namespace problem I still need to find out why I am getting
an error message:

PageInit.cs(43,76): error CS0117: 'object' does not contain a definition for
'LastPageVisited'

User is an object I have in my session variables that works fine in VB.Net
but there is something missing here.

The Compiler Code is:

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

The code snippet giving me the problem looks like (the last line is the
offender):
************************************
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;
***********************************

My User class looks something 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; }
}
....
*************************************

This is the piece that is giving me the problem:

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

As you can see, LastPageVisited is a property of User.

I am still getting this error, even if I change:

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

to

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

or

HttpContext.Current.Session["LastPageVisited"] =
(RolesBasedAuthentication.User)(HttpContext.Curren t.Session["User"]).LastPageVisited;

But the Class User does have a LastPageVisited:

public string LastPageVisited
{
get { return lastPageVisited; }
set { lastPageVisited = value; }
}

Am I casting it wrong??

Thanks,

Tom

Oct 31 '07 #1
5 1558
The cast is in the wrong place; this attempts to cast
HttpContext.Current.Session["User"].LastPageVisited to (User) - you
mean:
HttpContext.Current.Session["LastPageVisited"] =
((User)HttpContext.Current.Session["User"]).LastPageVisited;

i.e. cast HttpContext.Current.Session["User"] to User, and then access
..LastPageVisited

Marc
Oct 31 '07 #2
On Oct 31, 7:45 am, "tshad" <t...@dslextreme.comwrote:
I pulled this from my last question to hopefully make it more clear.
<snip>

It's best not to start multiple threads like this - I've just answered
another post having checked it wasn't answered within the thread, and
now I find Marc's answered it here.

Jon

Oct 31 '07 #3
Look on the bright side; they're both in the same newsgroup at least
;-p

Marc
Oct 31 '07 #4
"Marc Gravell" <ma**********@gmail.comwrote in message
news:en**************@TK2MSFTNGP05.phx.gbl...
The cast is in the wrong place; this attempts to cast
HttpContext.Current.Session["User"].LastPageVisited to (User) - you mean:
HttpContext.Current.Session["LastPageVisited"] =
((User)HttpContext.Current.Session["User"]).LastPageVisited;

i.e. cast HttpContext.Current.Session["User"] to User, and then access
.LastPageVisited
That was it.

Thanks,

Tom
>
Marc

Oct 31 '07 #5
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:11*********************@19g2000hsx.googlegrou ps.com...
On Oct 31, 7:45 am, "tshad" <t...@dslextreme.comwrote:
>I pulled this from my last question to hopefully make it more clear.

<snip>

It's best not to start multiple threads like this - I've just answered
another post having checked it wasn't answered within the thread, and
now I find Marc's answered it here.
I agree.

I only did it because I was afraid that it would get lost in answering the
first error message and I was in a big hurry.

Sorry.

Thanks,

Tom
>
Jon

Oct 31 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: dmiller23462 | last post by:
Here is the code, it's not complete of course....I've been inserting lines as I go to pinpoint the issue.....I understand that the error message I'm getting (#185 Missing Default Property) is...
5
by: Mike | last post by:
My first simple attempt at using a property. and I get an exception "An unhandled exception of type 'System.StackOverflowException' occurred in BalanceOmatic.exe" on line xxx. I have included...
1
by: Kun | last post by:
Hi there, I think vs.net missing default name for new form. Scenario: 1. I create new Window Application by default it give me Form1 2. I add Form2 3. In Form1_Load event I try to get form2...
4
by: Marc van den Bogaard | last post by:
hello together, my datarow.item property is missing, i just can accesss the ItemArray property, what is wrong with this? System.Data.DataSet dataset1 = new System.Data.DataSet(); ...
7
by: vh | last post by:
Hi, I'm new to C#. Most examples about properties I found are sth like the following: class A{ private int property; public int Property { get { return property; } set { property = value; } }...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
27
by: Just Me | last post by:
I made a Usercontrol that must have AutoScroll set to true when it is used. So I set it to True in the Load event. However the property still shows in the properties window when the control is...
37
by: Joergen Bech | last post by:
(Slightly religious question): Suppose I have the following class: ---snip--- Public Class MyClass Private _MyVariable As Integer Public Property MyVariable() As Integer Get
3
by: scott | last post by:
I hope I am just missing something easy, and that someone can point me in the right direction, but I cannot seem to find out how to change the title property of any random file using VB.NET. ...
11
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.