clement-brodu / PCTTools

Library to provide additional tools to PCT
MIT License
0 stars 1 forks source link

Unable to execute PCTTools.dll with my command line #4

Closed gquerret closed 5 months ago

gquerret commented 5 months ago

Here is the test case reproducing the way I'm starting the Catalog task in VSCode: https://github.com/gquerret/PCTTools/commit/793691a38d27f6a3615a286be06acc275fc52a16

However it fails at this line:

wAssembly = System.Reflection.Assembly:LoadFrom(pctTools).

Could you tell me what's wrong? I'm sure this is something stupid, but hey, it's Friday afternoon...

clement-brodu commented 5 months ago

It's because of PCTTextWriter, you have to replace the message by log-manager:write-message

/*------------------------------------------------------------------------
    File        : PCTTextWriter
    Purpose     : This file is used to redirect trace from .NET to Openedge
    Syntax      : 
    Description : 
    Author(s)   : Clément BRODU
    Created     : 
    Notes       : 
  ----------------------------------------------------------------------*/

BLOCK-LEVEL ON ERROR UNDO, THROW.

CLASS PCTTextWriter 
    INHERITS System.IO.TextWriter: 

    DEFINE PUBLIC OVERRIDE PROPERTY Encoding AS System.Text.Encoding NO-UNDO
    GET:
        RETURN System.Text.Encoding:UTF8.
    END GET.

    METHOD PUBLIC OVERRIDE VOID Write (pcCharacter AS CHARACTER):
        LOG-MANAGER:WRITE-MESSAGE(pcCharacter). /* will do a WriteLine */
    END METHOD.

    METHOD PUBLIC OVERRIDE VOID WriteLine ():
        LOG-MANAGER:WRITE-MESSAGE("").
    END METHOD.

    METHOD PUBLIC OVERRIDE VOID WriteLine (pcCharacter AS CHARACTER):
        LOG-MANAGER:WRITE-MESSAGE(pcCharacter).
    END METHOD.

    METHOD PUBLIC OVERRIDE VOID WriteLine (poObject AS System.Object):
        IF VALID-OBJECT(poObject) THEN
            LOG-MANAGER:WRITE-MESSAGE(poObject:ToString()).
        ELSE
            LOG-MANAGER:WRITE-MESSAGE("[null object]").
    END METHOD.

END CLASS.
gquerret commented 5 months ago

Same error. It looks like the DLL is not loaded correctly, but I don't know what to look for. Did you execute catalog.bat ? Using 12.8 Win.

clement-brodu commented 5 months ago

Yes, I started the bat file from proenv with current dirrectory at your "Test" directory.

Have you tried to add a catch at the end of NetAssemblyCatalog.p and -errorstack in the command line ?

catch error as Progress.Lang.Error:
    log-manager:write-message("Error: " + error:GetMessage(1)).
    log-manager:write-message("Error: " + error:CallStack).
    UNDO, THROW error.
end catch.

image

And I get this

[24/03/29@18:43:46.435+0100] P-018952 T-013288 1 4GL -- Logging level set to = 1
[24/03/29@18:43:46.484+0100] P-018952 T-013288 1 4GL APPL           JSON Config file: catalog.json
[24/03/29@18:43:46.486+0100] P-018952 T-013288 1 4GL APPL           PROPATH: ..\OpenEdge,.,D:\Openedge\OE12.7.0\x64\gui,D:\Openedge\OE12.7.0\x64\gui\ablunit.apl,D:\Openedge\OE12.7.0\x64\gui\adecomm.apl,D:\Openedge\OE12.7.0\x64\gui\adedict.apl,D:\Openedge\OE12.7.0\x64\gui\adeicon.apl,D:\Openedge\OE12.7.0\x64\gui\dataadmin.apl,D:\Openedge\OE12.7.0\x64\gui\OpenEdge.BusinessLogic.apl,D:\Openedge\OE12.7.0\x64\gui\OpenEdge.Core.apl,D:\Openedge\OE12.7.0\x64\gui\OpenEdge.ServerAdmin.apl,D:\Openedge\OE12.7.0\x64\gui\prodict.apl,D:\Openedge\OE12.7.0\x64\gui\adecomp.pl,D:\Openedge\OE12.7.0\x64\gu
[24/03/29@18:43:46.486+0100] P-018952 T-013288 1 4GL APPL           i\adedesk.pl,D:\Openedge\OE12.7.0\x64\gui\adeedit.pl,D:\Openedge\OE12.7.0\x64\gui\aderes.pl,D:\Openedge\OE12.7.0\x64\gui\adeshar.pl,D:\Openedge\OE12.7.0\x64\gui\adeuib.pl,D:\Openedge\OE12.7.0\x64\gui\adeweb.pl,D:\Openedge\OE12.7.0\x64\gui\adexml.pl,D:\Openedge\OE12.7.0\x64\gui\protools.pl,D:\Openedge\OE12.7.0\x64,D:\Openedge\OE12.7.0\x64\bin
[24/03/29@18:43:46.487+0100] P-018952 T-013288 1 4GL APPL           RUN NetAssemblyCatalog.p
[24/03/29@18:43:46.732+0100] P-018952 T-013288 1 4GL APPL           destFile :D:\Temp\PCTTools_Gilles\test\output.json
[24/03/29@18:43:46.732+0100] P-018952 T-013288 1 4GL APPL           pctTools :D:\Temp\PCTTools_Gilles\test\PCTTools.dll
[24/03/29@18:43:46.737+0100] P-018952 T-013288 1 4GL APPL           Never reached this point
[24/03/29@18:43:46.849+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:46 - Scan Assembly mscorlib
[24/03/29@18:43:47.092+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly Progress.clrbridge
[24/03/29@18:43:47.093+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly Progress.NetUI
[24/03/29@18:43:47.128+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly System
[24/03/29@18:43:47.236+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly System.Windows.Forms
[24/03/29@18:43:47.647+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly System.Drawing
[24/03/29@18:43:47.685+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly OEEventHandlerAssembly
[24/03/29@18:43:47.685+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly ISymWrapper
[24/03/29@18:43:47.687+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly System.Configuration
[24/03/29@18:43:47.700+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly System.Core
[24/03/29@18:43:47.821+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly System.Xml
[24/03/29@18:43:47.876+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly Progress.Telerik
[24/03/29@18:43:47.885+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - ERROR Reading Assembly Progress.Telerik : Impossible de charger un ou plusieurs des types requis. Extrayez la propriété LoaderExceptions pour plus d'informations.
[24/03/29@18:43:47.886+0100] P-018952 T-013288 1 4GL APPL              à System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)

[24/03/29@18:43:47.886+0100] P-018952 T-013288 1 4GL APPL              à System.Reflection.RuntimeModule.GetTypes()

[24/03/29@18:43:47.886+0100] P-018952 T-013288 1 4GL APPL              à System.Reflection.Assembly.GetTypes()

[24/03/29@18:43:47.886+0100] P-018952 T-013288 1 4GL APPL              à PCTTools.AssemblyCatalog.GenerateDocumentationFromAssembly(Assembly assembly)

[24/03/29@18:43:47.886+0100] P-018952 T-013288 1 4GL APPL              à PCTTools.AssemblyCatalog.GenerateDocumentationFromAppDomain()
[24/03/29@18:43:47.886+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly Progress.Messages
[24/03/29@18:43:47.887+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly netstandard
[24/03/29@18:43:47.887+0100] P-018952 T-013288 1 4GL APPL           2024-03-29T18:43:47 - Scan Assembly OEProxyAssembly
[24/03/29@18:43:48.230+0100] P-018952 T-013288 1 4GL APPL           ERR:no
clement-brodu commented 5 months ago

(I just made a quick fix for output parameters, you can rebase your branch)

gquerret commented 5 months ago

-errorstack helped getting this message:

[24/03/30@07:21:09.894+0100] P-025224 T-032308 1 4GL APPL           Error: System.IO.FileLoadException: Impossible de charger le fichier ou l'assembly 'file:///C:\Users\GillesQUERRET\projets\PCTTools\test\PCTTools.dll' ou une de ses dépendances. L'opération n'est pas prise en charge. (Exception de HRESULT : 0x80131515)
[24/03/30@07:21:09.899+0100] P-025224 T-032308 1 4GL APPL           Error: NetAssemblyCatalog.p at line 36  (..\OpenEdge\NetAssemblyCatalog.p)

DLL was flagged as unsafe by the web browser: image

Unblocking the DLL was the solution. Thanks !