发布VS2010项目以在其他PC上运行 [英] Publishing a VS2010 Project to run on a different PC

查看:151
本文介绍了发布VS2010项目以在其他PC上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这可能是一个愚蠢的问题,但是我已经在PC上编写了一个程序,并在PC上对其进行了测试,现在我想先在儿子的笔记本电脑上对其进行测试,然后再将其发送给我的人已经写了.

但是,当我在他的PC上安装并运行它时,由于SQL Server错误而失败,并且我认为这是由于该程序中包含一个硬编码的Connection,上面写着"Data Source = MEDESKTOP; Initial Catalog = KAELC; Integrated Security = True" ...他的PC显然不称为MEDESKTOP,我也不知道最终用户的PC将被称为...

OK, this might be a stupid question, but I have written a program on my PC and tested it on my PC & I now want to test it on my son''s laptop before I send it to the person who I have written it for.

However, when I install it & run it on his PC it fails with SQL Server errors, and I guess that this is down to the fact that the program has a hard coded Connection in it that says "Data Source=MEDESKTOP;Initial Catalog=KAELC;Integrated Security=True" ... his PC is obviously not called MEDESKTOP, and I have no idea what the end user''s PC will be called ...

How do I get around this problem ?!?

推荐答案

将连接存储在应用程序的配置文件中,并使用System.Configuration中的ConfigurationManager类读取它>组装. [
Store your connection the application''s configuration file and read it using the ConfigurationManager class in the System.Configuration assembly. This[^] link might be of use to you.


这篇关于发布VS2010项目以在其他PC上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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