Some warnings and error

This forum is meant for questions and discussions about the X# language and tools
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Some warnings and error

Post by robert »

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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Some warnings and error

Post by Chris »

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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

Some warnings and error

Post by Horst »

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
NickFriend
Posts: 248
Joined: Fri Oct 14, 2016 7:09 am

Some warnings and error

Post by NickFriend »

You may want to look at System.Web.Hosting.HostingEnvironment

HTH

Nick
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Some warnings and error

Post by wriedmann »

Hi Horst,

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
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Some warnings and error

Post by Chris »

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.
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):

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
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

Some warnings and error

Post by Horst »

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 ;-)
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

Some warnings and error

Post by Horst »

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
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Some warnings and error

Post by robert »

Horst

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
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Some warnings and error

Post by Chris »

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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply