Possibly error message when starting program with missing included DLL

Have some feedback and input to share?
Don't be shy and drop us a note. We want to hear from you and strive to make our site better and more user friendly for our guests and members a like.
User avatar
ArneOrtlinghaus
Posts: 412
Joined: Tue Nov 10, 2015 7:48 am
Location: Italy

Possibly error message when starting program with missing included DLL

Post 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
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Possibly error message when starting program with missing included DLL

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Possibly error message when starting program with missing included DLL

Post by wriedmann »

Hi Arne,
I have looked better - maybe there couid be a solution:
https://social.msdn.microsoft.com/Forum ... ?forum=wpf
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Possibly error message when starting program with missing included DLL

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Possibly error message when starting program with missing included DLL

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Possibly error message when starting program with missing included DLL

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

Possibly error message when starting program with missing included DLL

Post 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
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Possibly error message when starting program with missing included DLL

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

Possibly error message when starting program with missing included DLL

Post 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
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

Possibly error message when starting program with missing included DLL

Post 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
Post Reply