Error Load Program

micro

Well-Known Member
Licensed User
Longtime User
Hi to all,
I developed a program with basic4ppc 6.90 that work from old time on industrial touchscreens with window CE 6.00
Some days ago there is a new “build” of the operative system CE 6.00 and now when I open the program , it shows me:

"Error Loading Program."
"Value does not fall within the expected range".

How can I do debug in this case?
 

agraham

Expert
Licensed User
Longtime User
I am assuming this is an optimised compiled program where you don't get much error information and that the error information is being displayed in a message box. Is there a Sub name displayed with the error message? If so an exception is being thrown in which you can trap with OnError and examine with my Exceptions library.

Also you can try my Debug Recompiler which should add the number of the line that is causing the error to the message.
 

micro

Well-Known Member
Licensed User
Longtime User
Thanks for yuor answer.
I put a flag on the first line in App_Start
"MsgBox("ok1","Error")
but this messagebox does not appear, then it is difficult to perform a debug.
On the desktop now and in the previus build of OS on the device the same program work perfectly.
I did not understand how to use your debugcompiler, is useful in this case?
I have put DebugDecompiler.exe (ver.2.3) in the same directory of the program, but when i start it appears a message error:
"An error occured on sub_main_app_start."
"Caratteri non validi nel percorso."
"Continue?"
If i go on and put in the first textbox the name of the file and push on the recompile appears another error:
"Impossibile trovare il file X:\arguments.txt"
"Continue?"

How can i fix this problems?
 

agraham

Expert
Licensed User
Longtime User
I don't understand why you are having trouble with DebugDecompiler but it doesn't matter as it looks like the error is occurring in Sub Globals. You will have to find out which line is the problem by putting Msgbox statements in Sub Globals to find how far it is getting before throwing the error.
 

micro

Well-Known Member
Licensed User
Longtime User
I'm sorry agraham but this is really weird ..
Now I put a flag on the first line in Sub Globals
"MsgBox("ok1","Error")
but this messagebox does not appear.
:signOops:
Reappears only this messagebox:
"Basic4ppc"
"Error Loading Program."
"Value does not fall within the expected range".
 

agraham

Expert
Licensed User
Longtime User
In that case it looks like the error is in the Basic4ppc initialize method. This is where all the controls added by the Designer are instantiated and their properties set. It looks like one of those assignments may be the problem. I assume that you have checked that a minimal project will compile and run OK.

If you know what you are doing you could edit some debug code into the Class1.cs file found in the Tzor folder that is somewhere under your AppData/Roaming/AnywhereSoftware folder and recompile it using csc.exe passing it the argument information used by Basic4ppc to compile it that is in the arguments.txt file.

If you cannot do this then I would make a version of your program with no code Subs whatsoever except for all the Globals in each module and App_Start in Main and check that that the error is still present. Then start stripping out each Form added in the Designer to find the Form that has the problem then for that Form remove the controls until you find the one causing the problem.
 

agraham

Expert
Licensed User
Longtime User
If you are brave you could also try this. In the Tzor folder of your Basic4ppc program folder there is a file called Class1.c. Keeping a renamed copy for safety add the following lines to the end of the file. If the error is in initialize you will get a stack trace that should indicate where the error is in the compiled code. That code is in the Class1.cs file in the Tzor folder under AppData/Roaming/AnywhereSoftware folder.
B4X:
try
{
initialize();
}
catch (Exception ex)
{
MessageBox.Show("Error!\n" + ex.Message + "\n" + ex.StackTrace,"Basic4ppc");
}
 

micro

Well-Known Member
Licensed User
Longtime User
great, :sign0188:
thanks for the tip.
these are the exceptions:

"Error!"
"Value does not fall within the expected range."
"at Microsoft.AGL.Common.MISC.HandleAr()"
"at System.Drawing.Bitmap._InitFromMemoryStream()"
"at System.Drawing.Bitmap..ctor()"
"at Dbasic.Other.GetBitmapFromResource()"
"at Dbasic.b4p.initialize()"
"at Dbasic.b4p..ctor()"
"at Dbasic.b4p.Main()"

Now it remains to be seen what causes these errors.....it is strange that with the previous build of OS on the device my program worked perfectly.
 

micro

Well-Known Member
Licensed User
Longtime User
Yes, of course
but to work out how I change the code?
I think it's a problem of management of Microsoft.AGL.Common.MISC.HandleAr ().
I have several ImageButton, imagelist .... how can I filter
quickly the object that caused the error?
 

agraham

Expert
Licensed User
Longtime User
If it is a memory limitation at load time it is not any one particular object that is causing the error but the fact that you are loading more images than the OS can handle. You will just have to experiment with loading only the images you actually need and maybe loading them from files rather having Basic4ppc load them from embedded resources.
 

micro

Well-Known Member
Licensed User
Longtime User
Hi Agraham
then ...
I deleted a form, backgroundimage, 30 ImageButton, a contextual menu and deleted images from other ImageButton but the error is the same.
Possible that with a rebuild changes so much?
:BangHead:
 

agraham

Expert
Licensed User
Longtime User
If you are getting the same error in Microsoft.AGL.Common.MISC.HandleAr() then I guess there must still be one or more bitmaps being initialised. Look in Class1.cs for the initialize() method and see if there are any calls like

xxx.MyBitmap = Other.GetBitmapFromResource(...)

xxx will be something like the name of the control
 

micro

Well-Known Member
Licensed User
Longtime User
ok, nothing.
But are you sure it's a problem of bitmap resources?
In Class1.c there isn't any calls like

xxx.MyBitmap = Other.GetBitmapFromResource(...)
 

agraham

Expert
Licensed User
Longtime User
But are you sure it's a problem of bitmap resources?
No, I'm not sure of anything as I can't see the error but your stack trace shows that the error is in a Bitmap constructor.
In Class1.c there isn't any calls
Make sure you are looking in Class1.cs in the Tzor folder under AppData, not Class1.c which is in the Basic4ppc Tzor folder under Program Files.
 

micro

Well-Known Member
Licensed User
Longtime User
I deleted a imagelist with many items and this error does not occur:

"Error!"
"Value does not fall within the expected range."
"at Microsoft.AGL.Common.MISC.HandleAr()"
"at System.Drawing.Bitmap._InitFromMemoryStream()"
"at System.Drawing.Bitmap..ctor()"
"at Dbasic.Other.GetBitmapFromResource()"
"at Dbasic.b4p.initialize()"
"at Dbasic.b4p..ctor()"
"at Dbasic.b4p.Main()"

but only this error:

"Error Loading Program."
"Value does not fall within the expected range".
 

agraham

Expert
Licensed User
Longtime User
If you still have my try...catch patch in Class1.c then this means that it has successfully run initialize() and is probably now failing in either Sub Globals or Sub App_Start. Try putting Msgbox in statements to see where it is failing.

EDIT:- If this is so you can remove my patch.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…