gpt4 book ai didi

visual-studio-2010 - 为什么解决方案中的 Azure Add > Worker 角色项目在 VS2010 中呈灰色?

转载 作者:行者123 更新时间:2023-12-03 13:52:46 25 4
gpt4 key购买 nike

我有一个 C# .Net 4 类库,我认为我已将其设置为 Azure 辅助角色,即该类实现 Microsoft.WindowsAzure.ServiceRuntime.RoleEntryPoint 并具有 Run() 和 OnStart() 方法。但是,当我右键单击空 Windows Azure 项目中的“角色”文件夹并单击“添加”时,用于添加“解决方案中的辅助角色项目...”的选项显示为灰色。我需要对 VS2010 做什么才能意识到解决方案中存在潜在的 worker 角色项目?

enter image description here

最佳答案

解决方案中的添加 > 辅助角色项目...”仅显示辅助角色项目,而不显示类库。尽管它们看起来相同,但实际上并非如此。

您可以使用以下命令创建辅助角色项目:

  • 创建新的云项目时

enter image description here

  • 右键单击云项目

enter image description here

然后,您可以根据需要将该辅助角色项目添加到其他云项目中。在这种情况下,将启用“解决方案中的添加>辅助角色项目...”菜单选项。

现在,您还可以将类库“转换”为辅助角色项目。右键单击类库并选择卸载项目..然后(卸载后),编辑项目文件并在第一个中添加RoleType元素属性组:

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7E9F972F-BE92-4CF7-998D-E76B61B21C37}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClassLibrary1</RootNamespace>
<AssemblyName>ClassLibrary1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<RoleType>Worker</RoleType> <-------------------- HERE
</PropertyGroup>

最后 - 将项目重新加载回解决方案 -> 右键单击​​重新加载项目。 (注意:如果 Xml 文件仍然打开,系统会要求您关闭它......这是完美的。说"is"并关闭它)。 .. 现在您的类库已重新添加回来,但它是工作角色类库

如果您执行此操作,Visual Studio 会将该项目识别为辅助角色,您将能够将其添加到云项目中:

enter image description here

注意:您的类库需要一个从RoleEntryPoint派生的类。更多信息:http://blogs.msdn.com/b/jnak/archive/2010/02/11/windows-azure-roleentrypoint-method-call-order.aspx

关于visual-studio-2010 - 为什么解决方案中的 Azure Add > Worker 角色项目在 VS2010 中呈灰色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10829923/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com