Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Nov 20, 2014 11:02 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: An exception of class NilObjectException ... : only on Vista
PostPosted: Thu Mar 27, 2008 3:48 pm 
Offline

Joined: Tue Nov 14, 2006 5:25 pm
Posts: 488
Many little applications that runs ok on Windows Xp (also on Mac and Linux) written using RB Pro 2008 1, on Windows Vista at startup give this error message:
An exception of Class NilObjectException was not handled. The application must shut down.
I'm trying to understand what can cause that (using debbugger).
It's really odd ...
Any idea ?


Top
 Profile  
 
 Post subject: Re: An exception of class NilObjectException ... : only on Vista
PostPosted: Thu Mar 27, 2008 3:57 pm 
Offline
User avatar

Joined: Wed Nov 15, 2006 3:50 pm
Posts: 2353
Location: England
I have found that the Open event does not always seem to fire, or not in the order you expect.

Initialisation which you do in that event may not have happened.
So, if your code does something with (say) a picture object during the Activate event, the picture may not have been initialised yet, leading to a nilobject exception.

Try putting your initialisation code into a subroutine called init_me

Then, in the open and the activate, check one of your objects to see if it is still nil.
If so, call the init_me routine before doing anything else.


Top
 Profile  
 
 Post subject: Re: An exception of class NilObjectException ... : only on Vista
PostPosted: Thu Mar 27, 2008 4:18 pm 
Offline

Joined: Tue Nov 14, 2006 5:25 pm
Posts: 488
Yes, I call a pushbutton action
dim rs as recordSet
dim sql as string = ""
sql = "SELECT * FROM test WHERE id = '" + IDtest+ "' "
rs = app.DB.sqlSelect( sql )
IDtest = rs.Field("ID").StringValue

i receive a rs NIL

I think that other problem is related to permission that under Vista are really 'strong': for example some files and folder that i create with no problems from within the application on vista are not created !
That can be the other problem to investigate ...
Any tutorial on how to write an application under Vista ?
Seems that i need to rewrite the whole application :cry:


Top
 Profile  
 
 Post subject: Re: An exception of class NilObjectException ... : only on Vista
PostPosted: Thu Mar 27, 2008 4:22 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
You should ALWAYS test for errors on EVERY database operation. In this case, what does app.DB.ErrorMessage tell you?

Tim


Top
 Profile  
 
 Post subject: Re: An exception of class NilObjectException ... : only on Vista
PostPosted: Thu Mar 27, 2008 5:33 pm 
Offline

Joined: Thu May 18, 2006 7:03 am
Posts: 202
IIRC, you cannot/should not create folder items in the application's folder. Instead, you should create the folder items in the C:\Documents and Settings\All Users\Application Data\[Your Company] or C:\Documents and Settings\[User Name]\Application Data\[Your Company] folder.

Just basing this off of my somewhat inaccurate memory.

HTH


Top
 Profile  
 
 Post subject: Re: An exception of class NilObjectException ... : only on Vista
PostPosted: Fri Mar 28, 2008 9:22 am 
Offline

Joined: Tue Nov 14, 2006 5:25 pm
Posts: 488
RBNUBE wrote:
IIRC, you cannot/should not create folder items in the application's folder. Instead, you should create the folder items in the C:\Documents and Settings\All Users\Application Data\[Your Company] or C:\Documents and Settings\[User Name]\Application Data\[Your Company] folder.


Seems that's the problem !
But WHY on Vista (and only on Vista, nor Win XP now Mac OS X) i cannot create folder items in the application's folder ?

i've that code that runs ok on Mac and on Win Xp
Dim subfolder as FolderItem
subfolder = GetFolderItem("Test")
subfolder.CreateAsFolder
TestDB = New REALSQLDatabase
TestDB.databaseFile = GetFolderItem("/TestProgram/TestDB.rsd")


Top
 Profile  
 
 Post subject: Re: An exception of class NilObjectException ... : only on Vista
PostPosted: Fri Mar 28, 2008 11:22 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
That was a change made in Vista to improve security. It's harder on malware if it can't install itself in Program Files.

Tim


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group