VS 2015与DataSouces和Winforms崩溃 [英] VS 2015 crashes with DataSouces and Winforms

查看:75
本文介绍了VS 2015与DataSouces和Winforms崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio(2015年和2013年)工作了大约6个月没有问题,VS每次都会在设计器中向winform添加数据源时崩溃。在LocalDB上有三个不同的数据库。任何时候都没有异常报告
或错误消息。该程序"挂起"大约30秒,停止并重新启动。

After working for about a 6 months with Visual Studio (2015 and 2013) without a problem, VS now crashes every time when adding a datasource to a winform in the designer. This happens with three different databases on LocalDB. There is no exception reported or error message at any time. The program "hangs" for some 30 seconds and the stops and restarts.

使用三个数据库测试,包括Northwind。这三个在SQL Management Studio中运行良好。

Tested with three database, including Northwind. All three work fine in SQL Management Studio.

我的系统配置是:

PC:Intel Core i7 - 16GB - 技嘉科技主板
PC: Intel Core i7 - 16GB - Gigabyte Technology Motherboard

推荐答案

当它尝试初始化连接字符串时由于语法错误而失败,因为我看到连接字符串中有空格姓名我不知道你从哪里得到这个。

It could that when its trying to initialize the connection string its failing due to syntax error in it, because I'm seeing there is a space in the connection string name I don't where did you get this from.

另一件事我不确定为什么在第14步和第15步你手动复制连接字符串,因为EF使用特殊的连接字符串比ADO.net,请看这里:

Another thing I'm not sure why on step 14 and 15 you're copying the connectionstring manually because EF uses a special connection string than ADO.net, see here:

https://msdn.microsoft.com/en-us/data/jj556606.aspx#Section

不要通过复制创建连接字符串,让将DS拖动到表单时,向导会为您创建。 验证您的连接字符串有效:

Don't create the connection string by copying it, let the wizard create it for you when you dragging the DS to your form.To verify that your connection string is valid:


  • 创建一个示例代码,从app.config读取此连接字符串并连接到数据库以查看它是否有效,请参阅下面的示例,注意我保留了名称中的空格字符:
           string connetionString = null;
            SqlConnection cnn ;
			connetionString = System.Configuration.ConfigurationManager.ConnectionStrings[" EntitiesNW"].ConnectionString;

            cnn = new SqlConnection(connetionString);
            try
            {
                cnn.Open();
                MessageBox.Show ("Connection Open ! ");
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }

即使连接字符串,你有时使用& quot,并且在某些地方使用它作为字符',我也看到打开了关闭;

Even the connection string that you've sometime its using the &quot and in places it is using it as char ', also I saw opened and closed ;

根据我在上面链接中发布的示例,它应该类似于:

Based on the example I've posted in the link above it should be similar to:

<connectionStrings> 
  <add name="EntitiesNW"  
        connectionString="metadata=metadata=res://*/ModelWFAT.csdl|res://*/ModelWFAT.ssdl|res://*/ModelWFAT.msl;
                                           provider=System.Data.SqlClient 
                                           provider connection string= 
                                               &quot;data source=(LocalDB)\MSSQLLocalDB; 
                                               attachdbfilename=&quot; E:\Visual Studio 2015DatabasesSQL\NorthWind\NORTHWIND.MDF&quot; 
                                               integrated security=True; 
					       connect timeout=30;
                                               multipleactiveresultsets=True;
					       App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" /> 
</connectionStrings>


这篇关于VS 2015与DataSouces和Winforms崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆