xsharp.eu • New to X# and need some direction - Page 3
Page 3 of 8

New to X# and need some direction

Posted: Tue Jun 26, 2018 10:21 am
by tom@dieselworks.com.au
Isn't it right? I think XIDE did it itself, I just browsed for it

New to X# and need some direction

Posted: Tue Jun 26, 2018 10:25 am
by wriedmann
Hi Tom,

it could be that your system has one version of the library in the GAC, and the MYOB library needs a newer one.

With NuGet this works automatically.

Wolfgang

New to X# and need some direction - the XIDE Error

Posted: Tue Jun 26, 2018 10:30 am
by lumberjack
Hi Tom,
tom@dieselworks.com.au wrote: the only issue I have is that I have no idea what to copy where? I have located two folders in the project that I have set up in C# / Vs and copied them over into a new folder under the XIDE test project. Then I set up the references.

Both of these, the MYOB and JSON has a number of subfolders and to be honest I have no clue what to do here. I have copied the v4.0 folder of the JSon DLL into the v4.0 version of MYOB SDK but I still have the message
I think you need to copy the whole folder structure from VS not only the Assemblies. You do not need to add a Reference to NewtonJSON. MYOB will handle that part.

Look again at your error message, it tells you exactly what it needs, V7 of NwtonJSON. Problem is MYOB is looking for it in the same relative path as in your VS folder structure or you need the V7 JSON in the same folder as the MYOB assembly.

Code: Select all

System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
HTH,

New to X# and need some direction

Posted: Tue Jun 26, 2018 10:30 am
by tom@dieselworks.com.au
Thanks Wolfgang but I have fetched both using the VS NuGet - Command Line. what concerns me is that I have the code compiled and running it VS C# but that gets stuck half way through - while the XIDE will not even compile - same libraries

New to X# and need some direction

Posted: Tue Jun 26, 2018 10:40 am
by robert
Tom,
If a C# or X# project in VS uses NuGet then usually the necessary packages are copied to a packages subfolder in the solution.
The source for these packages is in the folder users<Currentuser>.nugetPackages
That last folder will have all versions of packages you have ever used. The packages folder in the solution will only have the package versions that are used in the solution.
Robert

New to X# and need some direction

Posted: Tue Jun 26, 2018 10:48 am
by wriedmann
Hi Tom,

I have now tried to build a VS project. After building and running it, I had the follwing files in my bin folder:
myob_lib.png
myob_lib.png (5.58 KiB) Viewed 472 times
You should add exactly these DLL as references to your XIDE project.

Wolfgang

New to X# and need some direction

Posted: Tue Jun 26, 2018 10:59 am
by tom@dieselworks.com.au
Thanks Robert, that is what I have found following your note. So what do I do with it? I can see 2 versions, 7.0.1 and 11.0.2

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:04 am
by tom@dieselworks.com.au
Thanks Wolgang, what is the rule? Which one do I add? I can see a few versions

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:05 am
by wriedmann
Hi Tom,

I have now tried to build a Console application in X# Core, with the following references (taken from the VS solution bindebug folder):
myob_xsharp.png
myob_xsharp.png (4.88 KiB) Viewed 472 times
The following X# code compiles for me:

Code: Select all

using System.Linq
using MYOB.AccountRight.SDK
using MYOB.AccountRight.SDK.Services
using MYOB.AccountRight.SDK.Services.GeneralLedger

function TestMYOB() as void
	
var configuration := ApiConfiguration{"http://localhost:8080/accountright"}
var cfService := CompanyFileService{configuration}
var companyFiles := cfService.GetRange()

//Next step in the flow is to select a company file that supports v2 contracts
// for the AccountRight API - anything from 2013.3 and up will do here.
var companyFile := companyFiles.FirstOrDefault( { x => Version{ x:ProductVersion } >= Version{"2013.3"} } )

//The company file credentials are an AccountRight requirement with the SDK providing the
//CompanyFileCredentials class to encapsulate these. For our example the company file
//login details in use are username: Administrator with no password on the admin account.
var credentials := CompanyFileCredentials{"Administrator",""}

//Now you are ready to start accessing resources directly from the API
var accountService := AccountService{configuration}
//var accounts := accountService.GetRange(companyFile,null,credentials)

return
The last line does not compile because I don't have the variable companyFile in my code.

Wolfgang

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:12 am
by wriedmann
Hi Tom,

the rule is simple: you need to use what the MYOB people used to build their assembly.

You can look also with . NET Reflector or ILSpy to see what version is needed.
references.png
references.png (10.03 KiB) Viewed 472 times
The NuGet should retrieve the right DLL.

Wolfgang