我是ASP.NET的新手,并且正在使用本教程http://www.codeproject.com/Articles/470107/ASP-NET-MVC-Part-Introduction来学习一些基础知识。

我已经使用Visual Studio 2012创建了一个项目。然后,我第一次尝试在调试模式下运行该程序。然后我得到在Winforms中遇到的错误,即Could not load file or assembly 'MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies.

我确保在引用中添加了MySql.Web。

我还将此添加到Web.config

 <system.data>
    <DbProviderFactories>
      <clear />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>


当我是ASP.NET的新手时,我注意到创建项目添加了一个未在Web.config中指定的连接字符串。

  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SoundSource-20140312214649;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SoundSource-20140312214649.mdf" providerName="System.Data.SqlClient" />
  </connectionStrings>


为了在浏览器中正确查看主页,我需要做什么?

最佳答案

我建议安装MySQL Installer,其中包括MySQL Connector for .NETMySQL for Visual Studio。连接器为您提供了与ADO.NET一起使用所需的程序集。借助Visual Studio插件,您可以使用服务器资源管理器连接到MySQL服务器(并轻松获取连接字符串)。它还为您提供了MySQL的实体框架设计器支持。

当您添加对.NET的MySQL连接器的引用时,您需要引用多个程序集。每个组件也有多个版本-您需要引用正确的版本。调查一下,它应该可以帮助您解决问题。

10-06 14:14
查看更多