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

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

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

Post 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 98 times
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

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

Post by wriedmann »

Hi Chris,
maybe the function pointers are to replace with delegates....
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

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

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

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

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

Post 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
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

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

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

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

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Kees Bouw
Posts: 119
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

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

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

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

Post by robert »

Kees,
I will see what I can do.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Kees Bouw
Posts: 119
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

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

Post 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!
User avatar
SHirsch
Posts: 286
Joined: Tue Jan 30, 2018 8:23 am
Location: Germany

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

Post 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
Post Reply