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

G

GaryDean

"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
 
J

Jialiang Ge [MSFT]

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:
(e-mail address removed) 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 ([email protected], 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.
 
G

GaryDean

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
 
J

Jialiang Ge [MSFT]

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 ([email protected], 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.
 
Joined
Oct 29, 2008
Messages
2
Reaction score
0
Just See this Solution

i found it's During googleing

dotnet-magic.blogspot.com/2008/12/unable-to-cast-object-of-type-asptype.html
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top