Closed Jsil8 closed 8 months ago
Hi @Jsil8 ,I was able to reproduce your error, thank you very much for the detailed information. I created a work item about this error on our board.
I encounter the same exception when I want to call AppCenter.Start(...)
in Program.cs and before create App.xaml
class.
This exception occurred in AppCenter 5.0.X, and I did not encounter this issue when using AppCenter 4.5.X with the same code.
I create the WPF Desktop Application but not WinForm.
Exception info
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException HResult=0x80131500 Message=无法对 null 引用执行运行时绑定 Source=<无法计算异常源> StackTrace: <无法计算异常堆栈跟踪>
> My sample code
```c#
internal class Program
{
[STAThread]
internal static void Main()
{
AppCenter.Start(...);
RunApp(...);
}
}
Hi @emako, and thanks for reaching out to us. It would be great if you could clarify the following points regarding your case:
Closing as the fix was released.
Description
When using a WPF component in a WinForms application, AppCenter runs WPF specific code while it shouldn't and crashes.
The problem is in the
WindowsHelper
static constructor. If the "PresentationFramework" assembly is loaded, theIsRunningAsWpf
is set to true and this will result in a Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Cannot perform runtime binding on a null reference'.Repro Steps
Please see this repository to reproduce the problem: https://github.com/Jsil8/appcenter_winforms_bug
Details
AppCenter.LogLevel = LogLevel.Verbose
before your call toAppCenter.Start(...)
and include the logs here: 'WinFormsApp3.exe' (CoreCLR: clrhost): Loaded 'Anonymously Hosted DynamicMethods Assembly'. Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in System.Linq.Expressions.dll An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in System.Linq.Expressions.dll but was not handled in user code Cannot perform runtime binding on a null referenceRelevant exception info: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException HResult=0x80131500 Message=Cannot perform runtime binding on a null reference Source=System.Linq.Expressions StackTrace:
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at Microsoft.AppCenter.Utils.ApplicationLifecycleHelperDesktop..ctor() at Microsoft.AppCenter.ApplicationLifecycleHelper.get_Instance() at Microsoft.AppCenter.AppCenter..ctor() at Microsoft.AppCenter.AppCenter.get_Instance() at Microsoft.AppCenter.AppCenter.PlatformStart(String appSecret, Type[] services) at Microsoft.AppCenter.AppCenter.Start(String appSecret, Type[] services) at WinFormsApp3.Form1.OnShown(EventArgs e) in D:\Temp\WinFormsApp3\WinFormsApp3\Form1.cs:line 18 at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)