Search code examples
eventsloadgenexus

Read file after open KB - Genexus extensions


I am creating a GeneXus extension and I want that on the AfterOpenKB event the extension reads a file. So, what I did was copy the files that I need read to the packages folder in GX. The thing is that when I am debugging the extension, the method AfterOpenKB is called twice and in one of those is searching for the file in the KB's folder.

The question is, it's expected that the method trigger twice or am I doing something wrong? Should I copy the file to the KB's folder too?

Thanks!


Solution

  • The AfterOpenKB event should be fired only once every time a process opens a KB. Is your extension a UI or a BL extension? I suspect you're developing a BL extension, and what you're seeing is that the MSBuild process for the specifier, which is an independent process and also starts the GX BL, triggers the AfterOpenKB event when opening the same KB as the GX process is opening.

    Can't give an answer to if you should copy the files to the KB folder, without knowing exactly what the extension is doing, but in general, don't believe is a good practice to copy files to the GX installation when opening a KB. Note that it'll be fairly common that GX is located inside Program Files, and writing files into that path will require elevated privileges. Currently GX requires to run as an elevated process, but that's something we may like to change in the future, so I heavily suggest against depending on that. The KB folder seems a better place to copy the files, but again, can't tell for sure without knowing exactly what the extension is doing and what are the files for.

    Hope that helps.