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
User avatar
lumberjack
Posts: 723
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 I can see it, it installed into the default app in VS - but I can't see it from XIDE
Not sure if I miss the point, but look at the attached screenshot. The browse tab let you add a reference from any directory. Press the browse disk for dll files. Go to where VS installed it and voila.
Regards,
Attachments
XIDEAssembly.JPG
XIDEAssembly.JPG (26.63 KiB) Viewed 309 times
______________________
Johan Nel
Boshof, South Africa
User avatar
wriedmann
Posts: 3677
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

New to X# and need some direction

Post by wriedmann »

Hi Karl,

of course one could use this - but unfortunately I have no experience with this.

Until now I have created a C# project, added the libraries there and copied them over to my X# project.

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 »

Thanks for all the comments, I have progressed ore than I expected but have got stuck again and this time it is getting more interesting. So far I have got XIDE working in native , loaded the relevant sample form app and got it running. In VS have loaded the MYOM SDK and managed to get it working. Wow!
Through VS I am able to connect to MYOB, the C# sample app returns the datafile info so I know it works to some extent but fails to compile and run when I have these two lines:
var accountService = new AccountService(configuration);
var accounts = accountService.GetRange(companyFile, null, credentials);


Just for reference, this is the full code posted on the MYOB site:

using MYOB.AccountRight.SDK;
using MYOB.AccountRight.SDK.Services;
using MYOB.AccountRight.SDK.Contracts;

var configuration = new ApiConfiguration("http://localhost:8080/accountright");
var cfService = new CompanyFileService(configuration);
var companyFiles = cfService.GetRange();
var companyFile = companyFiles.FirstOrDefault(x => new Version(x.ProductVersion) >= new Version("2013.3"));
var credentials = new CompanyFileCredentials("Administrator", "muffin023H");
var accountService = new AccountService(configuration);
var accounts = accountService.GetRange(companyFile, null, credentials);


so if I comment out the last two lines of code it works, and no error, but if included I get this error :

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


In X# in XIDE I do not get this far unfortunately.
Using the same code if complains about JSON is missing, which is strange as with exact same inclusion C# in VS doesn't complain and goes a few lines further

Just puzzled a little :-(
Attachments
VS Running2.jpg
VS Running2.jpg (84.79 KiB) Viewed 309 times
tom@dieselworks.com.au

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

Post by tom@dieselworks.com.au »

Here is the actual code and error message:

#using System.Windows.Forms
#using System.Drawing

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

===================================================================

METHOD OKButtonClick2() 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

END CLASS

=================================================
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
MYOB.AccountRight.SDK.ApiOperationException: Encountered an operation error (http://localhost:8080/accountright) ---> 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. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at MYOB.AccountRight.SDK.Extensions.JsonExtensions.FromJson[T](String data)
at MYOB.AccountRight.SDK.Communication.BaseRequestHandler.ExtractDetails[T](HttpWebResponse response, String& location, HttpStatusCode& statusCode) in c:projectsaccountright-live-api-net-sdkMYOB.API.SDKSDKCommunicationBaseRequestHandler.cs:line 152
at MYOB.AccountRight.SDK.Communication.BaseRequestHandler.HandleResponseCallback[T,TResp](IAsyncResult asynchronousResult) in c:projectsaccountright-live-api-net-sdkMYOB.API.SDKSDKCommunicationBaseRequestHandler.cs:line 122
--- End of inner exception stack trace ---
at MYOB.AccountRight.SDK.Extensions.ExceptionExtensions.ProcessException(Exception ex, Uri requestUri) in c:projectsaccountright-live-api-net-sdkMYOB.API.SDKSDKExtensionsExceptionExtensions.cs:line 31
at MYOB.AccountRight.SDK.Services.ServiceBase.MakeApiGetRequestSync[T](Uri uri, ICompanyFileCredentials credentials, String eTag) in c:projectsaccountright-live-api-net-sdkMYOB.API.SDKSDKServicesServiceBase.cs:line 151
at MYOB.AccountRight.SDK.Services.CompanyFileService.GetRange() in c:projectsaccountright-live-api-net-sdkMYOB.API.SDKSDKServicesCompanyFileService.cs:line 45
at BasicForm.OKButtonClick2() in C:XIDEProjectsTom_Test1ApplicationsMYOB_Test1PrgForm1.prg:line 67
at BasicForm.OKButtonClick(Object sender, EventArgs e) in C:XIDEProjectsTom_Test1ApplicationsMYOB_Test1PrgForm1.prg:line 56
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
MYOB_Test1
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/XIDE/Projects/Tom_Test1/Bin/Debug/MYOB_Test1.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3062.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
MYOB.AccountRight.SDK
Assembly Version: 2016.2.99.0
Win32 Version: 2016.2.99.0
CodeBase: file:///C:/XIDE/Projects/Tom_Test1/Bin/Debug/MYOB.AccountRight.SDK.DLL
----------------------------------------

************** JIT Debugging **************
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

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

Post by lumberjack »

Hi Tom,
tom@dieselworks.com.au wrote:
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. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
In XIDE it seems you copied the MYOB assembly to the XIDE path. However NewtonJSON is an assembly that MYOB reference, so get it into the same folder as your MYOB assembly and it would work.

Regards,
Johan
______________________
Johan Nel
Boshof, South Africa
User avatar
wriedmann
Posts: 3677
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

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

Post by wriedmann »

Hi Tom,

to understand what is going on, maybe you should read this article:
docs.xsharp.it/doku.php?id=namespace_assembly_reference

If something is not clear, please let me know, so I can make it clearer

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1538
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

New to X# and need some direction

Post by FFF »

Tom,

Code: Select all

var accountService = new AccountService(configuration);
var accounts = accountService.GetRange(companyFile, null, credentials);
This should be: var accountService := AccountService{configuration}
var accounts = accountService:GetRange(companyFile, null, credentials)

Note the colon vs fullstop. My personal way of thinking is:
A "dot" is NOTHING special, it's a character like any other.
So, tom.dieselworks is simply a name.
The colon is an operator, so tom:dieselworks asks the compiler for the value which the property dieselworks of object tom holds at this moment.
Never understood why MS made such a fuss with "namespace". There's no such thing, it is only a convention to name things coherently...
(FTR, i know there's a small glitch in my argumentation as VO and unfortunately X# treat "structures" special, in using the dot for accessing members of strucs. Again, i see no reason why this made it into core - you have to declare strucs like objects, so the compiler knows what it has at hand and could handle this correctly, but this is getting OT <g>)

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

New to X# and need some direction

Post by lumberjack »

Hi Karl,
FFF wrote:

Code: Select all

var accountService = new AccountService(configuration);
var accounts = accountService.GetRange(companyFile, null, credentials);
This should be: var accountService := AccountService{configuration}
var accounts = accountService:GetRange(companyFile, null, credentials)

Note the colon vs fullstop. My personal way of thinking is:
Be careful what you say. If you look at Tom's code it is the c# version. you read it as "X#", so yes .GetRange should change to :GetRange in X#, but stay .GetRange in c#.

As I read his problem, he did not copy the NewtonJSON assembly also into his XIDE bindebug folder, hence the MYOB assembly cannot find it.
Regards,
Regards,
______________________
Johan Nel
Boshof, South Africa
FFF
Posts: 1538
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

New to X# and need some direction

Post by FFF »

Johan,
i stand corrected, re-reading i see you are right. Sorry for confusing...

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
tom@dieselworks.com.au

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

Post by tom@dieselworks.com.au »

Thanks Johan, You are most likely right, 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
Post Reply