473,320 Members | 1,900 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,320 software developers and data experts.

Trace.Warn not working in my class

I have a page with Trace.Warns statements in my Page_Load and functions that
it calls, but it doesn't seem to work in a class that is defined on the same
page. I am writing this in C#

I am getting the following error at the 1st Trace.Warn:

***********************************************
Compiler Error Message: CS0118: 'System.Web.UI.Page.Trace' denotes a
'property' where a 'class' was expected

Source Error:

Line 84: {
Line 85: decimal mTemp = (decimal)dAmount;
Line 86: Trace.Warn("before rounding mTemp = ");
Line 87: mTemp = Decimal.Round(mTemp,2);
Line 88: Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = "
+ dBalance);
************************************************** ************************

The Function is:
*************************************
// Deposit - any positive deposit is allowed
public void Deposit(double dAmount)
{
if (dAmount 0.0)
{
decimal mTemp = (decimal)dAmount;
Trace.Warn("before rounding mTemp = ");
mTemp = Decimal.Round(mTemp,2);
Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = " +
dBalance);
dBalance += (double)mTemp;
}
}
****************************************

But in my function (not part of the class other than the Page class) the
Trace works fine:
**************************************************
void OpenBankAccount()
{
// open a bank account
Trace.Warn("Create a bank account object");
BankAccount ba = new BankAccount();
ba.InitBankAccount();
************************************************** ***

Why wouldn't it work in a class defined on the same page?

Thanks,

Tom
Sep 27 '07 #1
2 2567
Does the class you have inherit from the page object?

You can always use HttpContext.Current.Trace.Warn, which is the real method
call and not the shortcut that pages derived from the System.Web.UI.Page
provide.
--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"tshad" <tf*@dslextreme.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I have a page with Trace.Warns statements in my Page_Load and functions
that it calls, but it doesn't seem to work in a class that is defined on
the same page. I am writing this in C#

I am getting the following error at the 1st Trace.Warn:

***********************************************
Compiler Error Message: CS0118: 'System.Web.UI.Page.Trace' denotes a
'property' where a 'class' was expected

Source Error:

Line 84: {
Line 85: decimal mTemp = (decimal)dAmount;
Line 86: Trace.Warn("before rounding mTemp = ");
Line 87: mTemp = Decimal.Round(mTemp,2);
Line 88: Trace.Warn("after rounding mTemp = " + mTemp + " dBalance =
" + dBalance);
************************************************** ************************

The Function is:
*************************************
// Deposit - any positive deposit is allowed
public void Deposit(double dAmount)
{
if (dAmount 0.0)
{
decimal mTemp = (decimal)dAmount;
Trace.Warn("before rounding mTemp = ");
mTemp = Decimal.Round(mTemp,2);
Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = " +
dBalance);
dBalance += (double)mTemp;
}
}
****************************************

But in my function (not part of the class other than the Page class) the
Trace works fine:
**************************************************
void OpenBankAccount()
{
// open a bank account
Trace.Warn("Create a bank account object");
BankAccount ba = new BankAccount();
ba.InitBankAccount();
************************************************** ***

Why wouldn't it work in a class defined on the same page?

Thanks,

Tom

Sep 27 '07 #2
"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:ed**************@TK2MSFTNGP03.phx.gbl...
Does the class you have inherit from the page object?

You can always use HttpContext.Current.Trace.Warn, which is the real
method call and not the shortcut that pages derived from the
System.Web.UI.Page provide.
That was it.

I thought like all my other code when I don't use code-behind (Dreamweaver),
I can access functions such as Trace. I normally don't have to explicitly
define HttpContect.Current in my pages.

Thanks,

Tom
>

--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"tshad" <tf*@dslextreme.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I have a page with Trace.Warns statements in my Page_Load and functions
that it calls, but it doesn't seem to work in a class that is defined on
the same page. I am writing this in C#

I am getting the following error at the 1st Trace.Warn:

***********************************************
Compiler Error Message: CS0118: 'System.Web.UI.Page.Trace' denotes a
'property' where a 'class' was expected

Source Error:

Line 84: {
Line 85: decimal mTemp = (decimal)dAmount;
Line 86: Trace.Warn("before rounding mTemp = ");
Line 87: mTemp = Decimal.Round(mTemp,2);
Line 88: Trace.Warn("after rounding mTemp = " + mTemp + " dBalance =
" + dBalance);
************************************************* *************************

The Function is:
*************************************
// Deposit - any positive deposit is allowed
public void Deposit(double dAmount)
{
if (dAmount 0.0)
{
decimal mTemp = (decimal)dAmount;
Trace.Warn("before rounding mTemp = ");
mTemp = Decimal.Round(mTemp,2);
Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = "
+ dBalance);
dBalance += (double)mTemp;
}
}
****************************************

But in my function (not part of the class other than the Page class) the
Trace works fine:
************************************************* *
void OpenBankAccount()
{
// open a bank account
Trace.Warn("Create a bank account object");
BankAccount ba = new BankAccount();
ba.InitBankAccount();
************************************************* ****

Why wouldn't it work in a class defined on the same page?

Thanks,

Tom


Sep 28 '07 #3

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

Similar topics

3
by: Jens Alenius | last post by:
I've been looking at the Trace and TraceSwitch Classes i C# and I thrying to make it act more like java log4j. What I want is to add two different tracelisteners (like EventLogTraceListener and...
2
by: Richard | last post by:
Hi, I'm having trouble setting up a config file based trace switch & listener. I added an application config file to my console based C# program using the "Add New Application Config File" button...
0
by: Sally | last post by:
Can I set up my web.config and my @page to ONLY produce trace when I use Trace.Warn? I have some occasional problems and I want them to get logged, but if I log EVERY page hit, then I cannot...
5
by: martin | last post by:
Hi, The trace class seems to me to be very usefull however there are a few features of it that have to confused. I am using visual studio 2003. the IDE will not let me write ...
0
by: Elmo Watson | last post by:
Why would my Trace.Warn statements be Red (as I expect them to be) in some pages, and only black in others?
13
by: TJS | last post by:
How can I use trace.warn in a code class. I set the calling aspx page with trace=true but get this error when I put a trace.warn("hello") in my code class ------------------...
2
by: tshad | last post by:
I have been working in VB.net and have never had a problem with trace.warn or trace.write. I have a test program in C# that is giving me an error: ...
2
by: Tiësto | last post by:
Should I always check if Trace is enabled before attempting to use Trace.Write or Trace.Warn? will it throw an exception if I don't? will It make thing slower if I write entries in the trace when I...
0
by: Mark | last post by:
I am testing the tracing function of ASP.NET 2.0 and have included the following code in the the global.asax file: protected void Application_AcquireRequestState(object sender, EventArgs e) { ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.