New to X# and need some direction

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
tom@dieselworks.com.au

New to X# and need some direction

Post by tom@dieselworks.com.au »

Yes I have got that sorted in the meantime, the issue was that I have referenced v11 of Json and not v7
So that works, thaks to all. Now I have both VS C# and XIDE X# stopping at the same point - good and bad :-) Good that it looks like the sample is not correct. So now comes the new challenge :-)
XIDE X#:
error XS0103: The name 'companyFiles' does not exist in the current context 74,20 Form1.prg MYOB_Test1
VS with C#:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'AccountService' could not be found (are you missing a using directive or an assembly reference?) WindowsFormsApp1 C:Usersintersoft.SBSsourcereposWindowsFormsApp1WindowsFormsApp1Program.cs 30 Active

Did you get this? If not
tom@dieselworks.com.au

New to X# and need some direction

Post by tom@dieselworks.com.au »

using System.Windows.Forms
#using System.Drawing

#using MYOB.AccountRight.SDK
#using MYOB.AccountRight.SDK.Services
#using MYOB.AccountRight.SDK.Services.GeneralLedger
#using MYOB.AccountRight.SDK.Contracts


//USING MYOB.AccountRight.SDK
//USING MYOB.AccountRight.SDK.Services
//USING MYOB.AccountRight.SDK.Contracts

CLASS BasicForm INHERIT System.Windows.Forms.Form

PROTECT oTextBox AS System.Windows.Forms.TextBox
PROTECT oOKButton AS System.Windows.Forms.Button
// User code starts here (DO NOT remove this line) ##USER##

CONSTRUCTOR()

SUPER()
SELF:InitializeForm()

RETURN

METHOD InitializeForm() AS VOID

// IDE generated code (please DO NOT modify)

SELF:oTextBox := System.Windows.Forms.TextBox{}
SELF:oOKButton := System.Windows.Forms.Button{}

SELF:SuspendLayout()

SELF:ClientSize := System.Drawing.Size{392 , 264}
SELF:Location := System.Drawing.Point{100 , 100}
SELF:Name := "BasicForm"
SELF:Text := "Basic form application"

SELF:oTextBox:Location := System.Drawing.Point{8 , 48}
SELF:oTextBox:Name := "TextBox"
SELF:oTextBox:Size := System.Drawing.Size{341 , 20}
SELF:oTextBox:TabIndex := 1
SELF:Controls:Add(SELF:oTextBox)

SELF:oOKButton:Click += SELF:OKButtonClick
SELF:oOKButton:Location := System.Drawing.Point{280 , 232}
SELF:oOKButton:Name := "OKButton"
SELF:oOKButton:Size := System.Drawing.Size{104 , 24}
SELF:oOKButton:TabIndex := 0
SELF:oOKButton:Text := "&OK"
SELF:Controls:Add(SELF:oOKButton)

SELF:ResumeLayout()

RETURN

METHOD OKButtonClick(sender AS OBJECT , e AS System.EventArgs) AS VOID

//SELF:Close()
SELF:OKButtonClick2()
// SELF:oTextBox:Text := "Ok"
RETURN

METHOD OKButtonClick2() AS VOID

VAR configuration := ApiConfiguration{"http://localhost:8080/accountright"}
VAR cfService := CompanyFileService{configuration}
VAR comanyFiles := cfService.GetRange()

SELF:oTextBox:Text :="Company Files set"


VAR companyFile := companyFiles.FirstOrDefault({x => Version{x:ProductVersion} >= Version{"2013.3"}})


//VAR credentials := CompanyFileCredentials{"Administrator",""}


//VAR accountService := AccountService{configuration}
//VAR accounts := accountService.GetRange(companyFile,NULL,credentials)

RETURN

END CLASS
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

New to X# and need some direction

Post by wriedmann »

Hi Tom,

you need to add a reference to System.Core and a using System.LinQ to solve this error.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
tom@dieselworks.com.au

New to X# and need some direction

Post by tom@dieselworks.com.au »

and where do I get them from? How to add them?
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

New to X# and need some direction

Post by robert »

You use the one that is also used in your VS project
Usually the latest version.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

New to X# and need some direction

Post by wriedmann »

Hi Tom,

System.Core is in the GAC - is part of the .NET Framework.

FirstOrDefault() is a extension method that comes from the System.Core assembly and uses the System.LinQ namespace:

msdn.microsoft.com/de-de/library/bb340482(v=vs.110).aspx

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

New to X# and need some direction

Post by lumberjack »

Hi Tom,
tom@dieselworks.com.au wrote: and where do I get them from? How to add them?
Add Reference (means add a DLL), so here you go to our application Projects tab on the right in XIDE. Right click references, select Add Reference. Then in the window that opens, select the GAC tab. Type System.Core and add from list.

Now you have the Assembly added to your application. In your form.prg you need to now tell it you want to use Linq from the System.Core assembly. You do that by #using System.Linq with your other #using statements.

HTH,
______________________
Johan Nel
Boshof, South Africa
tom@dieselworks.com.au

New to X# and need some direction

Post by tom@dieselworks.com.au »

Thanks, got this sorted too. I have the test app running (except the last line) and it connects to MYOB, thaks again, really happy. I am not sure if this si a reference issue also?
error XS0120: An object reference is required for the non-static field, method, or property 'ReadableRangeService<Account>.GetRange(CompanyFile, string, ICompanyFileCredentials, string)' 85,19 Form1.prg MYOB_Test1
tom@dieselworks.com.au

New to X# and need some direction

Post by tom@dieselworks.com.au »

Thanks Johan, I have got that sorted, thanks again.
tom@dieselworks.com.au

New to X# and need some direction

Post by tom@dieselworks.com.au »

Thanks Robert, that is sorted, almost there, down to last error :-)
Post Reply