Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2.0 framework being evil?

Status
Not open for further replies.

JesseM1

Programmer
Mar 15, 2006
5
US
My boss has the 2.0 framework and 1.1 framework installed on his machine, and my developer machine has only the 1.1 framework installed.

I have a project written in C# in Visual Studio 2003 (not using unsafe code), and it always runs fine on my machine, but it keeps getting System.NullReferenceException errors on my boss's machine at random intervals.

Is the 2.0 framework trying to run 1.1 MSIL and failing at it? Has anyone else experienced this yet?
 
The 2.0 framework wouldn't be running the 1.1 code, especially since he has both on his machine. As part of your compiled program, it specifies which runtime that it operates in.

You don't have the line of code isolated that causes the exception? There is probably a code-logic reason that you are getting the exception.

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
Add a unhandled-exception handler to your code, so you can get a stacktrace and see where it's happening.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks for all your responses.

We did some testing, and I finally managed to make my developer machine throw some NullReferenceException exceptions. It still throws a lot more frequently on my boss's machine, though.

The most common place for the exception to be thrown is when I call System.Diagnostics.Process.Start( fileNameString ) to open MS Excel.

It appears to happen completely at random, but when it does happen, the top of the stack trace is:

System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Win32.NativeMethods.ShellExecuteEx(ShellExecuteInfo info)
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)

I created a test program to try to reproduce this problem with certain test cases:
- create a file with an invalid extension,
- create a .xls file that Excel can't read
- make the filename a null string
- edit important values in the .xls file with a hex editor

But all errors thrown resulted in a different sort of exception which was always thrown before Microsoft.Win32.NativeMethods.ShellExecuteEx(ShellExecuteInfo info).

Furthermore, putting a break point before the function revealed that the filename was always valid.

Well, anyway, thanks for all your responses, and I don't expect anyone to try to debug my code for me, but I'm really curious as to why it fails on a function (System.Diagnostics.Process.Start) that I use all the time and has never given me this kind of trouble before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top