用Visual Studio编写C语言程序时提示无法启动程序是什么原因?

img


用Visual Studio编写C语言程序时提示无法启动程序是什么原因?

  • 这个问题的回答你可以参考下: https://ask.csdn.net/questions/741632
  • 我还给你找了一篇非常好的博客,你可以看看是否有帮助,链接:利用Visual Studio编写一个简易计算机
  • 除此之外, 这篇博客: visual studio自定义必备组件中的 方法 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 1.找到系统中存放这些必备组件的位置,我的是C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages,里面有现在visual studio必备组件对应的文件夹,这个位置跟你安装时候路径选择有关,如果不是这个路径的话可以看一下C:\Program Files (x86)\Microsoft\SDKs\Windows\v7.0A\Bootstrapper\Packages
    或者C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\Bootstrapper\Packages
    或者C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages
    或者C:\Program Files\Microsoft SDKs\Windows\v10.0A\Bootstrapper\Packages

    2.在这个路径下创建一个你要添加的组件对应的文件夹,文件夹的名自定义,可以为你要添加的组件名,如UpdateConsentDialog
    在这里插入图片描述

    3.在创建的组件目录下将你要添加的组件copy如CH341SER.EXE进来

    4.在创建的组件目录下创建一个product.xml文件,里面填入

    <Product
      xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
      ProductCode="Microsoft.Sample.EULA">
      <!-- Defines the list of files to be copied on build. -->
      <PackageFiles CopyAllPackageFiles="false">
        <PackageFile Name="CH341SER.EXE"/>
      </PackageFiles>
    
      <!-- Defines how to run the Setup package.-->
      <Commands >
        <Command PackageFile = "CH341SER.EXE" Arguments=''>
          <ExitCodes>
            <ExitCode Value="0" Result="Success" />
            <ExitCode Value="-1" Result="Fail" String="AU_Unaccepted" />
            <DefaultExitCode Result="Fail"
              FormatMessageFromSystem="true" String="GeneralFailure" />
          </ExitCodes>
        </Command>
      </Commands>
    
    </Product>
    

    注意这里的PackageFile Name与Command PackageFile都要填你之前copy进文件夹的组件,也就是你需要预安装的组件,这里是CH341SER.EXE

    5.在UpdateConsentDialog路径下创建一个文件夹名为en
    在这里插入图片描述

    6.在en文件夹下创建一个eula.rtf文件,里面填入

    
    MICROSOFT SOFTWARE SUPPLEMENTAL LICENSE TERMS
    MICROSOFT .NET FRAMEWORK 4 FOR MICROSOFT WINDOWS OPERATING SYSTEM 
    MICROSOFT .NET FRAMEWORK 4 CLIENT PROFILE FOR MICROSOFT WINDOWS OPERATING SYSTEM 
    AND ASSOCIATED LANGUAGE PACKS
    Microsoft Corporation (or based on where you live, one of its affiliates) licenses this supplement to you.  If you are licensed to use Microsoft Windows operating system software (for which this supplement is applicable) (the “software”), you may use this supplement.  You may not use it if you do not have a license for the software.  You may use a copy of this supplement with each validly licensed copy of the software.
    The following license terms describe additional use terms for this supplement.  These terms and the license terms for the software apply to your use of the supplement.  If there is a conflict, these supplemental license terms apply.
    By using this supplement, you accept these terms.  If you do not accept them, do not use this supplement.
    If you comply with these license terms, you have the rights below.
    1.	SUPPORT SERVICES FOR SUPPLEMENT.  Microsoft provides support services for this software as described at www.support.microsoft.com/common/international.aspx.
    2.	MICROSOFT .NET FRAMEWORK BENCHMARK TESTING. The software includes one or more components of the .NET Framework (.NET Components).  You may conduct internal benchmark testing of those components. You may disclose the results of any benchmark test of those components, provided that you comply with the conditions set forth at http://go.microsoft.com/fwlink/?LinkID=66406.
    Notwithstanding any other agreement you may have with Microsoft, if you disclose such benchmark test results, Microsoft shall have the right to disclose the results of benchmark tests it conducts of your products that compete with the applicable .NET Component, provided it complies with the same conditions set forth at http://go.microsoft.com/fwlink/?LinkID=66406.
    

    7.在en文件夹中创建一个package.xml文件,里面填入

    <Package
      xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
      Name="DisplayName"
      Culture="Culture"
      LicenseAgreement="eula.rtf">
      <PackageFiles>
        <PackageFile Name="eula.rtf"/>
      </PackageFiles>
    
      <!-- Defines a localizable string table for error messages. -->
      <Strings>
        <String Name="DisplayName">Update Consent Dialog</String>
        <String Name="Culture">en</String>
        <String Name="AU_Unaccepted">The automatic update agreement is not accepted.</String>
        <String Name="GeneralFailure">A failure occurred attempting to launch the setup.</String>
      </Strings>
    </Package>
    

    注意这里的DiaplayName后面填的名称就是将会出现在visual studio必备组件列表中的名称,我这里填的是Update Consent Dialog

    8.也可以在UpdateConsentDialog文件夹中添加一些文件夹如de表示德语,fr表示法语,里面的文件基本相同,但是换成对应语法的。当然这些不是一定要的,看个人意愿和需求

    9.这些添加完毕后,重新打开visual studio的必备组件,就能发现多了一个名为Update Consent Dialog的组件
    在这里插入图片描述

  • 您还可以看一下 黄强老师的30分钟快速学习Visual Studio 2019课程中的 代码添加书签、快速查找、定位小节, 巩固相关知识点