can any body pls help me...while i run the below code...i get the error,"object reference not set to an instance of the object"....what may be the problem...can any one help me...
namespace ClassLibrary15
{
public class Class1
{

I really do hate giving these sort of 'non answers', but to try and be of help, I just need a little more info...

The message simply states one of the objects you are referencing (trying to use) in this method has not been created. Which line does the exception occure on? Beyond that, I would say that once you find out which line (which object: yes5, close4, uiapane3...etc) the exception is talking about, look further into the Desktop.UIA[] process from which your program is trying to gain a reference to find out why you are not getting one as you expect... without knowing what Desktop.UIA[] does, I don't have a good guess for you as to what it might be.

Perhaps somone else here who has seen what you're doing before can offer more of a solution for you, best of luck!

August 19th, 2011, 03:31 PM

BigEd781

Re: system.nullreference exception...

1. You're using the safe cast (as) operator, yet you don't check for a null return value. That defeats the whole purpose of using the safe cast and makes matters worse than they would be if you had simply used a normal, C-style cast.
2. You have some messy lookups into what appears to be a hash or 3 dimensional array. It is overly optimistic and you are assuming that those values will always exist. You perform absolutely no error checking.
3. You do not need the @ symbol to create a verbatim string in *any* of those strings. At all. Get rid of them as they serve only to obfuscate further what is already messy code.
4. You create buttons, don't add them to any control, and then call what must be a custom Click method. What is that supposed to do? I don't understand what you are even trying to accomplish with this code.
5. Learn to use the debugger. You can easily catch a null reference exception. They are among the easiest bugs to isolate.