I'm facing an issue with Workflow Foundation's designer and SDK-style csproj in Visual Studio 2022 17.9.2.
Assume we have 3 .net 4.8 working projects
- ActivityLibrary2: contains Activity2.xaml with a WriteLine Activity
- ActivityLibrary1 (referencing ActivityLibrary2 and Newtonsoft.Json): contains Activity1.xaml with a WriteLine Activity
- ConsoleApp1 (referencing ActivityLibrary1): contains Program.cs
Both designer and runtime WorkflowApplication works, nothing special.
Now we to port to SDK-style both ActivityLibrary projects (I tried manually and with upgrade assistant with similar results)
(ActivityLibrary1.csproj and ActivityLibrary2.csproj differs only on references and Activity1/Activity2)
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<LanguageTargets Condition="Exists('$(MSBuildProjectDirectory)\$(AssemblyName).csproj')">$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ActivityLibrary2\ActivityLibrary2.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Activities" />
<Reference Include="System.Xaml" />
</ItemGroup>
<ItemGroup>
<XamlAppdef Include="Activity1.xaml">
<Generator>MSBuild:Compile</Generator>
</XamlAppdef>
</ItemGroup>
</Project>
Then rebuild the solution and open Activity1.xaml.
<Activity mc:Ignorable="sap sap2010 sads" x:Class="ActivityLibrary1.Activity1"
sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#"
sap2010:WorkflowViewState.IdRef="ActivityLibrary1.Activity1_1"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Text</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System.ServiceModel</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>ActivityLibrary1</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_1" sads:DebugSymbol.Symbol="d01DOlxVc2Vyc1xtYXR0ZW9cc291cmNlXHJlcG9zXEFjdGl2aXR5TGlicmFyeTFcQWN0aXZpdHlMaWJyYXJ5MVxBY3Rpdml0eTEueGFtbAEfAx9xAgEB" />
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="WriteLine_1" sap:VirtualizedContainerService.HintSize="210,62" />
<sap2010:ViewStateData Id="ActivityLibrary1.Activity1_1" sap:VirtualizedContainerService.HintSize="250,142" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>
The designer opens, but the problems are:
- the tab "namespace imports" doesn't list anything in the search textbox but System.* namespace (not even ActivityLibrary1/ActivityLibrary2 namespace)
- any expression written in WriteLine C# expression doesn't remain: anytime you hit "Tab" or "click outside" the expression textbox, the expression you wrote disappears.
Any help will be greatly appreciated, thanks.
Notes:
- the point 2 doesn't happen if you don't have any ProjectReference (e.g. if you remove the ActivityLibrary2 dependency from ActivityLibrary1)
- (it seems) randomly after some designer item's add/remove, the xaml assemblyreferences pass from simple name to fully qualified name, e.g.
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
becomes
<AssemblyReference>System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyReference>
<AssemblyReference>System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyReference>
this never happened with non SDK-style csproj
- Some standard namespace cannot be resolved in the "imports" tab: System.Data and System.Linq "cannot be resolved". Probably it's only a coincidence, but the only .net framework that doesn't have System.Data and System.Linq is .net standard...is the designer loading .net standard instead .net framework?
- if I create an ActivityLibrary3 project in non SDK-style and then simply "link" the ActivityLibrary1's Activity1.xaml file in ActivityLibrary3 and open the designer, there are no more namespace problems (System.Data and System.Linq are found and the textbox expressions work again)
- if I manually edit the xaml code and add the body oth the WriteLine Activity, e.g.
<WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_1">
<InArgument x:TypeArguments="x:String">
<mca:CSharpValue x:TypeArguments="x:String">typeof(ActivityLibrary1.Activity1).FullName</mca:CSharpValue>
</InArgument>
<sads:DebugSymbol.Symbol>d01DOlxVc2Vyc1xtYXR0ZW9cc291cmNlXHJlcG9zXEFjdGl2aXR5TGlicmFyeTFcQWN0aXZpdHlMaWJyYXJ5MVxBY3Rpdml0eTEueGFtbAImAysPAgEBKAcocAIBAg==</sads:DebugSymbol.Symbol>
</WriteLine>
the workflow opens and the expression still exists, but if I change it from designer it reverts to the value I set during manual xaml update.
- everytime workflow designer opens, VS create a new appdomain. If the designer is opened inside a old-style csproj the probing path is
C:\Solution\ActivityLibrary1\obj\Debug
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8
C:\Solution\ActivityLibrary2\bin\Debug\
C:\Solution\ActivityLibrary1\bin\Debug\
whilst if opened inside a sdk-style csproj
C:\Solution\ActivityLibrary1\obj\Debug\net48
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8
C:\Solution\ActivityLibrary2\bin\Debug\net48
file:\C:\Windows\Microsoft.NET\Framework64\v4.0.30319
so it seems is missing the C:\Solution\ActivityLibrary1\bin\Debug\
and adding the file:\C:\Windows\Microsoft.NET\Framework64\v4.0.30319
path: I tried to manually copy ActivityLibrary2 and Newtonsoft.Json dlls into but nothing changed.
- fusion log viewer doesn't log any failed binding while opening the designer
- tried to see output log attaching a empty VS instance to my VS Workflow project while opening the workflow designer, but no errors or warning comes out in output window
I reproduced: any expression written in WriteLine C# expression doesn't remain
Please report the problem on Developer community and post the link here so that we can follow up.