问题
My C#, .NET 4, app runs fine on XP (media centre to be exact - don't ask).
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.)
So, anything I should know about deploying to Windows 7?
Edit: 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.
回答1:
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.
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.
Standard solution is to create the source from your setup.exe
回答2:
You are trying to access a resource that can't be created. Do you happen to have a stacktrace or a better description of what this app actually does?
来源:https://stackoverflow.com/questions/3176337/any-reason-id-get-a-nullreference-exception-on-windows-7-only