Solved

C#; implementing an inherited abstract member

Posted on 2004-08-03
4
835 Views
Last Modified: 2012-08-14
Greetings,

I am working through Amit Kalani's book in preperation for Microsoft exam 70-315 (Web Apps in C# and .NET), currently nearing the end, the chapter pertaining to testing, debugging and deployment.
The current exercise is about trace listeners, and has you develop a custom class called EmailTraceListener that sends any debug or trace info to an email address. It inherits from the TraceListener class. According to the book, in order to inherit from this class, you must at least implement its Write() and WriteLine() methods, which I have done. Then you also create a Web form pertaining to calculating factorials. In the code for the form, you add a custom listener to the PageLoad() method which uses an EmailTraceListener to add to the custom Listeners collection.
When I attempt to run the Web page, I get an error message in my output window stating that the page does not implement inherited abstract member "System.Diagnostics.TraceListener.Write(string)".
Here is a copy directly from the custom class:
            public override void Write(string message)
            {
                  if (this.message == null)
                        this.message = new    StringBuilder();
                  this.message.Append(message);
            }

Any input out there that might solve this issue?

Thanks in advance,
Robert Waskins
Seattle
0
Comment
Question by:bob_aloo
  • 2
4 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 11717033
Maybe remove the word override?  If there is no base parent definition then there is nothing to override - it just needs to be defined.
0
 

Author Comment

by:bob_aloo
ID: 11720201
mrichmon,

Thanks for the input. However, the instructions clearly state that the Write() method must be overridden.

Quoting:
If you want a listener object to perform differently from these three
listener classes, you can create your own class that inherits from the
TraceListener class. When doing so, you must at least implement
the Write() and WriteLine() methods.

And the sample code:
// A custom listener must override
// Write() method
public override void Write(string message)
{
if (this.message == null)
this.message = new StringBuilder();
this.message.Append(message);
}
// A custom listener must override
// WriteLine() method
public override void WriteLine(string message)
{
if (this.message == null)
this.message = new StringBuilder();
this.message.Append(message);
this.message.Append(‘\n’);
}
Any other ideas?

Thanks,
Robert
0
 
LVL 5

Accepted Solution

by:
LlamaJoe earned 125 total points
ID: 11919437
Try deleting your temporary asp.net files (c:\windows\microsoft.net\framework\v1.x\temporary asp.net files\) for your project, then do a rebuild solution - not build solution.

or - common bizarre issue, make sure you override Write before you override WriteLine
0
 

Author Comment

by:bob_aloo
ID: 11936157
LLamaJoe,

You nailed it. I had to override Write before WriteLine.

Thx,
Robert
Seattle
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now