为什么我的网站项目不适应 .NET 3.5?

发布于 2024-07-08 20:16:37 字数 155 浏览 8 评论 0原文

我们已将解决方案从 .NET 2.0 转换为 .NET 3.5。 所有项目都转换得很好,除了网站项目,它仍然不明白我在使用“var”等时的意思。

我查看了 Web 项目的属性页,目标框架设置为“.NET Framework 3.5”。

还有其他想法吗?

We've converted our solution from .NET 2.0 to .NET 3.5. All projects converted just fine except for the Website Project, which still doesn't understand what I mean when using 'var' and the like.

I've looked in the property pages for the web project, and the Target Framework is set to '.NET Framework 3.5'.

Any other ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柒夜笙歌凉 2024-07-15 20:16:37

将以下内容添加到 web.config 中:

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5"/>
        <providerOption name="WarnAsError" value="false"/>
      </compiler>
    </compilers>
  </system.codedom>

Add the following to web.config:

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5"/>
        <providerOption name="WarnAsError" value="false"/>
      </compiler>
    </compilers>
  </system.codedom>
与酒说心事 2024-07-15 20:16:37

默认情况下,3.5 中的新 Web 应用程序具有以下引用:

  • System System.Configuration
  • System.Core
  • System.Data
  • System.Data.DataSetExtensions
  • System.Drawing
  • System.EnterpriseServices
  • System.Web
  • System.WebExtensions
  • System.Web.Mobile
  • System.Web。服务
  • System.Xml
  • System.Xml.Linq

此外,在 web.config 文件中,您将在 web.config 文件顶部附近找到以下程序集信息:

    <assemblies>
      <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    </assemblies>

并且您还将在底部找到运行时程序集绑定文件的内容:

   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>

我敢打赌,没有所有这些引用会导致您的 var 声明出现问题。 验证所有这些内容是否已正确添加/创建。

By default, a new web app in 3.5 has the following References:

  • System System.Configuration
  • System.Core
  • System.Data
  • System.Data.DataSetExtensions
  • System.Drawing
  • System.EnterpriseServices
  • System.Web
  • System.WebExtensions
  • System.Web.Mobile
  • System.Web.Services
  • System.Xml
  • System.Xml.Linq

in addition, in the web.config file, you'll find the following assembly information near the top of your web.config file:

    <assemblies>
      <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    </assemblies>

and you will also find the runtime assembly binding found at the bottom of the file:

   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>

I'm wagering that not having all of these references is causing issues with your var declarations. Verify all of these contents were properly added/created.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文