xsharp.eu • Mixing C# and X#
Page 1 of 2

Mixing C# and X#

Posted: Thu Oct 01, 2020 2:54 pm
by Eric Selje
I was under the impression that I could mix C# and X# projects in one Solution. Is that incorrect?

Eric

Mixing C# and X#

Posted: Thu Oct 01, 2020 3:05 pm
by wriedmann
Hi Eric,
you can do that. In one solution, different applications.
One or more libraries can be in C# (or VB.NET), and your X# application can use them.
Wolfgang

Mixing C# and X#

Posted: Thu Oct 01, 2020 3:28 pm
by Eric Selje
So if I had a XAML application with C# back-end code, and wanted to use my X# business objects, could I combine them in one solution, or would I create two solutions and reference the X# libraries from my XAML app?

Mixing C# and X#

Posted: Thu Oct 01, 2020 3:34 pm
by wriedmann
Hi Eric,
if you combine them in one solution or not is just a question of taste.
Of course you can having a C# WPF application use your X# business objects - but only if they obey to the C# rules: no untyped parameters, no parameter skipping, no untyped variables.
Try and play with it.... after all, the X# compiler writes IL code like the C# compiler.
I'm doing similar things all the time, but not with C# (as I don't like it), but with applications written in X# Core dialect using X# VO style libraries.
Wolfgang

Mixing C# and X#

Posted: Thu Oct 01, 2020 3:38 pm
by Eric Selje
Ah - I think I see now what I was doing wrong. I was trying to stick C# code into a project that I had created using the X# WPF Application Template. I need to create a new project from the C# WPF Application Template so I get the correct compiler settings.

Thanks for talking me through this!

Eric

Mixing C# and X#

Posted: Thu Oct 01, 2020 3:49 pm
by wriedmann
Hi Eric,
exactly!
The greatest advantage of X# is that it takes your xBase code into the .NET platform. That makes it unique and invaluable - and therefore we should do what we can to keep the development team alive and working on it.
Wolfgang

Mixing C# and X#

Posted: Fri Oct 02, 2020 3:33 am
by TimothyS
I have been mixing X# and C# projects for some time now. The C# facility is useful for sample code for 3rd party interfaces. It saves having to translate to X#. C# is quite good, but it is hard to go past X# for flexibility and productivity.
Usually, I will reference the C# projects from my X# projects, but you can do the other way if you follow the rules mentioned by Wolfgang.

Regards,
Tim

Mixing C# and X#

Posted: Fri Oct 02, 2020 10:26 am
by info@task.si
Hi everybody !
Encouraged by last web conference .NET 5.0 - X# core (https://www.youtube.com/watch?v=PJVq_IwzcO8) and positive response from Robert on my question about mixing X# code and Blazor (Razor) code I started to mix C#, X# core DLL and Blazor code. First tests are very impressive and I will continue to develop my first web oriented application.
I choose Blazor because I am a newbie in .net world and I must start from zero. I have also requests from my customers to upgrade my ERP subsystem which was written mainly in VO code to WEB and of course that Blazor is capable also for Linux and MacOS operating system.
At that point I must also thank to you Wolfgang, and to Danilo Gulliano who also adressed those problems and possibility.

At last I have a request. Can anybody warn us and appoint me on the obstacles or dangerouses in a real (production) world. Must X# code be in Core dialect ?
Can I mix Dbcontext and ADO.NET (X# Core dialect library) to reach the data in MS SQLServer ?
Best Regards Andrej Terkaj

Mixing C# and X#

Posted: Fri Oct 02, 2020 11:12 am
by wriedmann
Hi Andrej,
congratulations to your application!
First: you don't have to use only the X# Core dialect, but what you export to your C# application should use what C# knows. That means only typed methods, no VO style arrays, no codeblocks and no date values.
Second: of course you can mix DbContext and Ad.NET.
Wolfgang

Mixing C# and X#

Posted: Fri Oct 02, 2020 2:42 pm
by info@task.si
Thank you Wolfgang !

I understand. I already implemented SMTP class in X#.DLL and then called from Blazor. I have now warnings from VisualStudio about await (async) states. I will try to solve this problem.

What would you recommend us when we want to access X# arrays. We can convert array to <List> and then it can be returned to C#. But I am using also multidimensional arrays and as far as I know there is no substitution for it in C#.

My plan is to use SqlClient (ADO.NET) in my future X# library for some functions and methods (i.e. -- Let me return last ID # from SQL table ... because i am familiar with Robert's VO2ADO library ). For all other purposes DbContext seems is more convenient.

Regards Andrej Terkaj