01-24-06 12:50 PM
Hi Martin,
what kind of problem do you get?
An exception?
What kind of exception?
Is there a call stack coming with this exception?
Did "currentChannel" get an instance in the first assignment?
If yes: does currentChannel contain "null" or not in the ** line?
Actually the code should work fine.
This would either be a bug or a database inconsistancy.
Please open a support case to get this analyzed in more details.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"Martin" <x@y.z> wrote in message
news:%235C9MNNIGHA.3944@tk2msftngp13.phx.gbl...
> Hi Stefan,
>
> I have a little class to help with channel navigation in my CMS site.
>
> In the constructor I have the following code
> Dim currentChannel, tmpChannel As channel
> Dim tmpLevel As Integer
> Dim appSR As AppSettingsReader
>
> currentChannel = CmsHttpContext.Current.Channel
> ' rootChannel = CmsHttpContext.Current.RootChannel()
> ' Work around for spurious bug accessing RootChannel()
>
> ' Work out what leve the current channel is at
> _level = 0
> ++ tmpChannel = currentChannel
> While Not tmpChannel.IsRoot
> tmpChannel = tmpChannel.Parent
> _level += 1
> End While
> _rootChannel = tmpChannel
>
> ' Get level 1 channel
> xx currentChannel = CmsHttpContext.Current.Channel
> ** tmpChannel = currentChannel
> tmpLevel = _level
> While tmpLevel > 1
> tmpChannel = tmpChannel.Parent
> tmpLevel -= 1
> End While
> 'tmpChannel now has level 1 channel in it if one exists
>
> Before I put in the line marked xx, the line marked ** fails with a null
> reference exception. I can't understand it as the line marked with ++
> above works fine. It looks like a CMS bug to me, but I might have missed
> something (??)
>
> Why is it necessary to have the line xx to make this work? I have only
> tried the work around with SP2.
>
> Thanks
> Martin
>
[ Post a follow-up to this message ]
|