xsharp.eu • Xporting an Internet Server based program: Object reference not set.. - Page 2
Page 2 of 3

Xporting an Internet Server based program: Object reference not set..

Posted: Wed Jan 22, 2020 8:18 pm
by wriedmann
Hi Chris,
the message is the following:

Code: Select all

error XS0246: The type or namespace name 'GetHeader' could not be found (are you missing a using directive or an assembly reference?)	261,23	ISAPIDefine.prg	VOInternetServer
on this line of code:

Code: Select all

	member pGetHeader as GetHeader ptr
I've taken the VO Internet Server SDK and xported it to X#.
Please find the zipped XIDE Export File.
Wolfgang
VOInternetServer.zip
(12.5 KiB) Downloaded 97 times

Xporting an Internet Server based program: Object reference not set..

Posted: Wed Jan 22, 2020 8:19 pm
by wriedmann
Hi Chris,
maybe the function pointers are to replace with delegates....
Wolfgang

Xporting an Internet Server based program: Object reference not set..

Posted: Wed Jan 22, 2020 10:53 pm
by Chris
Hi Wolfgang,

Yeah, normally you'd need to use delegates and then pointers derived from them,but this structure is being filled by windows, not by the user, isn't that right? So you do not have control on how you create it.

I think it should be still possible to use the pointers returned and even call the functions contained in them through the pcall/ccall mechanism and actually typed function pointers are already supported in LOCALs (with the /vo6 compiler option enabled), so probably they can be supported in VOSTRUCTs as well, but I think all this will become a big mess, isn't it much better just using the standard .Net internet classes instead, even for ported apps?

But for a quick answer if you really want to compile this library, if you are not actually using the function pointers, you can simply change them to simple AS PTR. Do you have some small code actually using those structures?

Xporting an Internet Server based program: Object reference not set..

Posted: Thu Jan 23, 2020 7:38 am
by wriedmann
Hi Chris,
this library is a part of the VO SDK, and even if I don't use this, there are several people that used it and have asked also in the past to move it to X#.
Wolfgang

Xporting an Internet Server based program: Object reference not set..

Posted: Thu Jan 23, 2020 7:59 am
by robert
Wolfgang,

We'll have a look at the library.
But it will not be easy.
What are you using this for?
- CGI apps
- ISAPI Extension DLL
- ISAPI Filter DLL
- ASP Component DLL

Robert

Xporting an Internet Server based program: Object reference not set..

Posted: Thu Jan 23, 2020 8:09 am
by wriedmann
Hi Robert,
personally I don't use that. But I know several people that uses CGI apps, and I think Dick is using the same.
So this would be the most important.
If others are used, people will ask here, I hope.
Wolfgang

Xporting an Internet Server based program: Object reference not set..

Posted: Thu Jan 23, 2020 4:26 pm
by Kees Bouw
Hi All,

Thank you for the replies. Yes, we have several CGI applications that we would like to transfer to X#. I would be more than happy to use standard .NET internet classes, but some explanation or help would be very welcome. From the VO class we only use this:

CLASS HTTPCGIContext, methods:
GetParamValue
GetParams
Write
HttpHeader
Close
ReadCookies
GetCookieValue
SetCookie
and CLASS HttpCookie

If there are corresponding .NET calls then maybe it will not be too difficult to use those?

Kees.

Xporting an Internet Server based program: Object reference not set..

Posted: Thu Jan 23, 2020 8:43 pm
by robert
Kees,
I will see what I can do.

Robert

Xporting an Internet Server based program: Object reference not set..

Posted: Tue Feb 18, 2020 2:51 pm
by Kees Bouw
With help from Robert I managed to Xport our CGI application and successfully build it in X# without any errors or even warnings. Now I have the situation that the application built in VO does work (and has worked for many years already), but if I copy all files in the X# release folder including the new executable to the website, the web server does not even try to execute it but immediately displays a download window. The X# exe has the same name as the VO exe so executable rights etc. have all been set. What puzzles me is why the web server does not even try to execute it. I should think that once the web server is set up correctly, which it is otherwise the VO version would not work, it will execute anything with the correct name. Many things can go wrong after execution starts of course, but we don't even get to that point. Any ideas on how to explain this (or even better: fix it) are very welcome!

Xporting an Internet Server based program: Object reference not set..

Posted: Tue Feb 18, 2020 3:40 pm
by SHirsch
Hi Kees,

here is a Test class for testing CGI processes. I use this to test php implementation via CGI/FastCGI in my WebServer. Just replace Filename with your exe file and add your required EnvironmentVariables.
Than console output should help.

Code: Select all

FUNCTION Start( ) AS VOID
	System.Console.WriteLine("Hello x#!")

	VAR test := CgiTest{} 
	test:CallCgi()
RETURN

CLASS CgiTest
PRIVATE _phpOutput AS STRING
METHOD CallCgi() AS VOID   
    TRY
        VAR  p := System.Diagnostics.Process{}
        p:StartInfo:FileName := "f:Tempphp-7.4php-cgi.exe"  //Replace with your file
        p:StartInfo:CreateNoWindow := TRUE
        p:StartInfo:UseShellExecute := FALSE       
        p:StartInfo:RedirectStandardInput := TRUE
        p:StartInfo:RedirectStandardOutput := TRUE   
        p:StartInfo:RedirectStandardError  := TRUE  
        p:StartInfo:StandardOutputEncoding := System.Text.Encoding.UTF8
        
        VAR evList := Dictionary<STRING, STRING>{}
        
        p:StartInfo:EnvironmentVariables:Add("SCRIPT_FILENAME", "f:Tempphp-7.4WikiDoku.php")  //Change an add you variables
        p:OutputDataReceived += phpOutputReceived  
        p:Start()
        
        p:BeginOutputReadLine()  
        
        IF (!p:WaitForExit(10000))
           p:Kill()
        ENDIF                                    
        
                 
        VAR err := p:StandardError:ReadToEnd()  
        
        
        Console.WriteLine("received: "+SELF:_phpOutput)
        Console.WriteLine("error: "+err)
    CATCH ex AS Exception
        Console.WriteLine(ex:ToString())
    END TRY
RETURN         
METHOD phpOutputReceived(sender AS OBJECT , e AS System.Diagnostics.DataReceivedEventArgs) AS VOID
    SELF:_phpOutput += e:Data+e"rn"
RETURN   
END CLASS
Stefan