If you have a library (dll) that is shared between WPF and Windows Forms, you can use the Is there any way to determine if the EXE that called the library is WPF, form, or console?
[Development Environment]
C#6.0
.NET 4.5.1
VS2015 Preview
If AppDomain
has PresentationFramework.dll
loaded and System.Windows.Application.Current
is not null, you can consider it a WPF app. This is valid if you are using ElementHost
on the form but you do not explicitly create Application
.
I think it is necessary to clarify the purpose a little more.You may just be loading the assembly *, or if you are called from a thread pool, there may be no trace of the stack frame.WPF can host WinForms and vice versa.Also, there are some like ILDASM.EXE that dare launch as a console application before opening the form.
Application.StartupPath…
© 2024 OneMinuteCode. All rights reserved.