任何原因,我会得到一个NullReference例外,仅在Windows 7?我会、原因、Windows、NullReference

2023-09-06 23:49:19 作者:艾菲尔铁塔下的樱花

我的C#.NET 4中,应用程序运行正常在XP(媒体中心是准确的 - 不要问)

My C#, .NET 4, app runs fine on XP (media centre to be exact - don't ask).

在Windows 7中,它安装好,但马上borks。它抱怨在后台工作的回调一个NullReferenceException。 (我很乐意给你更多的信息,但短期在目标机器上安装VS的,这是所有我可以得到的。)

On Windows 7, it installs fine, but immediately borks. It complains about a NullReferenceException in the callback of a background worker. (I'd love to give you more information, but short of installing VS on the target machine, this is all I can get.)

那么,什么是我应该知道的有关部署到Windows 7?

So, anything I should know about deploying to Windows 7?

编辑:按照要求,这里有什么事情......当我的应用程序初始化的主要形式,它使用了一个后台工作,以创建一个日志类的实例更好的说明。当创建日志类,工人的回调使用日志实例来添加新的条目。

As requested, here's a better description of what's going on... When the main form of my app initialises, it uses a background worker to create an instance of a logging class. When the logging class is created, the worker's callback uses the log instance to add a new entry.

推荐答案

就像我评论说,这是最有可能的权限的情况下(这将在Vista上打破过)。

Like I commented, this is most likely a case of privileges (and it will break on Vista too).

这应该是确定的写的一个事件日志,但有限制(正常)用户不能的创建的一个事件日志。

It should be OK to write to an eventlog, but a restricted (normal) user cannot create an EventLog.

您可以通过pre-创建事件日志与其他工具来解决办法。但是一些(XP的头脑)软件,认为它是始终创建日志是个好主意。错了。

You may be able to workaround by pre-creating the EventLog with another Tool. But some (XP-minded) software thinks it's a good idea to always create the Log. Wrong.

标准的解决方案是从你的SETUP.EXE创建源

Standard solution is to create the source from your setup.exe