Some warnings and error

This forum is meant for questions and discussions about the X# language and tools
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Some warnings and error

Post by wriedmann »

hi Horst,
In .NET errorhandlers are a very important thing. Please look here in the forums for samples. Unfortunately I'm ouf of town so I cannot help further until Sunday evening.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Some warnings and error

Post by robert »

Horst,
Debugging CGI apps can be a challenge, indeed.
However not impossible:

Add a call to System.Diagnostics.Debugger.Break() in your code.
This will bring up a dialog from your app where you can open or attach a debugger.
From then on you will be able to follow the program execution.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

Some warnings and error

Post by Horst »

Now i am confused. When i use the debugger i can step trough Start (). When i start the CGI App from the prompt its making the Workdir() correctly. And writes the second fwriteline.

When its starts over the IIS-Browser appears a errormessage in the browser.


Unbehandelte Ausnahme: System.ArgumentException: Illegales Zeichen im Pfad.
bei System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str, Boolean onlyCheckExtras)
bei System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
bei System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
bei System.Reflection.RuntimeModule.get_FullyQualifiedName()
bei VulcanRTFuncs.Functions.WorkDir()
bei Logout.Exe.Functions.Start()


pHandle := FOpen("c:swissbaseCGI_Error.log", FO_READWRITE)
FSeek(pHandle, 0, FS_END)
FWriteLine(pHandle, "Start Horst-"+"-"+chr(13)+chr(10))
FClose(pHandle)
--> cMessage := Workdir ()
pHandle := FOpen("c:swissbaseCGI_Error.log", FO_READWRITE)
FSeek(pHandle, 0, FS_END)
FWriteLine(pHandle, "Start Horst2-"+cMessage+"-"+chr(13)+chr(10))
FClose(pHandle)

Any hint ?

And is it possible to have a Line Number ?

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

Some warnings and error

Post by wriedmann »

Hi Horst,

to have line numbers you need to have compiled for debug - therefore I deliver all my X# applications with debug enabled.

The error seems to be in the WorkDir() function, and I don't know why. Maybe it is not defined when the CGI is called from the IIS. Currently I cannot give you a replacement for this function as I'm under pressure right now.

But you should surround your code with try/catch blocks, and write an error log. Otherwise you will have unhandled errors.

Please look here for an explanation:

https://www.xsharp.eu/forum/public-vo-vn/310-suggestions-for-conversion-vo-programs-using-vo-gui-classes?start=10

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

Some warnings and error

Post by Horst »

Hi Wolfgang

i found this and its a workaround for Workdir () , i found that code in Ivo's Juno. But its hard now to change all Workdir's :-( o is thre a possibiliy to overwrite Workdir () with this Function ?

Function _hkGetBinRoot()
LOCAL DIM abDir[256] as BYTE
LOCAL hInst AS PTR
LOCAL nPos AS DWORD
LOCAL cPath AS STRING

hInst := _GetInst()
GetModuleFileName( hInst, @abDir[1], 256 )
cPath := Psz2String( @abDir[1] )
nPos := RAt("", cPath)

IF nPos != 0
cPath := SubStr(cPath, 1, nPos)
ENDIF

RETURN cPath
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Some warnings and error

Post by robert »

Horst,

WorkDir is a function in the VulcanRuntime.
With ILSpy or Reflector you can see that the code (in C#) looks like this:

Code: Select all

public static string WorkDir()
{
	string text = Path.GetDirectoryName(Assembly.GetCallingAssembly().ManifestModule.FullyQualifiedName);
	if (text[text.Length - 1] == Path.DirectorySeparatorChar ^ true)
	{
		text += Path.DirectorySeparatorChar.ToString();
	}
	return text;
}
In this case it calls the RuntimeModule.FullyQualifiedName property (from the System.DLL)
Inside this property the path is retrieved and it asks the system for permission to Discover the path. Inside the FileIOPermission class (again inside System.DLL) the error occurs.
Line numbers for these assemblies will only be available if you download their symbols (PDB files) from the Ms Website. You can do this inside Visual Studio.
You can also download the source to this inside Visual Studio.

From what I have read on several spots on the web this seems to be a security issue.
It seems that if you setup your DefaultAppPool to use Network Services then the problem should be gone.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

Some warnings and error

Post by Horst »

mmm i dont find the switch for the linenumber.
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

Some warnings and error

Post by Frank Maraite »

Horst,

set the /debug compiler switch. Then the compiler generates an additional .pdb file. This file includes the line numbers for the debugger.

Frank
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Some warnings and error

Post by FFF »

Horst,
write e.g. WorkDir_HK() which call's Ivos code, in Xide a CTRL-Shift-R to replace all WorkDir with WorkDir_HK in all files. Or do i miss some problem?

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Some warnings and error

Post by wriedmann »

Hi Horst,

I forgot: to see linenumbers in the error messages, you need to copy also the PDB files together with the DLLs and the EXE.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply