.net 无法安装或运行应用程序:单击一次
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11505535/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to install or run the application: Click Once
提问by David Shochet
I published my .net application using ClickOnce, and all my users get the following error message on trying to open the program:
我使用 ClickOnce 发布了我的 .net 应用程序,并且我的所有用户在尝试打开该程序时都会收到以下错误消息:
"Unable to install or run the application. The application requires that assembly Telerik.Windows.Data Version 2012.1.215.40 be installed in the Global Assembly Cache (GAC) first".
“无法安装或运行该应用程序。该应用程序要求首先在全局程序集缓存 (GAC) 中安装程序集 Telerik.Windows.Data 版本 2012.1.215.40”。
The version I actually use in my application is NEWER than the one mentioned in the error message. I also don't have this problem on my machine which I use to develop the application. I wonder why it is looking for the older version of the dll. I can't find where it is referenced by my application.
我在应用程序中实际使用的版本比错误消息中提到的版本新。我用来开发应用程序的机器上也没有这个问题。我想知道它为什么要寻找旧版本的 dll。我找不到我的应用程序引用它的位置。
Could you please help me on this?
你能帮我解决这个问题吗?
回答by David Shochet
I found solution here:
我在这里找到了解决方案:
Excerpt from wordpress link:
摘自 wordpress 链接:
I recevied this error while compiling my first C# production application. I had to do the following in Visual Studio for the project:
- In Solution Explorer, expand the References node and click the assembly listed in the error. Ensure Copy Local in the Properties grid is set to ‘True'.
- In the properties of the project, Publish | Application Files Tab, ensure the Publish Status for the assembly listed in the error is set to ‘Include'
我在编译我的第一个 C# 生产应用程序时收到此错误。我必须在 Visual Studio 中为该项目执行以下操作:
- 在解决方案资源管理器中,展开引用节点并单击错误中列出的程序集。确保“属性”网格中的“复制本地”设置为“真”。
- 在项目的属性中,发布 | 应用程序文件选项卡,确保错误中列出的程序集的发布状态设置为“包括”
回答by Fragment
In my case, the problem caused this error message was of incorrect library publishing configurations.
就我而言,导致此错误消息的问题是库发布配置不正确。
When i set my library property CopyLocal = false, and then in project publish application files set Publish Statusto Include, all works fine after project rebuilding and next publishing.
当我设置我的库属性CopyLocal = false,然后在项目发布应用程序文件中将Publish Status设置为Include 时,在项目重建和下次发布后一切正常。
Thus we tell to ClickOnce compiler, not to publish this library with application by default, and by changing Publish State from Prerequisitesto Includetells ClickOnce, not to search this library in GAC.
因此,我们告诉 ClickOnce 编译器,默认情况下不要将这个库与应用程序一起发布,并通过将 Publish State 从Prerequisites更改为Include告诉 ClickOnce,不要在GAC 中搜索这个库。
回答by Askolein
You should also check that there is no wrong assembly binding redirection in your app.configfile. Look for a node looking like:
您还应该检查文件中是否存在错误的程序集绑定重定向app.config。查找如下所示的节点:
<dependentAssembly>
<assemblyIdentity name="Telerik.Windows.Data" publicKeyToken="--SomePublicToken--" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.2.0" newVersion="3.0.2.0"/>
</dependentAssembly>
and ensure the range oldto newmakes sense, or simple, that this node makes sense at all. My first try would be to simply delete it and check again. It can happen that some NuGet packages mess with the config file in old version and this node is not needed anymore in newer once (and it's not deleted automatically).
保证的范围内old,以new有意义,或简单的,这个节点是有道理的。我的第一次尝试是简单地删除它并再次检查。可能会发生某些 NuGet 包与旧版本中的配置文件混淆的情况,并且在较新版本中不再需要此节点(并且不会自动删除)。
回答by Thiru
if two version of the same dll referred across the dependent projects then that would be one of the root cause of the error.
如果在依赖项目中引用了相同 dll 的两个版本,那么这将是错误的根本原因之一。
It happened to me and complaining about NLog.dll, What I found is that my app referred one version of Nlog.dll and my library projects referred another version of Nlog.dll and manifest listed one version as dependency(install) and another version as dependency(requisite i.e. need to be present in the system even copy to local set to true).
它发生在我身上并抱怨 NLog.dll,我发现我的应用程序引用了 Nlog.dll 的一个版本,我的库项目引用了 Nlog.dll 的另一个版本,清单将一个版本列为依赖项(安装),另一个版本列为依赖(即必须存在于系统中,甚至复制到本地设置为 true)。

