.net core PublishSingleFile设置为True时服务结构可靠服务中未处理的异常

.net core PublishSingleFile设置为True时服务结构可靠服务中未处理的异常,.net-core,azure-service-fabric,.net Core,Azure Service Fabric,这是一个让我困惑的奇怪的问题。我有一个.NET核心应用程序作为可靠的服务部署到服务结构集群。这非常有效,直到我将最后两行添加到CSPROJ文件: <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>win-x64</RuntimeIdentifier>

这是一个让我困惑的奇怪的问题。我有一个.NET核心应用程序作为可靠的服务部署到服务结构集群。这非常有效,直到我将最后两行添加到CSPROJ文件:

    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PublishSingleFile>true</PublishSingleFile>  <-- New
    <PublishTrimmed>true</PublishTrimmed>  <-- New
我将我的更改恢复到CSPROJ文件并再次发布,现在它再次运行良好

我的问题:当我使用
PublishSingleFile
时,为什么我可以从命令行正常运行我的程序,而Service Fabric在同一个VM上运行同一个应用程序时会引发异常?

删除
true
。这仍然是实验性的,可能会从独立包中删除一些有效的依赖项。当您通过登录节点来运行时,它工作的原因是,它在SF运行时之外,并且可能能够从全局计算。 仅保持
为真


如果仍然不起作用,请尝试在主主机中添加netstandard的nuget包引用。csproj

酷!明天我会好好玩玩,看看能想出什么主意。谢谢我们已经确认这解决了问题。非常感谢!!
Application: DeviceSync.exe
CoreCLR Version: 4.700.20.26901
.NET Core Version: 3.1.6
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
   at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
   at System.StartupHookProvider.ProcessStartupHooks()