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

Rate It (1)

Last post 05-19-2008 8:50 AM by Elrinth. 135 replies.

Sort Posts:

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

    01-16-2006, 3:27 PM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 113
    I ran into this error in the beta of VS 2005 a few times, and now I'm expirencing it in the VS 2005 release.

    My code works fine for about the first hour or so of coding, then out of the blue, when I haven't changed anything in the code I get this error:

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

    After a (not so wonderfully quick) restart of VS, my code works fine again, for about another hour.  This is really annoying, and I would like to know what is going wrong.  A bug report was opened with Microsoft, and the quickly closed it because "They could not reproduce it" (or didn't really try).  I have seen others verify that this bug does exist.  Does anyone have any information about it at all?
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    01-27-2006, 12:10 PM
    • Loading...
    • beatniks
    • Joined on 01-27-2006, 5:05 PM
    • Posts 11

    I've been getting the same thing.  Everything works fine for a few days and then "BAM!" I get the same error without changing any code:

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

    The offending code:

    Line 160:        Dim mp As New MasterPage
    Line 161:        mp = CType(Me.Master, MasterPage)
    Line 162:        mp.AdtoCart(dt)

    I get the error on both a local dev machine and on a testing server hosted by a large hosting company.

    Beatniks

  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    01-30-2006, 1:17 PM
    • Loading...
    • jsalwen
    • Joined on 03-22-2003, 2:47 PM
    • Posts 4

    I have been having the same problem. It will also be fine, then it pops up, then it fixes itself (after 30 hours over the weekend) :(

    Once it starts happening, it effects all pages that set properties in master pages:

    Example:

    Page_Load of .aspx page

    Master.PageType = Enumorators.PageDisplayType.Full

    If we are around, we can fix it by making a minor mod to the global.asax or web.config, which forces the app to recompile.

    This is a big problem for us, so any help is appreciated.

  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    01-31-2006, 3:51 PM
    • Loading...
    • beatniks
    • Joined on 01-27-2006, 5:05 PM
    • Posts 11

    If I repost the web.config file to the host site, it seems to fix it, confirming jsalwen's post.  I don't have to make ANY changes to the file.

     

     

  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    01-31-2006, 7:02 PM
    • Loading...
    • SimonCal
    • Joined on 06-10-2002, 8:43 PM
    • Posts 376
    • Moderator

    We are trying to get a repro for this, so if you can describe exactly your site structure, the way you are using the masterpages from content pages and whatever changes may be occuring in your sites to cause the issues, these would be greatly appreciated.

    many thanlks

    Simon
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-01-2006, 1:00 AM
    • Loading...
    • Chuck H
    • Joined on 01-30-2006, 5:55 PM
    • San Jose, CA
    • Posts 5

    I have the same problem. I haven't noticed exactly what triggers it to start failing, but it seems to have started right after I created a nested Master page and then started creating pages using that Master page in a folder different from the folder containing the nested Master page. When the errors occur, Intellisense is also gone for the nested Master Page class.

    For me, the problem doesn't seem to fully disappear until I do multiple Rebuild Web Site commands.  Getting the problem to go away also may depend on which particular source files are open for editing when the Rebuilding is taking place. I would bet this is a VS 2005 bug.

    Chuck Hartman
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-01-2006, 9:48 AM
    • Loading...
    • dlmcdanl
    • Joined on 10-03-2005, 8:11 PM
    • Posts 3

    I too have experienced the same issue.  However, I have found that you do not have to restart the program.  You can enter a blank line in your master page, then delete it, rebuild your program and your code should work after that.  I am not using Nested Master pages but I do have multiple content areas on my master pages.  And it happens only after I have been coding for about an hour or so.  I have also found that sometimes this same error will appear when publishing from development to test even if you have made no code changes to any pages attached to the master page or the master page itself. So be sure and test all your pages right after publishing to make sure the publish is ok. 

    Donna

  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-01-2006, 10:10 AM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 113
    I'm not using nested master pages, and the files that are using the master page are at the same directory level as the master page.

    My master page does include some code to render a menu system in one of it's content areas, but I doubt that is the reason for the problem.
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-01-2006, 7:58 PM
    • Loading...
    • jsalwen
    • Joined on 03-22-2003, 2:47 PM
    • Posts 4
    I have a workaround!!

    I added a Try Catch around the problem code:

    Was:
    Master.BodyCSSClass = "fixWidth"

    Workaround (in VB):
    Try
       Master.BodyCSSClass = "fixWidth"
    Catch ex As Exception
       ' Log error
    End Try

    Funny thing though . . .
    I expected the page to load, even w the error happens. But I assumed the property would not be set in the Master page. I figured I could live with this for now.

    However, even when the error gets reported, the page loads and the Master's custom property gets set. Very WEIRD!



  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-10-2006, 11:57 AM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 113
    I would now rate this bug as very serious to critical.  At first I was only seeing it in my production environment, today it occured on our staging server.  I have serious doubts about deploying an ASP.NET application that could break at any moment.  The only solution that I have is to rewrite all of my code without using Master Pages. 

    ASP.NET team, please figure this out ASAP!
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-10-2006, 12:17 PM
    This has happened to me also, but I can't duplicate it. The only solution is to upload a file in a directory that causes the application to restart (i.e. App_Code, App_GlobalResources, Web.config, etc.).
    Ryan Olshan
    Microsoft MVP, ASP.NET
    Blog | Group | Website | Strong Coders Community

    How to ask a question
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-13-2006, 2:34 PM
    • Loading...
    • cytosoul
    • Joined on 08-02-2005, 2:20 PM
    • Posts 17

    I am also having a similar problem.  I have a simple site using a masterpage in the same directory as the affected page.  Closing/restarting VS cures this for a random period of time.  Sometimes hours, sometimes minutes.  There have been cases where I load the editor, make a small tweak to the codebehing on a completely different page, and start debugging.  My error does not reference the masterpage:

    "Unable to cast object of type 'ASP.info_parameters_aspx' to type 'ASP.info_parameters_aspx'."

    The line of code causing this error is in the codebehind:

    if (!PreviousPage.IsValid)

    Detailed exception error:

    System.InvalidCastException was unhandled by user code
      Message="Unable to cast object of type 'ASP.info_parameters_aspx' to type 'ASP.info_parameters_aspx'."
      Source="App_Web_f27gonji"
      StackTrace:
           at MemberResultsList.get_PreviousPage() in c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\phc\cfa5ec36\a10de74\App_Web_f27gonji.0.cs:line 0
           at MemberResultsList.Page_Load(Object sender, EventArgs e) in c:\dev\Data\WebSites\PHC\info\MemberResultsList.aspx.cs:line 20
           at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
           at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
           at System.Web.UI.Control.OnLoad(EventArgs e)
           at System.Web.UI.Control.LoadRecursive()
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-14-2006, 3:18 PM
    • Loading...
    • Thales2010
    • Joined on 11-30-2005, 5:25 PM
    • Posts 3
    This is randonly happening to me as well.

    While I do use Master Pages, this seems unrealted to the master itself - my "unable to cast X.aspx to X.asp" message comes when using the PreviousPage call against a get method in my .aspx.cs code - e.g.: PreviousPage.getTextBoxValue();

    I only use this type of methodology in 2 pages (I use query strings for my other pages), and this error has only ever occured when passing from one of these pages to the next when they call PreviousPage.


    Here's to hoping MS can get a handle on this quickly...
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-14-2006, 3:33 PM
    • Loading...
    • RyanSmith345
    • Joined on 12-13-2005, 6:00 PM
    • Fort Collins, CO
    • Posts 113
    Here is a little more information about what I have discovered with this problem.  I usually get the error when I change my default page "Default.aspx"

    What's interesting is that Default.aspx is one of the only pages in the site that doesn't make use of the MasterPage causing the problem.  When I make a change to it, I can view it, but when I navigate to one of the pages that uses the master page, I get the error.

    Like everyone has said, make a change to the web.config to force it to reload, or restarting the web server solves the problem and everything works the way it is suppose to.
  • Re: Unable to cast object of type 'ASP.masterpage_master' to type 'ASP.masterpage_master'.

    02-18-2006, 11:53 AM
    • Loading...
    • tripletdad
    • Joined on 11-19-2005, 3:14 PM
    • Posts 18
    I'm getting the same error.  I've found - as strange as this may be - that if I change anything (even one character) in the MasterPage, then re-save... I can continue onward.  This is really weird.


Page 1 of 10 (136 items) 1 2 3 4 5 Next > ... Last ยป