none
为什么无法用 VS2012 创建.NET4.5 程序? RRS feed

  • 问题

  • 我在Windows 8 x86 pro下,无法用VS2012 创建新的.NET v4.5 的任何类型程序。

    当点击创建新项目(.NET 4.5)时,弹出的错误提示框写的是

    未能加载项目文件。给定编码中的字符无效。第 1 行,位置 1。

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WorkflowBuildExtensions.targets

    请问如何解决,谢谢。

    2012年12月9日 5:10

答案

  • 我已经成功解决这个问题,获取文件C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WorkflowBuildExtensions.targets的权限后,删除它即可,谢谢

    • 已标记为答案 gaxjyxq 2012年12月11日 12:02
    2012年12月11日 12:02

全部回复

  • 尝试用记事本打开你的那个文件,然后用我的正常内容覆盖,重启VS看看:

    <!--
    ***********************************************************************************************
    Microsoft.WorkflowBuildExtensions.targets

    WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
              created a backup copy.  Incorrect changes to this file will make it
              impossible to load or build your projects from the command-line or the IDE.

    Copyright (C) Microsoft Corporation. All rights reserved.
    ***********************************************************************************************
    -->

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

      <PropertyGroup>
        <PrepareResourcesDependsOn>
          ValidationExtension;
          ExpressionBuildExtension;
          $(PrepareResourcesDependsOn)
        </PrepareResourcesDependsOn>
      </PropertyGroup>

      <PropertyGroup>
        <CoreCompileDependsOn Condition="'$(BuildingInsideVisualStudio)' == 'true'">
            GenerateCompiledExpressionsTempFile;
            $(CoreCompileDependsOn)
        </CoreCompileDependsOn>  
      </PropertyGroup>
      
      <PropertyGroup>
        <WorkflowBuildExtensionVersion Condition="'$(WorkflowBuildExtensionVersion)'==''">4.0.0.0</WorkflowBuildExtensionVersion>
        <WorkflowBuildExtensionKeyToken Condition="'$(WorkflowBuildExtensionKeyToken)'==''">31bf3856ad364e35</WorkflowBuildExtensionKeyToken>
        <WorkflowBuildExtensionAssemblyName Condition="'$(WorkflowBuildExtensionAssemblyName)'==''">Microsoft.Activities.Build, Version=$(WorkflowBuildExtensionVersion), Culture=neutral, PublicKeyToken=$(WorkflowBuildExtensionKeyToken)</WorkflowBuildExtensionAssemblyName>

        <GenerateCompiledExpressionsTempFilePathForEditing Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntermediateOutputPath)\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs</GenerateCompiledExpressionsTempFilePathForEditing>
        <GenerateCompiledExpressionsTempFilePathForValidation Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntermediateOutputPath)\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs</GenerateCompiledExpressionsTempFilePathForValidation>
        <GenerateCompiledExpressionsTempFilePathForTypeInfer Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntermediateOutputPath)\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs</GenerateCompiledExpressionsTempFilePathForTypeInfer>

        <DeferredValidationErrorsFileName>$(IntermediateOutputPath)\AC2C1ABA-CCF6-44D4-8127-588FD4D0A860-DeferredValidationErrors.xml</DeferredValidationErrorsFileName>
      </PropertyGroup>

      <UsingTask TaskName="WorkflowBuildMessageTask" AssemblyName="$(WorkflowBuildExtensionAssemblyName)" />
      <UsingTask TaskName="ReportDeferredValidationErrorsTask" AssemblyName="$(WorkflowBuildExtensionAssemblyName)" />
      <UsingTask TaskName="DeferredValidationTask" AssemblyName="$(WorkflowBuildExtensionAssemblyName)" />
     
      <ItemGroup>
        <XamlBuildTaskTypeGenerationExtensionName Include="Microsoft.Activities.Build.BeforeInitializeComponentExtension">
          <AssemblyName>$(WorkflowBuildExtensionAssemblyName)</AssemblyName>
          <Visible>false</Visible>
        </XamlBuildTaskTypeGenerationExtensionName>
        <XamlBuildTaskTypeGenerationExtensionName Include="Microsoft.Activities.Build.Debugger.DebugBuildExtension">
          <AssemblyName>$(WorkflowBuildExtensionAssemblyName)</AssemblyName>
          <Visible>false</Visible>
        </XamlBuildTaskTypeGenerationExtensionName>
      </ItemGroup>
     
      <Target Name ="ExpressionBuildExtension" >
        <WorkflowBuildMessageTask ResourceName="InvalidValueForDisableWorkflowCompiledExpressions" MessageType="Warning"
               Condition = "'$(DisableWorkflowCompiledExpressions)'!='' and '$(DisableWorkflowCompiledExpressions)'!='true' and '$(DisableWorkflowCompiledExpressions)'!='false'"  >
        </WorkflowBuildMessageTask>
        <ItemGroup>
          <XamlBuildTaskTypeInspectionExtensionName Include= "Microsoft.Activities.Build.Expressions.ExpressionsBuildExtension" Condition="$(DisableWorkflowCompiledExpressions)!=true" >
            <AssemblyName>Microsoft.Activities.Build</AssemblyName>
            <Visible>false</Visible>
          </XamlBuildTaskTypeInspectionExtensionName>
        </ItemGroup>
      </Target>

      <!-- XBT Validation Extension-->
      <Target Name ="ValidationExtension" >
        <WorkflowBuildMessageTask ResourceName="InvalidValueForSkipWorkflowValidation" MessageType="Warning"
               Condition = "'$(SkipWorkflowValidation)'!='' and '$(SkipWorkflowValidation)'!='true' and '$(SkipWorkflowValidation)'!='false'"  >
        </WorkflowBuildMessageTask>
        <ItemGroup>
          <XamlBuildTaskTypeInspectionExtensionName Include= "Microsoft.Activities.Build.Validation.ValidationBuildExtension" Condition="$(SkipWorkflowValidation)!=true" >
            <AssemblyName>Microsoft.Activities.Build</AssemblyName>
            <Visible>false</Visible>
          </XamlBuildTaskTypeInspectionExtensionName>
        </ItemGroup> 
      </Target>

      <Target Name ="GenerateCompiledExpressionsTempFile"
              Condition = "'$(GenerateCompiledExpressionsTempFilePathForEditing)' != ''"> 
        <WriteLinesToFile
          File="$(GenerateCompiledExpressionsTempFilePathForEditing)" Condition = "!Exists('$(GenerateCompiledExpressionsTempFilePathForEditing)')" />
        <WriteLinesToFile
          File="$(GenerateCompiledExpressionsTempFilePathForValidation)" Condition = "!Exists('$(GenerateCompiledExpressionsTempFilePathForValidation)')" />
        <WriteLinesToFile
          File="$(GenerateCompiledExpressionsTempFilePathForTypeInfer)" Condition = "!Exists('$(GenerateCompiledExpressionsTempFilePathForTypeInfer)')" />
        <ItemGroup>
          <Compile Include="$(GenerateCompiledExpressionsTempFilePathForEditing)" />
          <Compile Include="$(GenerateCompiledExpressionsTempFilePathForValidation)" />
          <Compile Include="$(GenerateCompiledExpressionsTempFilePathForTypeInfer)" />
        </ItemGroup> 
      </Target>

      <Target Name="AddDeferredValidationErrorsFileToFileWrites" AfterTargets="XamlMarkupCompilePass2" Condition="Exists('$(DeferredValidationErrorsFileName)')" >
        <ItemGroup>
          <FileWrites Include="$(DeferredValidationErrorsFileName)" />
        </ItemGroup>
      </Target>

      <!--
      ================================================================
                     ReportValidationBuildExtensionErrors
            Report deferred validation extension errors.
      ================================================================
      -->
      <Target Name="ReportValidationBuildExtensionErrors" AfterTargets="XamlMarkupCompilePass2" Condition="'$(SkipWorkflowValidation)' != 'true' and ('@(XamlPage)' != '' or '@(XamlAppDef)' != '')">   
        <ReportDeferredValidationErrorsTask DeferredValidationErrorsFilePath="$(DeferredValidationErrorsFileName)">
        </ReportDeferredValidationErrorsTask>
      </Target>

      <!--
      ==================================================================
                     DeferredValidation
            Fail the entire build process in case any validation errors
            been previously reported, but after Compile succeeded.
      ==================================================================
      -->
      <Target Name="DeferredValidation" AfterTargets="Compile" Condition="'$(SkipWorkflowValidation)' != 'true' and ('@(XamlPage)' != '' or '@(XamlAppDef)' != '')">
        <DeferredValidationTask DeferredValidationErrorsFilePath="$(DeferredValidationErrorsFileName)">
        </DeferredValidationTask>
      </Target>
     
    </Project>


    我的博客园
    慈善点击,点击此处
    和谐拯救危机,全集下载,净化人心

    2012年12月11日 7:49
  • 谢谢,不过当我用记事本打开C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WorkflowBuildExtensions.targets

    时,我发现这是个二进制文件,并且这个文件是受权限保护的,你说的是这个文件吗?需要改权限后用你的内容覆盖吗?

    2012年12月11日 11:32
  • 我已经成功解决这个问题,获取文件C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WorkflowBuildExtensions.targets的权限后,删除它即可,谢谢

    • 已标记为答案 gaxjyxq 2012年12月11日 12:02
    2012年12月11日 12:02