OK, I have this program which I haven't touched for a while. For housekeeping reasons I did a re-compile. BIG MISTAKE.
Situation
1. It works from the Windows IDE
2. It works from the Device IDE
3. It crashes as an exe on the device during start up at line 375, caused by line 69 caused by line 31
4. It crashes as an exe on Windows during start up at line 33 and doesn't appear to go to line 375!!!
The crashes say I'm not referencing an object, which is clever because the code has already referenced the object!
Lines 31 and 33 are in app_start, so as you can guess we aren't in a complicated scenario, just trying to create a couple of TreeView objects.
I know you prefer scaled down code but this is about just the very trivial subs which contain the lines specified, so you can ignore the rest of it.
I hesitate to correct the master but that is not quite the whole story. You can invoke New dynamically but all references to that object must then be made by the same "Type(name).Whatever" indirect syntax.
On the desktop for me it barfs on line 33 "ShopTV.Visible = False", replace that by " Treeviewplus(ShopTVStr).Visible = False
" and it now barfs in Sub ReadIni. Make the references indirect in that and all the other Subs and it works fine when compiled.
Technically the reason for this is that dynamically Newing an object doesn't set the global variable that holds the reference to the object so direct references to that variable fail as it remains null, whereas indirect references succeed as they look the object reference up in the controls hashtable.