fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Strange error 0118 in comment & differences XIDE vs VS

Strange error 0118 in comment <sic> & differences XIDE vs VS 2 years 1 month ago #1

Following Phil's advice i got me via nuget "EasyHttp" library from github.
Made a new X# app in Xide, added the references to the two dlls involved.
Then:
USING EasyHttp
USING EasyHttp.Http
FUNCTION Start( ) AS VOID
	System.Console.WriteLine("Hello x#!")               
GetFromUrl()

RETURN
FUNCTION GetFromUrl() AS VOID
	LOCAL  http := HttpClient{}  AS HttpClient                       
	      http:Get("drei-f.de")
//	http:Request:Accept := HttpContentTypes.ApplicationJson
//	VAR response := http.Get("url")
//	VAR customer := response.StaticBody<Customer>()
//	Console.WriteLine("Name: {0}", customer.Name)
RETURN
That code is partially transferred from minimal sample from the lib, hence the commented lines.

The strange thing is: this very code produces on F9 a:
Compilation failed (1 error)
error XS0118: 'customer' is a variable but is used like a type 16,38 Start.prg EasyHttp
Line 16 is the empty line behind the closing RETURN.
Why even "reads" the compiler the commented lines?
If i remove the commented lines, it compiles.
Unfortunately, further on, Xide fails at runtime with "System.TypeLoadException: Type "EasyHttp.Http.HttpClient" in Assembly "EasyHttp, Version=0.0.0.0, Culture=neural, PublicKeyToken=null" couldn't be loaded" (Copy to bin is set, the dlls are there...).
This made me "copy" the app in VS2015, where this error does not happen. Looking further, the template for a console app in VS has about 6 references more, so to check this out, i added them to my Xide-app, but to no avail...

Please Log in or Create an account to join the conversation.

Last edit: by FFF. Reason: enhancement

Strange error 0118 in comment <sic> & differences XIDE vs VS 2 years 1 month ago #2

Hi Karl,

In the code that the compiler reports an error there is this code:

Console.WriteLine("Name: {0}", customer.Name)

and indeed you are using "." on an instance ("customer") of a type to access a member ("Name") of the type, instead of using ":". If you were compiling for the core dialect, "." would had been allowed, too, but I assume you are compiling in vulcan dialect and in this dialect you need to use ":", same as in VO and vulcan. Supporting "." also in vulcan dialect is not supported because it produces several ambiguities that the compiler cannot resolve.

As for the compiler reporting error in a commented line, are you sure that you did not comment this out after you compiled the code? Or maybe something similar happened? If not, can you please send me the app to have a look? But please do include the library dll files, I'd prefer to avoid downloading them myself :-)

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Strange error 0118 in comment <sic> & differences XIDE vs VS 2 years 1 month ago #3

Chris,
no, had made a new X#/Core app, wanted only a quick playground to see, if i could use the Easyhttp code.
Yes, initially the offending code was "active", then commented out, but why the error persists?
Third: this morning the error is gone. If i try to "re-get" it, i see now the errors from earlier this week re static vs. instance etc.
Can only imagine, that i managed to disturb XIDE, starting point was some VB-net code i had opened as prg, which showed rather strange display with entity dividers almost randomly placed. If you are interested, i attached this prg file, too (this code has nothing to do with the other, unfortunately the coders choose the same name for their projects)

Nevertheless, the Loadexception continues, the Code is:
FUNCTION Start( ) AS VOID
	System.Console.WriteLine("Hello x#!")               
GetFromUrl()

RETURN
FUNCTION GetFromUrl() AS VOID
	LOCAL  http := HttpClient{}  AS HttpClient                 
//	http.GetAsFile("http://hadihariri.com/header.png", "C:\Temp\header.png")
      
//	      http:Get("drei-f.de")                                                                    
/*
	http:Request:Accept := HttpContentTypes.ApplicationJson
	VAR response := http.Get("url")
	VAR customer := response.StaticBody<Customer>()
	Console.WriteLine("Name: {0}", customer.Name)                 */
RETURN
The two dlls are attached (@Robert: you might consider allowing 7z-ending, packs are about 25% smaller...)
Attachments:

Please Log in or Create an account to join the conversation.

Strange error 0118 in comment <sic> & differences XIDE vs VS 2 years 1 month ago #4

Hi Karl,

Unfortunately I can't reproduce the problem, this code compiles ok here and executes as expected (printing Hello x#), so can you please zip your project and send it to have a look? Maybe there's something going wrong with the way references are added or something else that doesn't come to mind without seeing the actual project.

As for incorrect entity lines in the VB code, yes I see that, too, indeed the VB net code confuses the parser which expects x# code and incorrectly thinks the METHOD identifiers mark a METHOD entity.

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Strange error 0118 in comment <sic> & differences XIDE vs VS 2 years 1 month ago #5

Sigh... AEF is attached.

THX
Karl
Attachments:

Please Log in or Create an account to join the conversation.

Strange error 0118 in comment <sic> & differences XIDE vs VS 2 years 1 month ago #6

Hi Karl,

Thanks, that helped, the problem happens because the assembly name of your exe (EasyHttp.exe) is the same with the assmebly name of the dll EasyHttp.dll and the .Net loader fails to open it. You will get the same error also with c# or vulcan.

So just change the assembly name of your .exe to something slightly different and it will work!

hth,
Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Strange error 0118 in comment <sic> & differences XIDE vs VS 2 years 1 month ago #7

Chris,
indeed, that did the trick - and on a closer look, i had renamed the App for VS to EasyHttp2 ;)
So much for identical naming of different things...

Now i can proceed trying to find my way in a website with login, open subpage & retrieve some data.

THX!
Karl

Please Log in or Create an account to join the conversation.

  • Page:
  • 1