Visual studio 在工作流设计器中从VB切换到C#
我正在VisualStudio11Beta中创建一个活动库(尽管我在VS2010中重复了所有步骤,结果都是一样的),目标是.NET4.0框架 当我开始通过工作流设计器输入参数时,我注意到默认值框中的“输入VB表达式”消息。我不知道如何将语言上下文从VB更改为C 要创建项目,我遵循以下步骤:Visual studio 在工作流设计器中从VB切换到C#,visual-studio,xaml,workflow-foundation-4,workflow-activity,Visual Studio,Xaml,Workflow Foundation 4,Workflow Activity,我正在VisualStudio11Beta中创建一个活动库(尽管我在VS2010中重复了所有步骤,结果都是一样的),目标是.NET4.0框架 当我开始通过工作流设计器输入参数时,我注意到默认值框中的“输入VB表达式”消息。我不知道如何将语言上下文从VB更改为C 要创建项目,我遵循以下步骤: 转到文件新建并选择项目… 在“新建项目”对话框窗口的“已安装的模板”部分,选择Visual C#工作流活动库 像往常一样命名项目,然后单击确定 基本上就是这样。然后我注意到默认的Activity1.xaml文
Activity1.xaml
文件在默认值字段中需要VB。我将其删除,然后按照以下步骤创建新活动:
Microsoft.VisualBasic.Activities
名称空间和VisualBasic.Settings
元素,但我不确定如何更改它;每次我尝试,我都会把事情搞砸。下面是生成的XAML代码:
<Activity mc:Ignorable="sads sap" x:Class="THINKImport.CustomerAddOrderAdd"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:local="clr-namespace:THINKImport.THINKWebReference"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
xmlns:s="clr-namespace:System;assembly=System.Core"
xmlns:s1="clr-namespace:System;assembly=System"
xmlns:s2="clr-namespace:System;assembly=System.ServiceModel"
xmlns:s3="clr-namespace:System;assembly=mscorlib"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:t="clr-namespace:THINKImport"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Members>
<x:Property Name="user_login_data" Type="InArgument(local:user_login_data)" />
<!--Removed the other properties for brevity-->
</x:Members>
<sap:VirtualizedContainerService.HintSize>440,440</sap:VirtualizedContainerService.HintSize>
<mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
</Activity>
440,440
用于内部实现的程序集引用和导入的命名空间
我能够找出问题所在
不过,首先,我发现了根本原因。简而言之,它说即使程序是C#,表达式编辑器中也必须使用VB.NET
因此,我对此感到有点失望,但我决定再次尝试XAML代码,因为在完成WF教程的过程中,我在designer中进行的一项活动肯定会接受C#中的表达式。我打开了那个项目,并浏览了XAML代码
就在那时,我注意到了这句话:
<sap2010:ExpressionActivityEditor.ExpressionActivityEditor>C#</sap2010:ExpressionActivityEditor.ExpressionActivityEditor>
C#
我搜索了MSDN库并找到了。据我所知,这是.NET4.5的新功能。在我的特殊情况下,没有任何理由我不能在我的项目中以.NET4.5为目标,所以我改变了它。一旦解决方案重新打开,所有表达式编辑器文本字段和框将立即接受C。为了“重新开始”,我删除了我一直在处理的活动文件,并创建了一个新文件。如果有人感兴趣,下面是生成的XAML代码:
<Activity mc:Ignorable="sap sap2010 sads" x:Class="THINKImport.CustomerAddOrderAdd"
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"
xmlns:THINKWebReference="clr-namespace:THINKImport.THINKWebReference">
<x:Members>
<x:Property Name="user_login_data" Type="InArgument(THINKWebReference:user_login_data)">
<x:Property.Attributes>
<RequiredArgumentAttribute />
</x:Property.Attributes>
</x:Property>
<x:Property Name="customer_data" Type="InArgument(THINKWebReference:customer_data)" />
<!--Remainder of Properties removed for brevity-->
</x:Members>
<sap2010:ExpressionActivityEditor.ExpressionActivityEditor>C#</sap2010:ExpressionActivityEditor.ExpressionActivityEditor>
<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>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<sap2010:WorkflowViewState.IdRef>
THINKImport.CustomerAddOrderAdd_1
</sap2010:WorkflowViewState.IdRef>
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="THINKImport.CustomerAddOrderAdd_1" sap:VirtualizedContainerService.HintSize="440,440" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>
C#
系统
System.Collections.Generic
系统数据
系统Linq
系统文本
mscorlib
系统
系统核心
系统数据
System.ServiceModel
命名空间
THINKImport.CustomerAddOrderAdd_1
所以,有点不同(对我来说,无论如何),但我现在可以用C了,所以我很高兴
C#表达式
以前,工作流中的所有表达式只能用Visual Studio编写
基本的。在.NET Framework 4.5RC中,Visual Basic表达式仅适用于
用于使用Visual Basic创建的项目。Visual C#项目现在开始
对表达式使用C#。一个功能齐全的C#表达式编辑器是
提供了哪些功能,如语法突出显示和
智能感知。C#在以前版本中创建的工作流项目
使用Visual Basic表达式将继续工作
从Beta 1开始,C#表达式在设计时进行验证。错误
C#表达式将用红色波浪下划线标记
更多: