Setting ThemeManager.CurrentTheme runtime-ok MsTest-nok

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 15 years ago by Kris Goossens - Remmicom
Version: 4.5.0471
Avatar
Setting CurrentTheme doesn't work in MsTest & does work in normal run.

Window :
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBlock Text="This is a test"
Background="{DynamicResource {x:Static themes:ExplorerBarCommonDictionary.BackgroundBrushKey}}"/>
</Grid>
</Window>

Code :
Partial Public Class Window1
Protected Overrides Sub OnInitialized(ByVal e As System.EventArgs)
MyBase.OnInitialized(e)
Try
'ActiproSoftware.Windows.Themes.ThemeManager.CurrentTheme = "Office2007Black"
'=> Runtime error in MsTest, Ok in normal run.

ActiproSoftware.Windows.Themes.ThemeManager.SetTheme(Me, "Office2007Black")
'=> both ok

Catch ex As Exception
End Try
End Sub
End Class

So, why does setting CurrentTheme doesn't work in MsTest ?

Comments (6)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Unfortunately we have the VS for developers edition here. What specifically is the error you see? Please provide as much detail as possible and if appropriate, email over to our support team some screenshots and your information.


Actipro Software Support

Posted 15 years ago by Kris Goossens - Remmicom
Avatar
I run into a NullReference :

System.NullReferenceException was caught
Message="De objectverwijzing is niet op een exemplaar van een object ingesteld."
Source="ActiproSoftware.Shared.Wpf30"
StackTrace:
bij ActiproSoftware.Windows.Themes.ThemeManager.a(String A_0, String A_1)
bij ActiproSoftware.Windows.Themes.ThemeManager.set_CurrentTheme(String value)
bij WpfApplication16.Window1.OnInitialized(EventArgs e) in ...\WpfApplication16\Window1.xaml.vb:regel 8
InnerException: Nothing

StackTrace
bij ActiproSoftware.Windows.Themes.ThemeManager.a(String A_0, String A_1)
bij ActiproSoftware.Windows.Themes.ThemeManager.set_CurrentTheme(String value)
bij WpfApplication16.Window1.OnInitialized(EventArgs e) in ...\WpfApplication16\Window1.xaml.vb:regel 8



Sorry for the dutch words in the error.
"bij" = by or at
"De objectverwijzing is niet op een exemplaar van een object ingesteld." = ObjectReference not set to an instance of an object.

I maild some screenshots to support too.
Using nUnit instead of MsTest, doesn't work either.

Grtz
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks for the screenshots. Based on the stack trace and your other info, my guess is that there is no Application.Current object instantiated, which is certainly odd.

Can you do a test on your end to see if Application.Current is indeed null? If so, that is the problem. I've added a check for that scenario for the next build.


Actipro Software Support

Posted 15 years ago by Kris Goossens - Remmicom
Avatar
Yes it is.

When debugging the test Application.Current is nothing.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok good, then the next maintenance release should have this resolved for you.


Actipro Software Support

Posted 15 years ago by Kris Goossens - Remmicom
Avatar
Just tested against release 4.5.0482 and the MsTest runs fine now.
The theme is not applied, but at least the test doesn't fail. So this is ok for us.
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.