microsoft / appcenter-sdk-dotnet

Development repository for the App Center SDK for .NET platforms, including Xamarin
Other
309 stars 141 forks source link

FileNotFoundException and DllNotFoundException in AppCenter code with self-contained WPF app #1390

Closed jnm2 closed 4 years ago

jnm2 commented 4 years ago

I'm not sure how I would begin to repro this. FileNotFoundException and DllNotFoundException showed up with no exception message and only Microsoft code on the call stack:

System.DllNotFoundException: Dll was not found.
  at __std_type_info_destroy_list(__type_info_node* )
  at __scrt_uninitialize_type_info()
  at _app_exit_callback()
  at <CrtImplementationDetails>.LanguageSupport.DomainUnload(Object A_0, EventArgs A_1)
  at <CrtImplementationDetails>.ModuleUninitializer.SingletonDomainUnload(Object source, EventArgs arguments)
  at System.AppContext.OnProcessExit()
System.IO.FileNotFoundException: 
  at System.Windows.Forms.Screen.get_AllScreens()
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.WindowIntersectsWithAnyScreen(Object window)
  at CallSite.Target(Closure , CallSite , Type , Object )
  at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.IsAnyWindowNotMinimized()
  at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.WinEventHook(IntPtr winEventHookHandle, UInt32 eventType, IntPtr windowHandle, Int32 objectId, Int32 childId, UInt32 eventThreadId, UInt32 eventTimeInMilliseconds)

Details

.NET Core 3.1 WPF with PublishSingleFile and PublishTrimmed. Csproj contents:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <ApplicationManifest>App.manifest</ApplicationManifest>
    <UseWPF>true</UseWPF>
    <LangVersion>latest</LangVersion>
    <Nullable>enable</Nullable>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <PublishSingleFile>true</PublishSingleFile>
    <PublishTrimmed>true</PublishTrimmed>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AmbientTasks" Version="1.0.0" />
    <PackageReference Include="Humanizer.Core" Version="2.7.9" />
    <PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.0.0" />
    <PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.0.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="all" />
    <PackageReference Include="PropertyChangedAnalyzers" Version="3.2.0" PrivateAssets="all" />
  </ItemGroup>

  <ItemGroup>
    <None Update="Settings.settings" Generator="SettingsSingleFileGenerator" LastGenOutput="Settings.Designer.cs" />
    <Compile Update="Settings.Designer.cs" DesignTimeSharedInput="True" AutoGen="True" DependentUpon="Settings.settings" />
  </ItemGroup>

</Project>
vvechkanov commented 4 years ago

Hey, @jnm2, thanks for getting in touch. I am trying to reproduce this issue. Could you please share when this Exception appears. I mean how do you use SDK in the moment crash appears. For now, I tried to create a simple WPF application with the same dependencies and settings and it launches correctly.

Also, could you please enable verbose logs, to get more details of the exception reason. For that please add line AppCenter.LogLevel = LogLevel.Verbose before AppCenter.Start.

MatkovIvan commented 4 years ago

Hi, we haven't heard from you in a while so I'm closing this issue. Please reopen/comment if you have more questions or run into this again.

jnm2 commented 4 years ago

Sorry about that. I haven't been able to reproduce the crash.

aesim-tech commented 3 years ago

Hi, Not sure if it helps but I just experienced the same crash with my program. I am using Dotnet 5.0 WPF with PublishSingleFile and PublishTrimmed.

Crash log:

Package: UPSIM.UI.WPF
Version: 2020.12.8.0
OS: WINDOWS
Windows: 10.0.19042
Date: 2020-12-15T18:42:33.0872867Z

Exception Stack:
System.DllNotFoundException: Dll was not found.
  at __std_type_info_destroy_list(__type_info_node* )
  at __scrt_uninitialize_type_info()
  at _app_exit_callback()
  at <CrtImplementationDetails>.LanguageSupport.DomainUnload(Object A_0, EventArgs A_1)
  at <CrtImplementationDetails>.ModuleUninitializer.SingletonDomainUnload(Object source, EventArgs arguments)
  at System.AppContext.OnProcessExit() 

I am not able to reproduce this issue either.

AnastasiaKubova commented 3 years ago

Hi! Could you please share additional information about this issue? Could you please enable verbose logs and share reproducing steps? Unfortunately, we can't reproduce this issue on our side and any other additional information will be helpful to investigate this.

aesim-tech commented 3 years ago

Hi Anastasia, Sorry but this issue happened on a client computer and I am not able to reproduce it locally. I just copied the crash log in case it would help. It is not critical at all.

What is weird is the crash happened 25 hours after the user closed the program... 🤨 image