Object reference error on desktop exe

junglejet

Active Member
Licensed User
Longtime User
Hi all,

I have a optimized compile for both device and desktop. They work fine here. I hae sent both exe to two friends in England (I am from a different country). Both run the device exe ok. When they run the desktop exe they get

Error.jpg


One is on XP SP3, one is on Vista. Both have Net3.5 installed. Is this a localization issue? some local DLL missing here?

:sign0085:

Andy
 

junglejet

Active Member
Licensed User
Longtime User
Yes, all this is checked. There are 3 DLLs that are in the same folder on the desktop (colordialog, zip and sharp). And that works fine on my desktop.

Andy
 

junglejet

Active Member
Licensed User
Longtime User
The exact names are colordialog.dll, dzziplib.dll, ICSharpCode.SharpZipLib.dll.

I will be back with the source once I am back to the computer.
 

junglejet

Active Member
Licensed User
Longtime User
Haven't been back to my desktop yet, but I found out that the error does also occur on my laptop. I will need to do more checks on the desktop why it did not occur there.
 

junglejet

Active Member
Licensed User
Longtime User
I did try the desktop application on several others PCs now. It only works on the PC that has Basic4PPC installed. It fails with the above error on all other PCs. I have installed Net 2.0 CF on the others, but no success.

Here is an extract of App_start:

B4X:
Sub App_Start
     WaitCursor(True)

     If (DateYear(Now)>=2009) AND (DateMonth(Now)>2) Then
        Msgbox("Application test period expired", version1)
      AppClose
     End If
     
     'Start-up registry handling
     reg1.New1
          reg1.RootKey(reg1.rtLocalMachine)
     reg1.createsubkey("Software","Jxxx")
     
     bit.New1
     sid1=reg1.GetString(regkey,"id")
     If (sid1="") OR (StrLength(sid1)=9) Then 
      sid1=StrToUpper(bit.dectohex(Abs(Rnd(123456789,987654321))))
      reg1.setstringvalue(regkey,"id",sid1)
     End If
     lbpid.Text="Key: "&sid1
     
     sini=reg1.GetString(regkey,"inifile")
     If sini="" Then 
      sini="default.msprf"
      reg1.setstringvalue(regkey,"inifile",sini)
     End If
     lbcurrentprofile.Text=sini

     'VGA-mode Korrektur
     If form1.Height>400 Then 
        fontdiff=7 'Change to VGA mode
        pendiff=3 'Change to VGA mode
      vgafac=7
      vgafac2=2
      vga2=2 'Targets Zuschlag
      isvga=True
        vga.ChangeToVGA 'Change to VGA mode
     End If
     
     'Bildschirmhintergrund
       screen1(0).X = 0
         screen1(0).Y = 0
         screen1(1).X = Form1.Width
         screen1(1).Y = 0
         screen1(2).X = Form1.Width
         screen1(2).Y = Form1.Height+100
         screen1(3).X = 0
         screen1(3).Y = Form1.Height+100
     
     'Objekte positionieren
     panel3.left=form1.Width/2-panel3.width/2 'Locate the splash panel
     buload.Left=form1.width-buload.Width 'Locate the Load button
     buup.Left=form1.width-buup.Width 'Locate the Load button
     budn.Left=form1.width-budn.Width 'Locate the Load button
     buleft.Left=form1.width-buleft.Width 'Locate the Load button
     buright.Left=form1.width-buright.Width 'Locate the Load button
     
     Form1.Show
     WaitCursor(True)
     DoEvents
     
     'Device relevant initialization
     Form1.ForeLayer=True
     formwidth=form1.Width
     fw2=formwidth*8
     formheight=form1.Height
     fh2=formheight*8
     
     tbc.New1 ("Form3", -5,0, formwidth+5,formheight+5)
          tbc.AddTabPage("Config")
     tbc.SetColor(0,Rgb(220,220,220))
          tbc.AddTabPage("WX")
      tbc.SetColor(1,Rgb(220,220,220))
          tbc.AddTabPage("Text")
      tbc.SetColor(2,Rgb(202,200,174))
          tbc.AddTabPage("Misc")
      tbc.SetColor(3,Rgb(188,204,172))
      
     Controls() = GetControls("Form2")
     For i=0 To ArrayLen(controls())-1
      tbc.AddControl(Control(Controls(i)).name,0,Control(controls(i)).left,Control(controls(i)).top)
     Next
     Controls() = GetControls("wxForm")
     For i=0 To ArrayLen(controls())-1
      tbc.AddControl(Control(Controls(i)).name,1,Control(controls(i)).left,Control(controls(i)).top)
     Next
     Controls() = GetControls("TextForm")
     For i=0 To ArrayLen(controls())-1
      tbc.AddControl(Control(Controls(i)).name,2,Control(controls(i)).left,Control(controls(i)).top)
     Next
     Controls() = GetControls("MiscForm")
     For i=0 To ArrayLen(controls())-1
      tbc.AddControl(Control(Controls(i)).name,3,Control(controls(i)).left,Control(controls(i)).top)
     Next
     
     DoEvents
     TimeFormat ("HH:mm:ss")
     DateFormat ("dd/mm/yy")
     
     Hardware1.New1
     lbscreen.Text="Screen: "&formwidth & " x " & formheight
     lbdeviceid.Text="Device: "&Hardware1.GetDeviceID
     lbnet.Text=".Net: "&Hardware1.NetVersion
     lbver1.text="Version: "&version1
   
     flb.New1("Form1",B4PObject(1))
     flb.FullScreen(False)
     lbversion.Text=Version1
     flb.TextAlignment("lbversion",flb.alCenter)
      obj.New1(False)

     flb3.New1("Form3",B4PObject(3))
     flb3.FullScreen(False)
     flb3.TextAlignment("lbcurrentprofile",flb.alCenter)
     
     flb4.New1("wxform",B4PObject(4))
     flb4.FullScreen(False)
     
     coldi.New1  'colordialog
     gps.New1
     converter1.New1

     ctxm.New1
     ctxm.AddItem("Buttons")
     ctxm.AddItem("-")
     ctxm.AddItem("Center>Tap")
     ctxm.AddItem("Center<GPS")
     ctxm.AddItem("-")
     ctxm.AddItem("Full/Window")
     ctxm.AddItem("-")
     ctxm.AddItem("more...")
     ctxm.AddItem("-")
     ctxm.AddItem("Quit")
     flb.AddContextMenu("Form1",ctxm.Value)

     ctx2.New1
     ctx2.AddItem("5 NM")
     ctx2.AddItem("10 NM")
     ctx2.AddItem("15 NM")
     ctx2.AddItem("20 NM")
     ctx2.AddItem("25 NM")
     ctx2.AddItem("30 NM")
     ctx2.AddItem("40 NM")
     ctx2.AddItem("50 NM")
     ctx2.AddItem("60 NM")
     ctx2.AddItem("80 NM")
     ctx2.AddItem("100 NM")
     ctx2.AddItem("140 NM")
     ctx2.AddItem("180 NM")
     ctx2.AddItem("240 NM")
     flb.AddContextMenu("burange",ctx2.Value)

     ctx3.New1
     ctx3.AddItem("more...")
     flb.AddContextMenu("buload",ctx3.Value)

     WaitCursor(True)
     'Load the configuration
     Readinifile (lbcurrentprofile.Text)
     lbwx.Text=""
     lbwx.Left=10
     lbwx.Width=formwidth-15
     lbtext.Text=""
     lbtext.Left=10
     lbtext.Width=formwidth-15
     
     'Map relevant initialization
     calclong 'calc the current long factor
     LoadMaps 'Load the maps
     
     buGPS.Color=cSilver
     panel3.Visible=False
     DoEvents
     WaitCursor(False)
     timer2.Enabled = True
End Sub

:sign0085:

As I said, it runs ok on the desktop with the B4PPC IDE.

Thanks
Andy
 

agraham

Expert
Licensed User
Longtime User
I did try the desktop application on several others PCs now. It only works on the PC that has Basic4PPC installed. It fails with the above error on all other PCs.
Does it fail when both legacy and optimised compiled on other PCs?

As I said, it runs ok on the desktop with the B4PPC IDE.
Does it run or fail when optimised compiled on this PC?

If it fails when optimised compiled you will have noticed that the error line number is not given. You can use my program here http://www.b4x.com/forum/share-your-creations/3632-debug-optimised-app-device-desktop.html in simple mode (read the help) to alter an optimised compiled app to report the line number when it fails which will make it much easier to find what is happening in a large Sub like your App_Start.
 

junglejet

Active Member
Licensed User
Longtime User
Thanks Agraham, I will try to get a line number.

On other PCs I only tried optimized compile, it fails.

On B4PPC PC I only tried optimized compile, it runs.
 

junglejet

Active Member
Licensed User
Longtime User
Now finally found it:

http://www.b4x.com/forum/questions-help-needed/3170-checking-if-registry-key-exists.html

From the above example you see what as wrong:

B4X:
sini=reg1.GetString(regkey,"inifile")
     If sini="" Then 
      sini="default.msprf"
      reg1.setstringvalue(regkey,"inifile",sini)
     End If

When a key is not existant there is no "" returned, but an exception is created on the desktop. No problem on the device, though.

I believe this is worth a note in some sticky.
 

junglejet

Active Member
Licensed User
Longtime User
Thanks, Erel, finally only this code did the trick for all cases I encountered:

B4X:
Sub GetRegValue (regkey1,name1,default)
     ErrorLabel(notfound)
     ret=reg1.GetValue(regkey1,name1)
     If ret="" Then 
      reg1.setstringvalue(regkey1,name1,default)
        ret=default
     End If
     Return ret
     Notfound:
      reg1.setstringvalue(regkey1,name1,default)
      Return default
End Sub

Andy
 
Top