You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新旧VB.NET项目时无法找到My Project下的文件怎么办?

解决VB.NET项目缺失"My Project"文件的构建问题

1. 手动重建"My Project"目录及核心文件

由于文件已彻底丢失,直接创建必要的目录和模板文件:

  • 在项目根目录新建名为My Project的文件夹
  • 新建Resources.resx文件,复制以下默认模板内容:
<?xml version="1.0" encoding="utf-8"?>
<root>
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
</root>
  • 同时新建Settings.settings和Application.myapp文件,可从一个正常的VB.NET项目中复制对应模板内容,保证结构一致。

2. 修改项目文件(.vbproj)手动引入缺失项

若解决方案资源管理器仍不显示文件,直接编辑项目文件:

  • 右键项目 → 卸载项目 → 右键编辑.vbproj文件
  • 将以下内容添加到<ItemGroup>节点中:
<EmbeddedResource Include="My Project\Resources.resx">
  <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
  <LastGenOutput>Resources.Designer.vb</LastGenOutput>
  <CustomToolNamespace>My.Resources</CustomToolNamespace>
</EmbeddedResource>
<Compile Include="My Project\Resources.Designer.vb">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="My Project\Settings.settings">
  <Generator>SettingsSingleFileGenerator</Generator>
  <LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<Compile Include="My Project\Settings.Designer.vb">
  <AutoGen>True</AutoGen>
  <DependentUpon>Settings.settings</DependentUpon>
  <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="My Project\Application.myapp">
  <Generator>MyApplicationCodeGenerator</Generator>
  <LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<Compile Include="My Project\Application.Designer.vb">
  <AutoGen>True</AutoGen>
  <DependentUpon>Application.myapp</DependentUpon>
</Compile>
  • 保存后重新加载项目,Visual Studio会自动生成对应的Designer文件。

3. 修复框架适配的兼容性问题

针对重构到官方支持框架的需求,检查项目配置:

  • 在.vbproj中找到<TargetFrameworkVersion>节点,修改为目标版本(如v4.8或.NET 6)
  • 移除项目中过时的引用、编译选项或旧框架专属配置。

4. 重置解决方案缓存

若上述操作后仍有问题,清理VS缓存:

  • 关闭Visual Studio,删除项目目录下的.vs文件夹、bin和obj目录
  • 重新打开解决方案,尝试构建。

内容的提问来源于stack exchange,提问作者HarrisonO

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 00:52:27