Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Where is the Message object that was in VS 2008

Posted on 2013-05-31
6
Medium Priority
?
458 Views
Last Modified: 2013-06-05
This worked in VS 2008. It is Error Handler code

      <asp:LinkButton ID="DetailLinkButton" runat="server"
            OnClick="DetailLinkButton_Click">Show Details
        </asp:LinkButton>

protected void DetailLinkButton_Click(object sender, EventArgs e)
        //Displays error details only to the web master
        {
            if (this.MessagePanel.Visible)
            {
                this.MessagePanel.Visible = false;
                this.DetailLinkButton.Text = "Show Details";
            }
            else
            {
                if (Message.LastException != null)
                {
                    this.MessageTextBox.Text = "Error Caught in Application_Error event\n" +
                        "Error in: " + Request.Url.ToString() +
                        "\n\nError Message:" + Message.LastException.Message.ToString() +
                        "\n\nStack Trace:" + Message.LastException.StackTrace.ToString();
                }
                else
                {
                    //this should never happen.
                    this.MessageTextBox.Text = "There is no exception.";
                }

Error in 2012

Error      1      The name 'Message' does not exist in the current context      C:\Users\Dovberman\Documents\Visual Studio 2012\Projects\StockPro\WebApplication1\ErrorHandling\ShowError.aspx.cs      93      21      StockPro

What replaces the Message object in vs 2012 ?

Thanks
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39211432
I'm not familiar with a Message object in ASP.Net C# or VB.  Is it possible this was a user-defined class that didn't make it over (or was renamed) from VS2k8?
0
 

Author Comment

by:Dovberman
ID: 39211616
I partially fixed this.

http://bytes.com/topic/asp-net/answers/564850-global-error-handler

Added this line to the web.config file:

<!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.
            -->
    <customErrors mode="On" defaultRedirect="~/ErrorHandling/ShowError.aspx">
    </customErrors>

Message.LastException seems to be an error object.

Again, this worked in VS 2008 in .net 2.0.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39211619
Interesting.

What part still doesn't work?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Dovberman
ID: 39211752
if (Message.LastException != null)


Error      1      The name 'Message' does not exist in the current context      C:\Users\Dovberman\Documents\Visual Studio 2012\Projects\StockPro\WebApplication1\Global.asax.cs      16      9      StockPro

The message object was part of the exception class in vs 2008.

Message.LastException  represented the most recent error that was passed to the error handler.

Is there is new way to handle errors in vs 2012 using .net 4.5?
0
 

Accepted Solution

by:
Dovberman earned 0 total points
ID: 39212158
I removed this block of code that displayed the error message only if Admin was logged on.

I will display the exception detail to the Web Master within the Catch block instead .

protected void DetailLinkButton_Click(object sender, EventArgs e)
        //Displays error details only to the web master
        {
            if (this.MessagePanel.Visible)
            {
                this.MessagePanel.Visible = false;
                this.DetailLinkButton.Text = "Show Details";
            }

            else
            {
                if (Message.LastException != null)
                {
                    this.MessageTextBox.Text = "Error Caught in Application_Error event\n" +
                        "Error in: " + Request.Url.ToString() +
                        "\n\nError Message:" + Message.LastException.Message.ToString() +
                        "\n\nStack Trace:" + Message.LastException.StackTrace.ToString();
                }
                else
                {
                    //this should never happen.
                    this.MessageTextBox.Text = "There is no exception.";
                }

                this.MessagePanel.Visible = true;
                this.DetailLinkButton.Text = "Hide Details";
            }}
0
 

Author Closing Comment

by:Dovberman
ID: 39221525
I resolved this issue myself.
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

715 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