XAML Workflow Activity designer 100% throws OutOfMemoryException and crashes when some specific NuGet packages are referred through PackageReference (NOT with packages.config) using the "old" project file format (<Project ToolsVersion="15.0" ...> and NOT <Project Sdk="Microsoft.NET.Sdk">).
I think this is caused by some assembly reference resolution error in the new PackageReference related code and related to #1244, #1499
Steps to reproduce:
Instead of opening the designer, VS says:
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at VSLangProj.Reference.get_PublicKeyToken()
at Microsoft.VisualStudio.Activities.Helper.CreateAssemblyNameFromReference(Reference r)
at Microsoft.VisualStudio.Activities.Helper.GetReferenceAssemblies(VSProject project)
at Microsoft.VisualStudio.Activities.EditorPane.get_ReferencedAssemblies()
at Microsoft.VisualStudio.Activities.EditorPane.ResetShadowCopyPath()
at Microsoft.VisualStudio.Activities.EditorPane.CreateWorkflowDesignerInIsolatedMode()
at Microsoft.VisualStudio.Activities.EditorPane.Microsoft.VisualStudio.Shell.Interop.IPersistFileFormat.Load(String fileName, UInt32 formatMode, Int32 readOnly)
Some of the above packages (Microsoft.Orleans.Core, Orleans.Activities, Abp) also causes the "The referenced component 'System.Net.Http' could not be found." warning, so after adding the below code to the end of the project files, the warning disappears, but the XAML designer still crashes:
<Target Name="UpdateOriginalItemSpecs" AfterTargets="ResolveAssemblyReferences">
<ItemGroup>
<ReferencePath>
<OriginalItemSpec>%(ReferencePath.FileName)</OriginalItemSpec>
</ReferencePath>
</ItemGroup>
</Target>
But 2 warnings remain even after adding the above target to the project file (I think the XAML designer uses some different target for assembly resolution):
Note: referring Microsoft.Orleans.Core.Abstractions or Dapper doesn't cause any warning, the designer simply crashes. Adding the above target workaround, doesn't change anything.
I've tried to investigate:
This error also reported multiple times at several places:
Using the new project file format (<Project Sdk="Microsoft.NET.Sdk">) is not an option, because it doesn't contain the XamlAppDef BuildAction and though the XAML designer starts without crash, it doesn't resolve any assembly, so useless. Using packages.config as workaround is awfully slow and painful.
Maybe @dmetzgar can add some insights about the internals of the XAML Workflow Activity designer.
On it...
@lmagyar I tracked down the source of this bug in our internal code and assigned it a team that should be able to help out. Your bug report is outstanding, and I'm sorry to see that it took so long to get eyes on it. I'm going to start a separate internal discussion related to avoiding the type of delay that occurred in reviewing your feedback items.
/cc @Pilchie
Note that @tmeschter is already looking at this.
Closing the issue here as it is already being tracked somewhere else and worked on.
Most helpful comment
@lmagyar I tracked down the source of this bug in our internal code and assigned it a team that should be able to help out. Your bug report is outstanding, and I'm sorry to see that it took so long to get eyes on it. I'm going to start a separate internal discussion related to avoiding the type of delay that occurred in reviewing your feedback items.
/cc @Pilchie