Unable to cast object of type 'ASP.masterpage_master' to type 'MasterPage

Discussion in 'ASP .Net' started by GaryDean, Feb 28, 2008.

  1. GaryDean

    GaryDean Guest

    "Unable to cast object of type 'ASP.masterpage_master' to type 'MasterPage"

    This code has always worked but today it is getting the exception in the
    subject line of this post...

    protected void Page_Load(object sender, EventArgs e)
    {

    this.Master.HeadingLabel.Text = "Direct 4506 Purchase"; <--this
    gets the cast exception

    I'm changing a public property in the master page- we do it all the time. I
    googled the error and a lot of people were getting it back in 2006 where it
    had to do with a caching bug in IIS I think. Why would I suddenly get this
    today? I bounced IIS reloaded the project but to no avail.
    Thanks,
    Gary
    GaryDean, Feb 28, 2008
    #1
    1. Advertising

  2. Hello Gary,

    Microsoft has admitted the problem "Unable to cast object of type
    'ASP.masterpage_master' to type 'MasterPage" an issue of ASP.NET Framework.

    See the KB article:
    FIX: You may receive an InvalidCastException error in an ASP.NET-connected
    Web application
    http://support.microsoft.com/kb/915782/en-us
    <quote>A supported hotfix is now available from Microsoft. However, it is
    intended to correct only the problem that is described in this article.
    Apply it only to systems that are experiencing this specific problem. This
    hotfix may receive additional testing. Therefore, if you are not severely
    affected by this problem, we recommend that you wait for the next Microsoft
    ..NET Framework 2.0 service pack that contains this hotfix.</quote>

    and see the issue report on http://connect.microsoft.com:
    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedba
    ckID=105052&wa=wsignin1.0
    <quote>We have a fix for this issue that we are testing internally. If you
    want to test this fix please contact, Todd Carter, MCSE, MCSD Senior
    Escalation Engineer ASP.NET Escalation Services, Microsoft Corp. email:
    phone: 469.775.7918 cell: 972.743.6424 blog:
    http://blogs.msdn.com/toddca.</quote>

    I am sorry for the inconveniences caused by the problem. If you feel it
    critical to the current situation, please visit
    http://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=370
    5 (need your registration), or contact the person above to get the hotfix's
    test version. Otherwise, we recommend that you wait for the next .NET
    Framework 2.0 Service pack release.

    If you have any other concerns or questions, please feel free to let me
    know.

    Regards,
    Jialiang Ge (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    For MSDN subscribers whose posts are left unanswered, please check this
    document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications. If you are using Outlook Express/Windows Mail, please make sure
    you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
    see your reply promptly.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Jialiang Ge [MSFT], Feb 28, 2008
    #2
    1. Advertising

  3. GaryDean

    GaryDean Guest

    Jialiang,
    I found a post on Experts Exchange to add a batch entry to the following in
    the web.config...
    <compilation debug="true" batch="false"> and it worked!

    Two things I don't understand:
    #1 What does this batch entry do?
    #2 This was a hotfix back in April of 2006 - hard to believe it has not been
    in a service pack by now.

    Thanks for your help
    Gary

    "Jialiang Ge [MSFT]" <> wrote in message
    news:...
    > Hello Gary,
    >
    > Microsoft has admitted the problem "Unable to cast object of type
    > 'ASP.masterpage_master' to type 'MasterPage" an issue of ASP.NET
    > Framework.
    >
    > See the KB article:
    > FIX: You may receive an InvalidCastException error in an ASP.NET-connected
    > Web application
    > http://support.microsoft.com/kb/915782/en-us
    > <quote>A supported hotfix is now available from Microsoft. However, it is
    > intended to correct only the problem that is described in this article.
    > Apply it only to systems that are experiencing this specific problem. This
    > hotfix may receive additional testing. Therefore, if you are not severely
    > affected by this problem, we recommend that you wait for the next
    > Microsoft
    > NET Framework 2.0 service pack that contains this hotfix.</quote>
    >
    > and see the issue report on http://connect.microsoft.com:
    > https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedba
    > ckID=105052&wa=wsignin1.0
    > <quote>We have a fix for this issue that we are testing internally. If you
    > want to test this fix please contact, Todd Carter, MCSE, MCSD Senior
    > Escalation Engineer ASP.NET Escalation Services, Microsoft Corp. email:
    > phone: 469.775.7918 cell: 972.743.6424 blog:
    > http://blogs.msdn.com/toddca.</quote>
    >
    > I am sorry for the inconveniences caused by the problem. If you feel it
    > critical to the current situation, please visit
    > http://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=370
    > 5 (need your registration), or contact the person above to get the
    > hotfix's
    > test version. Otherwise, we recommend that you wait for the next .NET
    > Framework 2.0 Service pack release.
    >
    > If you have any other concerns or questions, please feel free to let me
    > know.
    >
    > Regards,
    > Jialiang Ge (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > For MSDN subscribers whose posts are left unanswered, please check this
    > document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
    >
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications. If you are using Outlook Express/Windows Mail, please make sure
    > you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
    > see your reply promptly.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    GaryDean, Feb 28, 2008
    #3
  4. Hello Gary,

    Yes, you are right. I confirmed with the ASP.NET team. The hotfix was
    released on 4/12/2007, and it has been included into .NET Framework 2.0 SP1
    (See: Problems that are fixed in the .NET Framework 2.0 SP1
    http://support.microsoft.com/kb/945757). I think the KB article
    http://support.microsoft.com/kb/915782/en-us does need an update to reflect
    this. I will file a request to the KB team and ask them to update the
    article as soon as possible. Thank you for pointing it out.

    The "batch" attribute in the <compilation> element indicates whether
    batching is supported. If True (default to be true), eliminates the delay
    caused by the compilation when you access a file for the first time.
    ASP.NET precompiled all the uncompelled files in a batch mode, which causes
    an even longer delay the first time the files are compiled. However, after
    this initial delay, this compilation delay is eliminated on subsequent
    access of the file. If this attribute is False, we turn off the batch
    compilation on the web site. See MSDN article
    http://msdn2.microsoft.com/en-us/library/s10awwz0.aspx

    I also see a lot of community member say that batch="false" can resolved
    the problem:
    http://forums.asp.net/t/954194.aspx?PageIndex=7
    and Scott Guthrie from Microsoft agreed that it can fix the problem. This
    doesn't impact runtime performance. IIS also doesn't recompile when the
    application restarts unless there has been a code or configuration change
    that requires it - so you won't have performance issues related to that
    unless you are making code changes on the live site.

    Scott Guthrie has a great blog entry at:
    http://weblogs.asp.net/scottgu/archive/2007/04/11/public-hotfix-patch-availa
    ble-for-asp-net-compilation-issues.aspx
    This explains the resolution of the issue in detail.

    If you have any other concern or need anything else, please feel free to
    let me know.

    Thanks
    Jialiang Ge (, remove 'online.')
    Microsoft Online Community Support

    =================================================
    When responding to posts, please "Reply to Group" via your newsreader
    so that others may learn and benefit from your issue.
    =================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Jialiang Ge [MSFT], Feb 29, 2008
    #4
  5. GaryDean

    ketanbece

    Joined:
    Oct 29, 2008
    Messages:
    2
    Just See this Solution

    i found it's During googleing

    dotnet-magic.blogspot.com/2008/12/unable-to-cast-object-of-type-asptype.html
    ketanbece, Dec 2, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Imran Aziz
    Replies:
    4
    Views:
    8,665
    ljenner01
    Jan 19, 2011
  2. Replies:
    2
    Views:
    3,057
    silverfox_1188
    Aug 16, 2006
  3. Replies:
    0
    Views:
    904
  4. Replies:
    1
    Views:
    1,142
  5. BillE
    Replies:
    0
    Views:
    447
    BillE
    Nov 8, 2006
Loading...

Share This Page