bioman 1 Posted November 27, 2020 [dcc32 Error] Server.Resources.pas(46): E2250 There is no overloaded version of 'TMARSResourceRegistry.RegisterResource<Server.Resources.THelloWorldResource>' that can be called with these arguments An error occurs when compiling MARSWebServer, please tell me how to fix it. Share this post Link to post
KostasR 1 Posted December 31, 2020 (edited) Hi, Do you mean the MARS\Demo\HelloWorld project? If so, I just compiled it on Delphi 10.4.1. It runs without any problems. If you mean the example MARS\Demos\MARSWebServer, I always use the template from MARS\Demos\MARSTemplate for new projects. Here the resource is registered without the anonymous method. The resource is created implicitly. initialization TMARSResourceRegistry.Instance.RegisterResource<THelloWorldResource>; // TMARSResourceRegistry.Instance.RegisterResource<THelloWorldResource>( // function: TObject // begin // Result := THelloWorldResource.Create; // end // ); There is another difference with Server.Forms.Main.pas FormCreate uses Web.HttpApp , MARS.Core.URL , MARS.Core.MessageBodyWriter, MARS.Core.MessageBodyWriters , MARS.Core.MessageBodyReader, MARS.Core.MessageBodyReaders , MARS.Utils.Parameters.IniFile, MARS.Core.RequestAndResponse.Interfaces ; --- procedure TMainForm.FormCreate(Sender: TObject); begin // MARS-Curiosity Engine FEngine := TMARSEngine.Create; try FEngine.Parameters.LoadFromIniFile; FEngine.AddApplication('DefaultApp', '/default', ['Server.*']); PortNumberEdit.Text := FEngine.Port.ToString; FEngine.BeforeHandleRequest := function (const AEngine: TMARSEngine; const AURL: TMARSURL; const ARequest: IMARSRequest; const AResponse: IMARSResponse; var Handled: Boolean ): Boolean begin Result := True; // skip favicon requests (browser) if SameText(AURL.Document, 'favicon.ico') then begin Result := False; Handled := True; end; // Handle CORS and PreFlight if SameText(ARequest.Method, 'OPTIONS') then begin Handled := True; Result := False; end; end; StartServerAction.Execute; except FreeAndNil(FEngine); raise; end; end; With these two changes I was able to compile and run the MARSWebServer project. http://localhost:8080/rest/default/helloworld In the resource, the path is set to c:\temp. Thus index.html is searched here. Regards, Kostas Edited December 31, 2020 by KostasR Share this post Link to post
Andrea Magni 75 Posted January 18, 2021 Hi, sorry for the late. Thanks for pointing it out the demos was not compiling. Some demos are a bit outdated and I need to fix them according latest library changes. I've just pushed an update for this (and some other demos) and it should now work out of the box. More to come. Sincerely, Andrea Share this post Link to post