Optional parameter not recognized

This forum is meant for questions and discussions about the X# language and tools
User avatar
robert
Posts: 4519
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Optional parameter not recognized

Post by robert »

Mathias,
In which scenario do you need to use CCALLNATIVE ?
Technically we could implement that like PCALLNATIVE but it is usually not necessary because there are usually other ways to achieve the same result.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Kromi
Posts: 45
Joined: Wed Jan 13, 2016 8:31 am

Optional parameter not recognized

Post by Kromi »

Hi Robert,

we use this function for communicating with 3rd party components like card readers and an LDAP library.

To be honest, I have no idea if we can replace CCallNative where we use it.

Mathias
User avatar
Otto
Posts: 174
Joined: Wed Sep 30, 2015 6:22 pm

Optional parameter not recognized

Post by Otto »

OK. I have found MY error. :oops:

I had typed

METHOD Constructor( param1 as string, param2 := "" as string)

and the error message was on the call to a constructor with 1 parameter which resulted in the error "can't find constructor with 1 parameter".

I should have typed

Constructor( param1 as string, param2 := "" as string)

Sorry for the inconvenience.

Is it an option to create an warning on the use of the word Constructor if the word method preceeds it or something like that?

I wonder how many METHOD Constructors without parameters I have created... :oops:
edit: none B)
User avatar
Chris
Posts: 4905
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Optional parameter not recognized

Post by Chris »

Hi Matthias,
Kromi wrote:Hi Chris,

the scenario is important for me because I'm evaluating the transition of a huge Vulcan.NET solution to X#. Since I get some errors from the X# compiler that I can't resolve yet (e. g. calls to CCALLNATIVE) in a base project, my plan was to reset this project back to Vulcan.NET in order to be able to evaluate other projects that depend on the base project.

Mathias
I think the error you are seeing when calling the x# library from vulcan is a kind of dll mismatch problem, probably vulcan in VS "sees" an older version of the X# dll. Please try a Clean Solution, then Rebuild All, I think it will compile fine now.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Kromi
Posts: 45
Joined: Wed Jan 13, 2016 8:31 am

Optional parameter not recognized

Post by Kromi »

Chris,

Cleaning, deleting bin and obj directories and rebuilding did not help, the error is still there.

If I change the signature of the called constructor in a way that there's no cast any more, the compiler is happy. If I add the cast again, the error returns.

Mathias
User avatar
Chris
Posts: 4905
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Optional parameter not recognized

Post by Chris »

Hi Matthias,
Kromi wrote:Chris,
Cleaning, deleting bin and obj directories and rebuilding did not help, the error is still there.

If I change the signature of the called constructor in a way that there's no cast any more, the compiler is happy. If I add the cast again, the error returns.
Hmm, this is very strange, normally this should not be making any difference in this code, I just checked the generated IL with and without the cast and it is identical. Just now I realized you said you are using an older X# build, can you please try again with the newer?

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Kromi
Posts: 45
Joined: Wed Jan 13, 2016 8:31 am

Optional parameter not recognized

Post by Kromi »

I think I'm using the newest one that is publicly available. But I'll try again as soon as 2.0.0.4 is available.

Mathias
User avatar
Chris
Posts: 4905
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Optional parameter not recognized

Post by Chris »

Kromi wrote:I think I'm using the newest one that is publicly available. But I'll try again as soon as 2.0.0.4 is available.

Mathias
OK, I will install the build you're using and test also with it and will tell you if this is what makes the difference.

Chris
Chris Pyrgas

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

Optional parameter not recognized

Post by wriedmann »

Hi Chris,

I was able to download the solution as I have both the latest Vulcan and X# 2.0.0.4 in my Visual Studio 2015: the error is present also in this version:

Code: Select all

Severity	Code	Description	Project	File	Line	Suppression State
Error		'InheritedXsharp.ClassWithCtor{ STRING }' : no constructor that accepts these argument types	VulcanReferencingXsharp	C:DevNETtempVulcanReferencingXsharpMyClass.prg	16	
If I can do something to help please let me know.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4905
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Optional parameter not recognized

Post by Chris »

Thanks Wolfgang!

Guys, do you get a warning from MSBuild that there is a mismatch between the platform of the vulcan runtime dlls (x86) and the platform target of the X# app (AnyCPU)? This should be displayed, but for some reason it doesn't and this makes me believe something has gone off in the solution and it does not get fixed with a rebuild either, I could fix it only with a Clean. Wolfgang, please try deleting all .dll/.exe files from the solution, then select rebuild all, does it make any difference?

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply