我开发的ClickOnce应用程序有问题:在Windows 10的某些内部版本中,ClickOnce客户端已下载,由.net框架执行,但未显示任何内容。
[如果我进入任务管理器,选择进程,打开详细信息,然后选中“在Windows 8的兼容模式下运行此程序”复选框,它将正常工作。
由于我不希望每个客户端都执行此操作,因此我正在寻找一种方法来强制ClickOnce客户端在Windows 8启动时以此兼容模式执行。
我检查了很少的文档,并以此更改了应用程序的清单:
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
</application>
我再次测试,但是ClickOnce客户端未以正确的兼容模式启动。
有没有一种方法可以实现我想做的事?
谢谢!
Microsoft团队的某人在social.msdn上非常有效地支持了我,因此我将在此处报告解决方案:
我们需要更改注册表以设置键=值,其中-键是可执行文件的路径-值为“ WIN8RTM”。
在clickonce应用程序中,在我开始任何操作之前,我先调用以下函数:
void ForceWin8RTM() {
try {
RegistryKey^ key = Registry::CurrentUser->OpenSubKey("SoftWare\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", true);//Open the registry subkey
System::String^ EXEName = System::Reflection::Assembly::GetExecutingAssembly()->Location;
//If the item does not exist, create the sub-item
if (key == nullptr)
{
key = Registry::CurrentUser->CreateSubKey("SoftWare\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");
}
//If the value does not exist, set the value and restart the program to apply the setting
if (key->GetValue(EXEName) == "" || key->GetValue(EXEName) == nullptr)
{
key->SetValue(EXEName, "WIN8RTM");
Application::Restart();
}
} catch(Exception^ e) {
}
}