gpt4 book ai didi

.net - 在客户端为 ClickOnce 应用程序选择目标框架

转载 作者:可可西里 更新时间:2023-11-01 11:47:21 27 4
gpt4 key购买 nike

我们使用的是 ClickOnce 部署的 WPF 应用程序,旨在在 .Net Framework v3.5 上运行。该应用程序不适用于 Windows 8 或 10,并且如果安装了较新版本的 .Net Framework,则无法运行。

我们收到错误消息:

This method explicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the NetFx40_LegacySecurityPolicy configuration switch. Please see http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

我无权访问源代码或编辑 Web 服务器上的 ClickOnce 文件。我需要一种解决方案,无需更改 Web 服务器或代码即可使应用程序在我们公司的计算机上运行。

最佳答案

link in the error message给你答案:

Compatibility: Using the CAS Policy Legacy Option

The configuration element lets you specify that a process or library uses legacy CAS policy. When you enable this element, the policy and evidence overloads will work as they did in previous versions of the framework.

<configuration>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
</configuration>

因此,要重新启用已弃用的代码,请添加 <NetFx40_LegacySecurityPolicy enabled="true"/>元素到 YourApp.exe.config .

如果您使用的是 ClickOnce,则可以 add the setting to machine.config 反而。编辑 machine.config不推荐,因为它们可能会产生系统范围的运行时或安全后果,如果有其他选项可用,则不应尝试,并且永远不要未经测试。

或者,如果您想在 .Net 3.5(内部版本 v2.0.50727 的 CLR 和一些额外的库)下运行整个应用程序,您可以改为指定 <supportedRuntime> 以同样的方式。这不是通过 ClickOnce 部署的应用程序的选项。

<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>

关于.net - 在客户端为 ClickOnce 应用程序选择目标框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41812984/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com