473,406 Members | 2,336 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,406 software developers and data experts.

NullReferenceException in Profile

in <system.web> of web.config I've:
[...]
<profile>
<properties>
<add name="EnterTime" type="System.DateTime" allowAnonymous="true"/>
</properties>
</profile>

And in Session_Start of global.asax:
[...]
Profile.EnterTime = System.DateTime.Now '**** Line 26

But I get an error message in line 26:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Mar 13 '06 #1
5 5268
The syntax you are using is good for an aspx file for a page. In global.asax
Profile is not defined . You can access it via HttpContext.Current with
syntax:

HttpContext.Current.Profile.GetPropertyValue("Ente rTime");

Eliyahu

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:en**************@TK2MSFTNGP14.phx.gbl...
in <system.web> of web.config I've:
[...]
<profile>
<properties>
<add name="EnterTime" type="System.DateTime" allowAnonymous="true"/>
</properties>
</profile>

And in Session_Start of global.asax:
[...]
Profile.EnterTime = System.DateTime.Now '**** Line 26

But I get an error message in line 26:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."

Mar 13 '06 #2
Thanks Eliyahu,
I used your syntax:
Dim EnterTime As String = System.DateTime.Now.ToString
HttpContext.Current.Profile.GetPropertyValue(Enter Time)

but again the same error, here is the error details:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_global.asax.5_wxyugz"
StackTrace:
at ASP.global_asax.Session_Start(Object sender, EventArgs e) in
C:\Documents and Settings\saber\My Documents\Visual Studio
2005\WebSites\WebTesting\global.asax:line 27
at System.Web.SessionState.SessionStateModule.RaiseOn Start(EventArgs
e)
at System.Web.SessionState.SessionStateModule.OnStart (EventArgs e)
at System.Web.SessionState.SessionStateModule.Complet eAcquireState()
at
System.Web.SessionState.SessionStateModule.BeginAc quireState(Object source,
EventArgs e, AsyncCallback cb, Object extraData)
at
System.Web.HttpApplication.AsyncEventExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
The syntax you are using is good for an aspx file for a page. In
global.asax Profile is not defined . You can access it via
HttpContext.Current with syntax:

HttpContext.Current.Profile.GetPropertyValue("Ente rTime");

Eliyahu

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:en**************@TK2MSFTNGP14.phx.gbl...
in <system.web> of web.config I've:
[...]
<profile>
<properties>
<add name="EnterTime" type="System.DateTime" allowAnonymous="true"/>
</properties>
</profile>

And in Session_Start of global.asax:
[...]
Profile.EnterTime = System.DateTime.Now '**** Line 26

But I get an error message in line 26:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."


Mar 13 '06 #3
I am not good in VB.

In GetPropertyValue(EnterTime) EnterTime should a string constant. In c# I
would write GetPropertyValue("EnterTime").

Eliyahu

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:Os**************@tk2msftngp13.phx.gbl...
Thanks Eliyahu,
I used your syntax:
Dim EnterTime As String = System.DateTime.Now.ToString
HttpContext.Current.Profile.GetPropertyValue(Enter Time)

but again the same error, here is the error details:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_global.asax.5_wxyugz"
StackTrace:
at ASP.global_asax.Session_Start(Object sender, EventArgs e) in
C:\Documents and Settings\saber\My Documents\Visual Studio
2005\WebSites\WebTesting\global.asax:line 27
at System.Web.SessionState.SessionStateModule.RaiseOn Start(EventArgs
e)
at System.Web.SessionState.SessionStateModule.OnStart (EventArgs e)
at System.Web.SessionState.SessionStateModule.Complet eAcquireState()
at
System.Web.SessionState.SessionStateModule.BeginAc quireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)
at
System.Web.HttpApplication.AsyncEventExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
The syntax you are using is good for an aspx file for a page. In
global.asax Profile is not defined . You can access it via
HttpContext.Current with syntax:

HttpContext.Current.Profile.GetPropertyValue("Ente rTime");

Eliyahu

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:en**************@TK2MSFTNGP14.phx.gbl...
in <system.web> of web.config I've:
[...]
<profile>
<properties>
<add name="EnterTime" type="System.DateTime" allowAnonymous="true"/>
</properties>
</profile>

And in Session_Start of global.asax:
[...]
Profile.EnterTime = System.DateTime.Now '**** Line 26

But I get an error message in line 26:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."



Mar 13 '06 #4
There is no difference in C# and VB syntax in this case (except the
semicolon of end of line!),
Thank you for showing me the right way, I've to use *SetPropertyValue*
because I'm writing
a value not reading.

VB:
Dim EnterTime As String = System.DateTime.Now.ToString
HttpContext.Current.Profile.SetPropertyValue("Ente rTime", EnterTime)

C#:
string EnterTime = System.DateTime.Now.ToString();
HttpContext.Current.Profile.SetPropertyValue("Ente rTime", EnterTime);

BUT again the same error message(NullReferenceException) :(
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:eE**************@TK2MSFTNGP10.phx.gbl...
I am not good in VB.

In GetPropertyValue(EnterTime) EnterTime should a string constant. In c# I
would write GetPropertyValue("EnterTime").

Eliyahu

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:Os**************@tk2msftngp13.phx.gbl...
Thanks Eliyahu,
I used your syntax:
Dim EnterTime As String = System.DateTime.Now.ToString
HttpContext.Current.Profile.GetPropertyValue(Enter Time)

but again the same error, here is the error details:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_global.asax.5_wxyugz"
StackTrace:
at ASP.global_asax.Session_Start(Object sender, EventArgs e) in
C:\Documents and Settings\saber\My Documents\Visual Studio
2005\WebSites\WebTesting\global.asax:line 27
at
System.Web.SessionState.SessionStateModule.RaiseOn Start(EventArgs e)
at System.Web.SessionState.SessionStateModule.OnStart (EventArgs e)
at
System.Web.SessionState.SessionStateModule.Complet eAcquireState()
at
System.Web.SessionState.SessionStateModule.BeginAc quireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)
at
System.Web.HttpApplication.AsyncEventExecutionStep .System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
The syntax you are using is good for an aspx file for a page. In
global.asax Profile is not defined . You can access it via
HttpContext.Current with syntax:

HttpContext.Current.Profile.GetPropertyValue("Ente rTime");

Eliyahu

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:en**************@TK2MSFTNGP14.phx.gbl...
in <system.web> of web.config I've:
[...]
<profile>
<properties>
<add name="EnterTime" type="System.DateTime" allowAnonymous="true"/>
</properties>
</profile>

And in Session_Start of global.asax:
[...]
Profile.EnterTime = System.DateTime.Now '**** Line 26

But I get an error message in line 26:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."



Mar 13 '06 #5
What can make a NullReferenceException when trying to read/write a Profile
value?
I configured the database using aspnet_regsql.exe wizard.
How to test it configured properly?

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:en**************@TK2MSFTNGP14.phx.gbl...
in <system.web> of web.config I've:
[...]
<profile>
<properties>
<add name="EnterTime" type="System.DateTime" allowAnonymous="true"/>
</properties>
</profile>

And in Session_Start of global.asax:
[...]
Profile.EnterTime = System.DateTime.Now '**** Line 26

But I get an error message in line 26:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."

Mar 13 '06 #6

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

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
5
by: Fabio Papa | last post by:
Hi, I am fairly new to programming and and even newer to dotnet. I appoligise in advance if this is a dumb questions, and I would appreciate if you could answer it anyways. :) I am writing a...
5
by: TT (Tom Tempelaere) | last post by:
Hi, Once in a while my application throws an NullReferenceException at startup, however it appears to be occurring in an unknown module. If I debug it and ask to 'break', then there is no source...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
6
by: Shimon Sim | last post by:
Hi I am working on application that need to hold custom user information - Last and first name, email, some other domain related information. I used to create Base class for all my pages. The base...
6
by: William Mild | last post by:
I must be getting brain fried. I can't see the error. Create a new web form with the following code begind: Public Class test Inherits System.Web.UI.Page Public Class ReportCardData ...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
11
by: Spencer | last post by:
I am working on a program that uses System.Xml and an XML file. I have the following code in my project that returns a NullReferenceException: profileDataDoc = new XmlDocument();...
1
by: r035198x | last post by:
This exception occurs often enough in practice to warrant its own article. It is a very silly exception to get because it's one of the easiest exceptions to avoid in programming. Yet we've all got it...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.