Erratic Masterpage exception

Erratic Masterpage exception

am 15.01.2008 21:35:02 von SandpointGuy

I have a masterpage named MasterpageController with a menu. In the
codebehind I have a method SetMasterMenu() to display the
appropriate menu items.
The content page, which has a MasterType directive, executes the method
using "this.Master.SetMasterMenu()". Runs fine for maybe 5-10
"start with/without debugging"'s, while I am in development mode in vs.net
2005, and then I'll start getting an "Unable to cast object of type
'ASP.masterpagecontroller_master' to type 'ASP.masterpagecontroller_master'"
when the content page attempts to execute the method. I have to restart IIS
to get the app to run correctly .. then a few starts later I get the
exception.
Any ideas on how to fix this?

Re: Erratic Masterpage exception

am 15.01.2008 22:32:30 von Jonathan Wood

SandpointGuy,

>I have a masterpage named MasterpageController with a menu. In the
> codebehind I have a method SetMasterMenu() to display the
> appropriate menu items.
> The content page, which has a MasterType directive, executes the method
> using "this.Master.SetMasterMenu()". Runs fine for maybe 5-10
> "start with/without debugging"'s, while I am in development mode in vs.net
> 2005, and then I'll start getting an "Unable to cast object of type
> 'ASP.masterpagecontroller_master' to type
> 'ASP.masterpagecontroller_master'"
> when the content page attempts to execute the method. I have to restart
> IIS
> to get the app to run correctly .. then a few starts later I get the
> exception.
> Any ideas on how to fix this?Sounds like you might want to upgrade to
> VS2008.

I've never seen this error but looks like you're not the only one.

See http://forums.asp.net/p/954194/1184928.aspx.

Then, on page 2, Microsoft replies with:

"This particular exception error can happen a number of ways (most typically
due to developer error), which is why it took awhile to figure out what was
happening and identify the bug.

As Ryan mentioned above, we are releasing a QFE hotfix that will be
available in a few weeks (QFE reference #4039). It is in testing right now
and we'll release it once we have confirmation from a number of customers
who have reported it that it fixes the issue.

As a temporary workaround, you can also disable batch compilation when
deploying your production apps. This can be done by setting the
attribute in web.config. This will avoid the
problem occuring in a production environment.

Note that you want to be careful using the above switch at development
time -- since it will slow does VS compiles quite a bit. But if you want to
be safe when you deploy files you can enable it until the QFE comes out."

This was posted in February of 2006.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Re: Erratic Masterpage exception

am 15.01.2008 22:49:03 von SandpointGuy

Thanks.
I had been running this code for months without the problem.
I have been working on an .ascx control to do file uploads from. I dragged
it onto a page and this started happening. The page I dragged it onto isnt
executed when this problem happens. But if I were asked what was different
since yesterday, I would point to this.

"Jonathan Wood" wrote:

> SandpointGuy,
>
> >I have a masterpage named MasterpageController with a menu. In the
> > codebehind I have a method SetMasterMenu() to display the
> > appropriate menu items.
> > The content page, which has a MasterType directive, executes the method
> > using "this.Master.SetMasterMenu()". Runs fine for maybe 5-10
> > "start with/without debugging"'s, while I am in development mode in vs.net
> > 2005, and then I'll start getting an "Unable to cast object of type
> > 'ASP.masterpagecontroller_master' to type
> > 'ASP.masterpagecontroller_master'"
> > when the content page attempts to execute the method. I have to restart
> > IIS
> > to get the app to run correctly .. then a few starts later I get the
> > exception.
> > Any ideas on how to fix this?Sounds like you might want to upgrade to
> > VS2008.
>
> I've never seen this error but looks like you're not the only one.
>
> See http://forums.asp.net/p/954194/1184928.aspx.
>
> Then, on page 2, Microsoft replies with:
>
> "This particular exception error can happen a number of ways (most typically
> due to developer error), which is why it took awhile to figure out what was
> happening and identify the bug.
>
> As Ryan mentioned above, we are releasing a QFE hotfix that will be
> available in a few weeks (QFE reference #4039). It is in testing right now
> and we'll release it once we have confirmation from a number of customers
> who have reported it that it fixes the issue.
>
> As a temporary workaround, you can also disable batch compilation when
> deploying your production apps. This can be done by setting the
> attribute in web.config. This will avoid the
> problem occuring in a production environment.
>
> Note that you want to be careful using the above switch at development
> time -- since it will slow does VS compiles quite a bit. But if you want to
> be safe when you deploy files you can enable it until the QFE comes out."
>
> This was posted in February of 2006.
>
> --
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
>
>

Re: Erratic Masterpage exception

am 15.01.2008 23:11:45 von George Ter-Saakov

I would bet on caching to be a problem..
LoadControl (which might be used with master pages inexplicitly) function
will return not a reference to an object but reference to
PartialCachingControl which might be not your object you trying to cast
to...

So try to investigate into that direction...

George

"Jonathan Wood" wrote in message
news:%23jYPj47VIHA.2268@TK2MSFTNGP02.phx.gbl...
> SandpointGuy,
>
>>I have a masterpage named MasterpageController with a menu. In the
>> codebehind I have a method SetMasterMenu() to display the
>> appropriate menu items.
>> The content page, which has a MasterType directive, executes the method
>> using "this.Master.SetMasterMenu()". Runs fine for maybe
>> 5-10
>> "start with/without debugging"'s, while I am in development mode in
>> vs.net
>> 2005, and then I'll start getting an "Unable to cast object of type
>> 'ASP.masterpagecontroller_master' to type
>> 'ASP.masterpagecontroller_master'"
>> when the content page attempts to execute the method. I have to restart
>> IIS
>> to get the app to run correctly .. then a few starts later I get the
>> exception.
>> Any ideas on how to fix this?Sounds like you might want to upgrade to
>> VS2008.
>
> I've never seen this error but looks like you're not the only one.
>
> See http://forums.asp.net/p/954194/1184928.aspx.
>
> Then, on page 2, Microsoft replies with:
>
> "This particular exception error can happen a number of ways (most
> typically due to developer error), which is why it took awhile to figure
> out what was happening and identify the bug.
>
> As Ryan mentioned above, we are releasing a QFE hotfix that will be
> available in a few weeks (QFE reference #4039). It is in testing right
> now and we'll release it once we have confirmation from a number of
> customers who have reported it that it fixes the issue.
>
> As a temporary workaround, you can also disable batch compilation when
> deploying your production apps. This can be done by setting the
> attribute in web.config. This will avoid the
> problem occuring in a production environment.
>
> Note that you want to be careful using the above switch at development
> time -- since it will slow does VS compiles quite a bit. But if you want
> to be safe when you deploy files you can enable it until the QFE comes
> out."
>
> This was posted in February of 2006.
>
> --
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
>