简体   繁体   English

安装项目后出现C#错误

[英]c# error after install project

I deploy a project using install shield limited edition, if I install it on my PC it works perfectly. 我使用install shield限量版部署了一个项目,如果我将其安装在PC上,则可以完美运行。 If I bring it to another PC (doesn't have SQL sever) whenever I press some button that need to connect to database I got this exception. 如果每当我按下需要连接到数据库的某个按钮时,将其带到另一台PC(没有SQL服务器),就会出现此异常。

在此处输入图片说明

Anyone who can fix this? 谁能解决这个问题?

I had a similar issue with this recently! 我最近也有类似的问题!

My best bet is that you have one or two of these things happening. 我最好的选择是,您正在发生其中一两种情况。 Either you have ports not opened that you need to have opened for your program to communicate with or (the most likely) that the group policy on the machine that you are installing to is blocking the application. 尚未打开的端口需要打开才能与程序进行通信,或者(最有可能)您要安装的计算机上的组策略阻止了该应用程序。 I had this occur primarily with hashing. 我主要在散列中发生这种情况。

This guy is not necessarily an easy fix. 这个家伙不一定是容易解决的。 What I would do is open up Windows Event Viewer and read through the stack trace on the error and see which library threw the exception. 我要做的是打开Windows事件查看器,并仔细阅读有关错误的堆栈跟踪,并查看哪个库引发了异常。 Then I would open up the group policy and see if you can find that name in the policy. 然后,我将打开组策略,看看是否可以在策略中找到该名称。

Another idea is that it could very easily be a permission set that you have on your SQL server not allowing a computer to talk to it, but that is another issue. 另一个想法是,它很容易就是您在SQL服务器上拥有的权限集,不允许计算机与之对话,但这是另一个问题。

If your application uses a local database(in local sql server), you should find a way to attach your database either together with your application or in your MS-SQL Server. 如果您的应用程序使用本地数据库(在本地sql服务器中),则应找到一种将数据库与应用程序或MS-SQL Server附加在一起的方法。 B/C in your attached picture it is saying: "The server was not found.." So if you have a simple button like this, you should be able to reach your server by your connection string. B / C在所附的图片中说:“找不到服务器。。”因此,如果您有一个像这样的简单按钮,则应该可以通过连接字符串访问服务器。

 private void button1_Click(object sender, EventArgs e)
    {
        string connetionString = null;
        SqlConnection cnn ;
        connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
        cnn = new SqlConnection(connetionString);
        try
        {
            cnn.Open();
            MessageBox.Show ("Connection Open ! ");
            cnn.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show("Can not open connection ! ");
        }
    }

Note: if you are using locally attached database, it is a must that you should install MS-SQL Server in your new deploying PC. 注意:如果使用的是本地连接的数据库,则必须在新的部署PC中安装MS-SQL Server。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM