xsharp.eu • Possibly error message when starting program with missing included DLL
Page 1 of 5

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 2:20 pm
by ArneOrtlinghaus
I had now the case, that an EXE program did not start because of a missing DLL. The program started and stopped without a message. In the event log I found the following entry:
System.IO.FileNotFoundException
bei <Module>.$AppInit()
bei RadixDN.Exe.Functions.Start()

I looked into $AppInit() with ILSpy and I saw an exception handling. Is it probably possible that in case of an EXE file you open a windows message box with the exception? When having Win32-programs with a missing DLL normally the Runtime shows such a message.
Thanks
Arne

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 2:28 pm
by wriedmann
Hi Arne,
that is a problem I had several times, but I don't thing the devteam can do anything here as it is the .NET Runtime that loads the DLLs.
Wolfgang

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 2:30 pm
by wriedmann
Hi Arne,
I have looked better - maybe there couid be a solution:
https://social.msdn.microsoft.com/Forum ... ?forum=wpf
Wolfgang

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 4:09 pm
by robert
Arne,

Adding a message box should be possible, however that will add a dependency to System.Windows.Forms to all apps. Or we need to add a _DLL FUNCTION in the generated code for MessageBox in user32.dll.
And that would make our programs incompatible with non windows platforms...


Robert

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 4:16 pm
by wriedmann
Hi Robert,
and write an error log?
I suspect this check must be executed before any user code is executed, so there is no possibility to register a handler.... Or would it be possible to call a function with a fixed name in the exe, when it exist?
Wolfgang

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 4:19 pm
by robert
Wolfgang,

I think that calling a function in the EXE should be possible, as long as that function does not depend on any of the initializers that are called from $AppInit() ( init procedures).
I could pass the exception object to that function.
Do you have a suggestion for a function name ?

Robert

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 4:24 pm
by mainhatten
wriedmann wrote:I have looked better - maybe there couid be a solution:
https://social.msdn.microsoft.com/Forum ... ?forum=wpf
If Arne has a similar customer-PEBCAC problem as the original poster of the linked thread, another option is to rename the .exe
Whatever_StartOptimized.exe
and to add another program (depending on nothing but itself, perhaps a JSON or dbf data store and perhaps the GAC) first verifying all dll are in expected place and fit expected CRC-value, either showing nice error msg or starting "Whatever_StartOptimized.exe" if all is ok.

Sometimes going the long way is easier than to confront PEBCAC customers head on...

regards
thomas

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 4:24 pm
by wriedmann
Hi Robert,
that would be great, thank you!
As function name I could suggest "XSharpInitError()", but I'm not really good inventing names <g>.
The important thing is that a sample for such a funtion would be added by XPorter and also in the sample applications in both XIDE and VS, so people sees it and uses it also in own applications.
Wolfgang

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 5:08 pm
by Karl-Heinz
Guys
,
i think the first question should be how Arne is currently catching exceptions ? Is he really using a WPF app, where it seems there is a catch problem when i follow Wolfgang´s link ?

i´m using a global Exception handler, and til now i see all errors using the X# buildin ErrorDialog. Maybe Arne can give a sample when exactely such a exception handling fails ?

Code: Select all

[STAThread];
FUNCTION Start() AS INT 
LOCAL oDlg AS ErrorDialog 
LOCAL oXApp AS XApp

	TRY
		oXApp := XApp{}
		oXApp:Start() 
				  
	CATCH e AS Exception 
		oDlg := ErrorDialog { e }
		oDlg:showDialog() 
		
	END TRY
	
RETURN 0  


CLASS XApp INHERIT App

METHOD Start() 

.. open the first Window 

RETURN 0

END CLASS 

regards
Karl-Heinz

Possibly error message when starting program with missing included DLL

Posted: Wed Mar 18, 2020 5:47 pm
by Karl-Heinz
Hi Arne

Would be interesting to know. When you add this init proc to your app do you see the debout() content before your app closes ?

Code: Select all

PROCEDURE AppInit1 _INIT1
	
	DebOut( "AppInit1" )
	
	RETURN NIL

regards
Karl-Heinz