VS05自带打包功能(virusplayer )

levenwood 2008-07-16 07:29:52
这两天,照着网上弄了个网站打包的小程序:连接数据库,指定虚拟目录
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
Form1 fr = new Form1();
if (fr.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
XmlDocument xmldocument = new XmlDocument();
xmldocument.Load(Path.Combine(getpath(), "Web.config"));

//'查找到appsettings中的节点

//XmlNode node=new XmlNode();

bool FoundIt = false;
XmlNodeList nodes = xmldocument.SelectSingleNode("/configuration/connectionStrings").ChildNodes;
foreach (XmlNode node in nodes)
{
if (node.Name == "add")
{
if (node.Attributes["name"].Value == "myconnString")
{
//'写入连接字符串
node.Attributes["connectionString"].Value = String.Format("Data Source={0};User ID={1};pwd={2};Initial Catalog={3}",
fr.DbServer, fr.LoginName, fr.Password, fr.Db);
FoundIt = true;
xmldocument.Save(Path.Combine(getpath(), "Web.config"));
}
}
}

if (!FoundIt)
{
throw new ApplicationException("Web.Config 文件没有包含connectionString连接字符串设置");
}
else
{
CreateVirtualDir(fr.SiteName, this.Context.Parameters[""]);
}

}
catch (Exception ex)
{
throw ex;
}
}
else
{
throw new ApplicationException("应用程序数据库安装失败");
}
}

也增加了自定义操作,可安装过程中自己写的窗口并没有弹出来,不知道是什么原因,向大家请教,也希望virusplayer来看看
...全文
180 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
levenwood 2008-07-18
  • 打赏
  • 举报
回复
摆平了~谢谢virus 秋心
levenwood 2008-07-18
  • 打赏
  • 举报
回复
我试试~
virusswb 2008-07-18
  • 打赏
  • 举报
回复
差一点都不行了
分部类啊,可是你没有写的话,就不会执行你的类内容了,肯定是另外有一个地方还有一个分布类,而且是执行那个的东西,你必须加上才可以和那个 合并
levenwood 2008-07-17
  • 打赏
  • 举报
回复
谢谢楼上的链接,可以用处不大
levenwood 2008-07-17
  • 打赏
  • 举报
回复
我没有用websetup
levenwood 2008-07-17
  • 打赏
  • 举报
回复
是的~
宝_爸 2008-07-17
  • 打赏
  • 举报
回复
你用的是VS2005吗?
宝_爸 2008-07-17
  • 打赏
  • 举报
回复
我的web setup project 让你选择要安装的site,并让你自己输入Virtual Directory.
levenwood 2008-07-17
  • 打赏
  • 举报
回复
看不到了,顶顶
宝_爸 2008-07-17
  • 打赏
  • 举报
回复
就差了个partial? my god
virusswb 2008-07-17
  • 打赏
  • 举报
回复
原因不太清楚了
你自己研究一下吧
virusswb 2008-07-17
  • 打赏
  • 举报
回复
解决了

class CNWITInstaller : Installer

改成

public partial class CNWITInstaller : Installer
宝_爸 2008-07-17
  • 打赏
  • 举报
回复
这篇文章是说怎么弹出对话框,设置connectionString
.NET 2.0 C# - Windows Installer and the Connection String
http://wlasson.wordpress.com/tutorialscode/net-20-windows-installer-and-the-connection-string-c/


有个人在vs2003 setup project中弹出FolderBrowserDialog 也有问题,这是他的解决方案。


public override void Install(System.Collections.IDictionary stateSaver)
{
Thread thread = new Thread(new ThreadStart(DoWork));

thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}

private void DoWork()
{
using (System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog())
{
dialog.ShowDialog();
}
}






Basically what we are doing is starting a new thread, setting it to use STA and then displaying the dialog from there. This should get you started, but remember to make your code thread safe.

Note: If you try to show a FolderBrowserDialog on a thread that is not STA in Visual Studio 2005, an exception is now thrown, so it won't display at all.

levenwood 2008-07-17
  • 打赏
  • 举报
回复
加过了,可还是没出来~
virusswb 2008-07-17
  • 打赏
  • 举报
回复
安装部署项目,右键-视图-自定义操作-安装-右键-添加自定义操作-选择你的那个installer类的项目
virusswb 2008-07-17
  • 打赏
  • 举报
回复
在安装部署项目中要添加项目输出,选择这个installer类的项目
levenwood 2008-07-16
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 findcaiyzh 的回复:]
使用web setup project会自动的生成iis虚拟目录和数据库设置page吧 。
[/Quote]自动生成的虚拟目录是固定的。更要求不太符合
pinhailinfeng 2008-07-16
  • 打赏
  • 举报
回复
关注学习吧,没发现什么好的打包工具。
levenwood 2008-07-16
  • 打赏
  • 举报
回复
hy_lihuan 我可以把源码发给你 能帮我看看吗?
加载更多回复(6)

61,826

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧