Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Difference .Net/Win32 with missing libraries? 31 Aug 2021 21:07 #19486

  • ic2
  • ic2's Avatar
  • Topic Author


  • Posts: 1574
  • I was thinking a bit more about my earlier remark that I rarely update X#, partly because my 2.7 works for everything I need in my code my main concern, real Intellisense improvements and speed of use in VS is planned for the version after 2.8c as intended by Robert. That's one of the 2 main reasons I haven't updated to 2.8 (or more precise: I rolled back the update after some new compiler errors in ADS code which will most likely now work after some rewrites in 2.8 anyway but I haven't reinstalled a 2.8 yet).

    The 2nd reason is that I have to replace DLL's at client site and I just realize why this is such an issue. When I would miss a DLL in VO, not very likely as nothing changed for years, I will get a clear error window when starting the VO created program, e.g. The code execution can not proceed because VO28EOLE.DLL was not found.

    This will continue until every DLL is present.

    But recently an X# created program didn't start without any message. It took me a very long time before I found that I had issued an earlier version accidentally which still contained a reference to the Vulcan DLL's which I removed in the latest version and hence also in the installation at the client site. I could only find some clues by digging deep into the Windows Event log.

    Is this another disadvantage of .Net compared to VO or can I change something to get the same clear message for missing DLL's in X# programs?

    Dick

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 31 Aug 2021 23:15 #19487

    • Jamal
    • Jamal's Avatar


  • Posts: 303
  • Dick,

    I assume this is a Winforms app. In your Start method, wrap the form show method with TRY, CATCH and FINALLY block and check for the exception. I have not tried it, but if it does work for you, let me know.

    There is also C# code out there to check for referenced assemblies: docs.microsoft.com/en-us/dotnet/api/syst...emblies?view=net-5.0

    Jamal

    Please Log in or Create an account to join the conversation.

    Last edit: by Jamal.

    Difference .Net/Win32 with missing libraries? 01 Sep 2021 05:58 #19488

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3245
  • Hi Dick,
    to check startup errors about a missing DLL please see this thread:
    www.xsharp.eu/forum/suggestions/1829-pos...missing-included-dll
    and here is my code to deal with it:
    class ProdPlan.XStartupCode
    [STAThreadAttribute];
    static method Start as void
    	local oSB as System.Text.StringBuilder
    
    	try
    	Functions.Start()
    	catch oEx as Exception
    	AllocConsole()
    	oSB			:= System.Text.StringBuilder{}
    	Output( oSB, "An unhandled exception has occurred" )
    	Output( oSB, "===================================" )
    	do while oEx != null
    		Output( oSB, "Exception: " + oEx:Message )
    		Output( oSB, "Callstack:")
    		Output( oSB, oEx:StackTrace )
    		Output( oSB, "" )
    		oEx				:= oEx:InnerException
    	enddo
    	Output( oSB, "===================================" )
    	Output( oSB, "Press return to close the application" )
    	Wait()
    	System.IO.File.AppendAllText( System.IO.Path.Combine( AppDomain.CurrentDomain:BaseDirectory, "ApplicationError.log" ), oSB:ToString() )
    	end try
    	return
    
    static method Output( oSB as System.Text.StringBuilder, cText as string ) as void
    	oSB:AppendLine( cText )
    	Console.WriteLine( cText )
    	return
    
    static method Wait() as void
    	Console.ReadLine()
    	return
    
    [DllImport("kernel32.dll", SetLastError := true)];
    [return: MarshalAs(UnmanagedType.Bool)];
    static extern method AllocConsole() as logic
    
    [DllImport("user32.dll", CharSet := CharSet.Ansi)];
    static method MessageBox(hwnd as IntPtr, lpText as string, lpCaption as string, uType as dword) as int pascal
    
    end class
    
    [STAThreadAttribute];
    function Start() as int
    	local oApp as App
    	oApp 		:= App{}
    	oApp:Run()
    	return 0

    HTH

    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 01 Sep 2021 16:04 #19493

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1574
  • Thanks Wolfgang, Jamal for your reply. This is actually a WCF program (so not WPF or WInforms) but I see that error handling should show the error. I did however already log the exception:message as below and I have checked the log and did not find the missing DLL message there so apparently it doesn't always work contrary to the built in VO reporting which, unfortunately in a way, is again superior to .Net.

    Catch exception As System.Exception
    		LogEvents("IC2WebExchangeWCF",0,Null_Object,"Exception from start "+exception:message,0,"")									// Added logging on runtime error 7-11-2015

    Dick

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 01 Sep 2021 16:10 #19494

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3245
  • Hi Dick,
    please look at this exact message from Robert:
    www.xsharp.eu/forum/suggestions/1829-pos...g-included-dll#13777
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 02 Sep 2021 18:16 #19502

    • Jamal
    • Jamal's Avatar


  • Posts: 303
  • Dick,

    Please see the following discussion about the .NET CLR loader and Win32 loader mechanism and differences.

    stackoverflow.com/questions/2967164/how-...ls-loaded-by-the-clr


    ic2 wrote: Thanks Wolfgang, Jamal for your reply. This is actually a WCF program (so not WPF or WInforms) but I see that error handling should show the error. I did however already log the exception:message as below and I have checked the log and did not find the missing DLL message there so apparently it doesn't always work contrary to the built in VO reporting which, unfortunately in a way, is again superior to .Net.

    Catch exception As System.Exception
    		LogEvents("IC2WebExchangeWCF",0,Null_Object,"Exception from start "+exception:message,0,"")									// Added logging on runtime error 7-11-2015

    Dick

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 03 Sep 2021 13:20 #19510

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1574
  • Hello Jamal,

    Jamal wrote: Please see the following discussion about the .NET CLR loader and Win32 loader mechanism and differences.


    That's very interesting. It could explain why, despite the error handler, nothing was reported but my program simply didn't start without a trace.

    It confirms once more that .Net is full of design flaws. But what else could one expect from Microsoft?

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Difference .Net/Win32 with missing libraries? 04 Sep 2021 14:30 #19515

    • robert
    • robert's Avatar


  • Posts: 3286
  • Dick,

    I strongly disagree that delaying loading DLLs until really needed is a design flaw.
    I think this is a well thought decision.

    Btw: For X# things works a bit differently:
    We add special code to every DLL compiled with X# (at least in the non-core dialects).
    When the main app is started then this startup code is executed, to make sure that INIT procedures are all run at startup time and also to make sure that types in external libraries become available so they can be created with CreateInstance(#TypeName).

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 04 Sep 2021 16:44 #19516

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3245
  • Hi Dick,
    I would even go further than Robert: for me a delayed DLL load is very important.
    I had asked for that many years ago for VO, and since that was not possible, I implemented something for not-always-used DLLs like printing, zipping and some more, to speed up the loading of my applications.
    And AFAIK the company of Arne has a system to load nearly all DLLs delayed.
    I don't think that all decisions that Microsoft has made for .NET are good decisions (IMHO they have several design flaws in WPF), but after all .NET shows that they have learned a lot from earlier systems.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 05 Sep 2021 22:23 #19517

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1574
  • Hello Wolfgang, Robert,

    wriedmann wrote: Hi Dick,
    I would even go further than Robert: for me a delayed DLL load is very important.


    I don't deny that; after all thanks to the JIT compiler starting any .Net program with delayed DLL loading takes a lot more time than a Win32 program like from VO, with loading all DLL's.

    The price we pay for .Net programs not being even slower than they already are however is that there's no (reliable) way to be informed that a DLL may be missing.

    It has taken me a few hours while in VO I would have seen it immediately.

    Dick

    Please Log in or Create an account to join the conversation.

    Difference .Net/Win32 with missing libraries? 07 Sep 2021 08:15 #19520

    • ArneOrtlinghaus
    • ArneOrtlinghaus's Avatar


  • Posts: 337
  • > And AFAIK the company of Arne has a system to load nearly all DLLs delayed.
    Yes, it is still mostly true. Fortunately we could use the advantages of Dotnet. Now more dlls are included in the start exe, as code takes less space in memory. We merged also some smaller dlls to reduce the number of dlls. But nevertheless much code is loaded on demand. Standard usage needs about 20% to 25% of the dlls. All other dll loading depends on the usage of the customer/user. Report windows for example are loaded only randomly and we can see that users use reports much less than years before.

    Arne

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1