简体   繁体   English

C#安装程序自定义操作-图形与Windows 7不兼容

[英]C# Installer Custom Action - Graphics not Compatible with Windows 7

I've written a C# Windows Form Application, and a Deployment Project for it. 我已经编写了一个C#Windows窗体应用程序,以及一个针对它的部署项目。 The Deployment Project has a Custom Action. 部署项目具有自定义操作。

I wrote the Application on a Windows XP machine. 我在Windows XP计算机上编写了该应用程序。 When I tested it on a Windows 7 machine, I noticed that major parts of the UI were "blacked out". 当我在Windows 7计算机上对其进行测试时,我注意到UI的主要部分“被涂黑”。 I discovered that this could be fixed by coding the application to "force classic UI mode" regardless of what operating system it ran on. 我发现可以通过将应用程序编码为“强制经典UI模式”来解决此问题,而不管它在什么操作系统上运行。 I did this by making the contents of Main() in the already-existing program.cs read as follows: 我这样做是通过使已经存在的program.cs中Main()的内容如下所示:

static void Main()
{      
    //Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new MainForm());
}

That solves the problem for the main form. 这就解决了主要形式的问题。 (Also, the Deployment Project displays correctly on Windows 7 with no similar modifications to that portion of the code.) (此外,Deployment Project在Windows 7上可以正确显示,而对那部分代码没有类似的修改。)

There is one exception: I had to write a Custom Action for the Installer which displays a Form. 有一个例外:我必须为安装程序编写一个显示表单的自定义操作。 (The user interacts with and hits "Next" just like it was part of the original Installer.) (用户与之交互并点击“下一步”,就像它是原始安装程序的一部分一样。)

My problem is that there is no Main() or Program.cs in the Deployment Project or in the Custom Action (which you create as a separate Class in the same project). 我的问题是,部署项目或自定义操作(您在同一项目中创建为单独的类)中没有Main()或Program.cs。 Consequently I don't know where I'd place the lines to "tell" the Custom Action to render in a fully-compatible display mode. 因此,我不知道在哪里放置行以“告诉”自定义动作以完全兼容的显示模式进行渲染。 The Application namespace (which contains the method I need to use) isn't available in my Custom Action at all. Application名称空间(包含我需要使用的方法)在我的“自定义操作”中根本不可用。

I'd appreciate any pointers -- I'm sure it's an easy fix but I can't find it! 我会很感激任何指点-我敢肯定这是一个简单的解决方法,但我找不到它!

Thanks, rs 谢谢,rs

You need to make sure that your custom action uses Microsoft.Windows.Common-Controls version 6.0: 您需要确保自定义操作使用Microsoft.Windows.Common-Controls 6.0版:

http://msdn.microsoft.com/en-us/library/aa289524(VS.71).aspx http://msdn.microsoft.com/zh-CN/library/aa289524(VS.71).aspx

http://msdn.microsoft.com/en-us/library/bb773175(VS.85).aspx http://msdn.microsoft.com/zh-cn/library/bb773175(VS.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM