Horst,
I am not sure what you want to achieve, but the folder where the program is located (which is what you get from GetModuleFileName()) is not always the same as the WorkDir().
Robert
Some warnings and error
Some warnings and error
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Some warnings and error
Hi Horst,
Just some more info, yes it is possible to replace the WorkDir() function (and any other runtime function) with your own version.
You simply need to (re)define it in the same exe/dll with the code that calls it and the compiler will pick your version, instead of the "old" function defined in the runtime dlls.
So, in your case, you can just rename Function _hkGetBinRoot() with Function WorkDir() AS STRING (just better also include the return type, but it is not mandatory) and you will not need to make any other changes.
Although like Robert said, I am not sure if this is the solution to the underlying security issue.
Chris
Just some more info, yes it is possible to replace the WorkDir() function (and any other runtime function) with your own version.
You simply need to (re)define it in the same exe/dll with the code that calls it and the compiler will pick your version, instead of the "old" function defined in the runtime dlls.
So, in your case, you can just rename Function _hkGetBinRoot() with Function WorkDir() AS STRING (just better also include the return type, but it is not mandatory) and you will not need to make any other changes.
Although like Robert said, I am not sure if this is the solution to the underlying security issue.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Some warnings and error
Houres later, reading many in IIS Help, i found no other solution for Workdir ()in IIS as to use a other function.
Maybe Vulcan-Workdir() tries to get the "WorkingDirectory of the IIS" and this is not allowed. A post from IIS Forum.
I got a hint from a IIS forum to take
Directory.GetCurrentDirectory ()
Retrieves the current directory for the current process.
So i will make my own Workdir () with this call and i hope Chris hint the compiler will take this Function works.
Thanks for your help
Maybe Vulcan-Workdir() tries to get the "WorkingDirectory of the IIS" and this is not allowed. A post from IIS Forum.
I got a hint from a IIS forum to take
Directory.GetCurrentDirectory ()
Retrieves the current directory for the current process.
So i will make my own Workdir () with this call and i hope Chris hint the compiler will take this Function works.
Thanks for your help
-
- Posts: 248
- Joined: Fri Oct 14, 2016 7:09 am
Some warnings and error
You may want to look at System.Web.Hosting.HostingEnvironment
HTH
Nick
HTH
Nick
Some warnings and error
Hi Horst,
it is a great thing that we can use hints from C# or VB.NET also in X#!
Wolfgang
it is a great thing that we can use hints from C# or VB.NET also in X#!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Some warnings and error
Yes, it will work. When you use a function in your code, the compiler searches for it in places in this order (I will not complicate things by including also same named method here):Horst Korak wrote: So i will make my own Workdir () with this call and i hope Chris hint the compiler will take this Function works.
1. First it searches for such a named function inside the same dll/exe ("assembly") with the function call itself.
2. Then it searches in all of the referenced libraries, excluding the vulan runtime libraries.
3. If the function is not found yet, then teh compiler searches for the function in the runtime libraries as well.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Some warnings and error
ohhh i am going tired This code works fine when i start it on dos prompt
FUNCTION myerr (cText as string, gdDebug as dword) as void
LOCAL pHandle AS PTR
LOCAL n AS DWORD
if gdDebug = 1
pHandle := FOpen(WorkDir ()+"CGI_Error.log", FO_READWRITE)
<b>IF pHandle != F_ERROR</b>
FSeek(pHandle, 0, FS_END)
n := FWriteLine(pHandle, cText+chr(13)+chr(10))
FClose(pHandle)
endif
endif
RETURN
But when the cgi is called from IIS then the exe hangs on the line
<b>IF pHandle != F_ERROR</b>
and the errormsg is
Unbehandelte Ausnahme: System.IO.FileNotFoundException: Die Datei oder Assembly "SDK_Defines, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
bei Logout.Exe.Functions.myerr(String cText, UInt32 gdDebug)
bei JunoHttpCgiContext..ctor(__Usual[] Xs$Args) in C:XporterOutputSwissbase-Logout__JunoHttpCgiContext.prg:Zeile 32.
bei Logout.Exe.Functions.Start() in C:XporterOutputSwissbase-Logout__Start.prg:Zeile 28.
Any idea ?
Only for understanding, why is VO working and X# not ? The basic i think are the same OS Functions.
Horst - unhappy
FUNCTION myerr (cText as string, gdDebug as dword) as void
LOCAL pHandle AS PTR
LOCAL n AS DWORD
if gdDebug = 1
pHandle := FOpen(WorkDir ()+"CGI_Error.log", FO_READWRITE)
<b>IF pHandle != F_ERROR</b>
FSeek(pHandle, 0, FS_END)
n := FWriteLine(pHandle, cText+chr(13)+chr(10))
FClose(pHandle)
endif
endif
RETURN
But when the cgi is called from IIS then the exe hangs on the line
<b>IF pHandle != F_ERROR</b>
and the errormsg is
Unbehandelte Ausnahme: System.IO.FileNotFoundException: Die Datei oder Assembly "SDK_Defines, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
bei Logout.Exe.Functions.myerr(String cText, UInt32 gdDebug)
bei JunoHttpCgiContext..ctor(__Usual[] Xs$Args) in C:XporterOutputSwissbase-Logout__JunoHttpCgiContext.prg:Zeile 32.
bei Logout.Exe.Functions.Start() in C:XporterOutputSwissbase-Logout__Start.prg:Zeile 28.
Any idea ?
Only for understanding, why is VO working and X# not ? The basic i think are the same OS Functions.
Horst - unhappy
Some warnings and error
Hallo
I dont understand following - return as void ?? from the Vulcan help
PUBLIC STATIC METHOD FOpen( ;
cFile As STRING, _
dwAttributes As DWORD _
) AS VOID
It has to give back a pointer to the file. Confused.
Horst
I dont understand following - return as void ?? from the Vulcan help
PUBLIC STATIC METHOD FOpen( ;
cFile As STRING, _
dwAttributes As DWORD _
) AS VOID
It has to give back a pointer to the file. Confused.
Horst
Some warnings and error
Horst
I think it returns a void *, a void pointer which is the same as the ptr type in vo.
Robert
I think it returns a void *, a void pointer which is the same as the ptr type in vo.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Some warnings and error
Hi Horst,
The error message says that SDK_Defines cannot be found at runtime. Have you put the SDK_Defines.dll file in the sane folder where you have put the other dlls, for the app to find them?
Chris
The error message says that SDK_Defines cannot be found at runtime. Have you put the SDK_Defines.dll file in the sane folder where you have put the other dlls, for the app to find them?
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu