Divelements Community
Customer discussion of all Divelements products

Themes and Reflection(?)

Latest post 04-25-2008 11:49 by Steve. 2 replies.
  • 04-24-2008 9:56

    • Steve
    • Not Ranked
    • Joined on 04-09-2008
    • UK
    • Posts 2

    Themes and Reflection(?)

    Hi there,

    I am having a problem applying a theme to SandDock. Whenever the following code is invoked I get a NullReferenceException (stack trace at bottom)

          private void UserControl_Loaded(object sender, RoutedEventArgs e)
            {
                Divelements.SandDock.Rendering.Themes.SetOffice2007Theme(Divelements.SandDock.Rendering.Office2007.Office2007ColorScheme.Blue);
            }

    I have my suspicions that this is failing because the UserControl on which the dock resides is being loaded dynamically via reflection. This is due to the fact that the application is being developed as a Composite Application which is part of the Smart Client Software Factory (http://msdn2.microsoft.com/en-us/library/aa480482.aspx).

    From what I understand each component is loaded via reflection and the application does not hold any “hard” references to each module that can be executed.  I think that there must be some differences in the object hierarchy when the UserControl is loaded dynamically (a parent, container or something similar).

     

    Any ideas on how to fix this without having an actual reference to the UserControl library?

    Thanks,

    Steve

    ================================================

    Stack Trace

    ================================================

       at Divelements.SandDock.Rendering.Themes.ClearThemes()
       at Divelements.SandDock.Rendering.Themes.SetOffice2007Theme(Office2007ColorScheme colorScheme)
       at ...UserControl_Loaded(Object sender, RoutedEventArgs e) in C:\Documents and Settings\....\View.xaml.cs:line 315
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
       at MS.Internal.FrameworkObject.OnLoaded(RoutedEventArgs args)
       at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
       at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
       at MS.Internal.LoadedOrUnloadedOperation.DoWork()
       at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Microsoft.Practices.CompositeUI.WinForms.FormShellApplication`2.Start()
       at Microsoft.Practices.CompositeUI.CabApplication`1.Run()
       at Workbench.Program.Main() in C:\Documents and Settings\....\Workbench Shell\Program.cs:line 21

  • 04-24-2008 15:40 In reply to

    Re: Themes and Reflection(?)

    Do you have an Application object created before calling this function? At least with the WPF SandRibbon control you need to create the Application object before setting the theme.
  • 04-25-2008 11:49 In reply to

    • Steve
    • Not Ranked
    • Joined on 04-09-2008
    • UK
    • Posts 2

    Re: Themes and Reflection(?)

    You are spot on. The Application.Current property is null. Now I just need to work out how to make sure its set correctly when the app starts up.

    Thanks.

Page 1 of 1 (3 items) | RSS
Copyright © 2008 Divelements Limited
Powered by Community Server (Commercial Edition), by Telligent Systems