Former project in VS2017 and v10.0.0.2255 and webrequest

(lhsoft) #1

according to Microsoft the Syntax of webrequest should be:
var req: System.Net.WebRequest := System.Net.WebRequest.Create(URL: String);

If doing so in a new Project (from your web template in VS2017) i get Error <Cannot instantiate abstract class “WebRequest”>

If opening my Project Directory from former VS2015 and Oxygen in VS2017, there is no Compiler error at the same Code file in VS2017. and the whole (huge) Project works fine.
the lines are within a class method:

class method globalfuncs.isHor(Img: System.String): System.Boolean;
var Im: System.Drawing.Image;
if System.Environment.MachineName.ToUpper.StartsWith(‘XXX’) then
var req: System.Net.WebRequest := System.Net.WebRequest.Create(globalvar.ImageURL + Img);
var res: System.Net.WebResponse := req.GetResponse;
var st: System.IO.Stream := res.GetResponseStream;
Im := System.Drawing.Image.FromStream(st);
end else
Im := System.Drawing.Image.FromFile(globalvar.ImagePath + Img);
var ImgW: System.Single := Im.PhysicalDimension.Width;
var ImgH: System.Single := Im.PhysicalDimension.Height;
if ImgH > ImgW then Result := False else Result := True;
if Im <> nil then Im.Dispose;
Result := False;

Do you have any ideas?

There is another strange behavior might bring an idea:
if opening old Directory with the web application in VS2017, the files *.aspx and *.aspx.pas are not grouped any more, the Debugger does not work propperly, the CC does not work and moving mouse over objects like WebRequest shows “unknown type”, but application compiles and works without Problems.

if creating a new Project from your templates in VS2017, the files are grouped, the Debugger works, the CC works and all objects are wellknown. I copied about 8000 lines of my Code in this new Project and all works but only WebRequest does not as described above.

I tried a few hours but found no idea for a solution.

Can you help me?

best regards

(JohnMoshakis) #2

Is legacy create turned on ?

What happens if you add & before the Create ie

var req: System.Net.WebRequest := System.Net.WebRequest.&Create(URL: String);

(lhsoft) #3

yes the reason was the lagacy create enabled. Since turning off, there is no exception any more.

But the second part of the Problem still remains:
I suppose that the old “Web-Application” til VS2015 does not work any more because if creating a Project with VS2017 in old mode, there is no Oxygen available. Therefore, I guess, CC and nothing else regarding Oxygen is available.

If creating a Project with template Oxygene ASP.NET Web-Application, Oxygene works fine but the design files are not updated if writing code to the aspx-file. So I can not use objects of aspx in Code behind without updating the design-file manually. That would be terrible.

What I’m doing wrong?
How to migrate a web-application from VS2015 to VS2017?

best regards