ClickOnce应用程序出现问题 [英] Problem with ClickOnce application

查看:138
本文介绍了ClickOnce应用程序出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的问题,这使我发疯了!

发布应用程序后,我根本无法在运行时更改控件的属性.示例:我的窗体上有两个按钮,button1和button2.在button1的OnClick事件中,我有以下代码:

I''m having this strange issue that''s been driving me mad!

I simply cannot change the control''s properties at runtime after I publish my application. Example: I have two buttons on my form, button1 and button2. On button1''s OnClick event, I have the following code:

button2.Visible = false;



但这根本行不通. Button2保持可见.如果我尝试更改按钮的任何属性(例如,启用),也会发生相同的问题.

只有在我发布并安装clickonce应用后,才会发生这种情况.如果我在Visual Studio上运行该应用程序,则一切正常.

有人见过吗?

谢谢.



But this simply does not work. Button2 remains visible. The same problem happens if I try to change any of the button''s properties (Enabled, for instance).

This only happens after I publish and install my clickonce app. If I run the app on Visual Studio, everything works fine.

Has anyone ever seen this before?

Thanks.

推荐答案

确保您的发布正常进行.听起来这是您的问题.如果需要,请尽可能检查其他发生的更改. button1_click中是否还有其他代码在运行?如果是这样,请验证代码是否仍在执行.如果是,则您的发布失败.如果不是,则说明您的处理程序根本无法正确触发,您还有其他问题需要解决.
Ensure that your publish worked properly. It sounds like that is your issue. If you need to, check some other change that happened as well if possible. Is there any other code running in button1_click? If so, validate that the code is still executing. If it is, then your publish failed. If it isn''t, then your handler simply isn''t firing properly and you have other issues to sort out.


在花了几年的时间对这个问题进行故障排除之后,我终于发现它的原因很明显(不是总是这样吗?):对"InitializeComponent"方法有两次调用.我希望这至少可以帮助其他可能犯此愚蠢错误的人.
After losing a few years of life troubleshooting this problem, I finally found it''s ridiculously obvious cause (isn''t it always like that?): there were two calls to the "InitializeComponent" method. I hope this at least helps someone else who might make this stupid mistake.


这篇关于ClickOnce应用程序出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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