Skip to content

Commit 795c554

Browse files
committed
Try to fix the DesignMode trainwreck
1 parent 58043c2 commit 795c554

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ReactiveUI/RxApp.cs

+14-4
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,28 @@ public static bool InUnitTestRunner()
197197

198198
string[] designEnvironments = new[] {
199199
"BLEND.EXE",
200-
"DEVENV.EXE",
201200
"MONODEVELOP",
202201
"SHARPDEVELOP.EXE",
203202
};
204203

205204
#if SILVERLIGHT
206-
if (Application.Current.RootVisual != null && System.ComponentModel.DesignerProperties.GetIsInDesignMode(Application.Current.RootVisual)) {
205+
var ret = Deployment.Current.Parts.Any(x =>
206+
testAssemblies.Any(name => x.Source.ToUpperInvariant().Contains(name)));
207+
208+
if (ret) {
209+
return ret;
210+
};
211+
212+
try {
213+
if (Application.Current.RootVisual != null && System.ComponentModel.DesignerProperties.GetIsInDesignMode(Application.Current.RootVisual)) {
214+
return false;
215+
}
216+
} catch {
217+
// If we're in some weird state, assume we're not
207218
return false;
208219
}
209220

210-
return Deployment.Current.Parts.Any(x =>
211-
testAssemblies.Any(name => x.Source.ToUpperInvariant().Contains(name)));
221+
return ret;
212222
#else
213223
// Try to detect whether we're in design mode - bonus points,
214224
// without access to any WPF references :-/

0 commit comments

Comments
 (0)