fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Mixing C# and X# 01 Oct 2020 16:54 #16035

  • Eric Selje's Avatar

  • Eric Selje

  • Topic Author


  • Posts: 25
  • I was under the impression that I could mix C# and X# projects in one Solution. Is that incorrect?

    Eric

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 01 Oct 2020 17:05 #16036

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • 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
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 01 Oct 2020 17:28 #16037

  • Eric Selje's Avatar

  • Eric Selje

  • Topic Author


  • Posts: 25
  • 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?

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 01 Oct 2020 17:34 #16038

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • 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
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 01 Oct 2020 17:38 #16039

  • Eric Selje's Avatar

  • Eric Selje

  • Topic Author


  • Posts: 25
  • 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

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 01 Oct 2020 17:49 #16040

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • 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
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 02 Oct 2020 05:33 #16043

  • TimothyS's Avatar

  • TimothyS


  • Posts: 44
  • 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

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 02 Oct 2020 12:26 #16044

  • info@task.si's Avatar



  • Posts: 7
  • Hi everybody !
    Encouraged by last web conference .NET 5.0 - X# core (
    ) 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

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 02 Oct 2020 13:12 #16045

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • 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
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 02 Oct 2020 16:42 #16047

  • info@task.si's Avatar



  • Posts: 7
  • 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

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 02 Oct 2020 16:54 #16049

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • Hi Andrej,
    you can convert your array to a List<object> - and then any member can contain anything, even other lists.
    But maybe Robert has a better idea.
    Wolfgang
    P.S. I would go away from multidimensional arrays and use single dimension arrays of objects - I'm doing such changes also in my VO code whenever I touch older code where I have used multidimensional arrays
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 03 Oct 2020 08:05 #16054

  • info@task.si's Avatar



  • Posts: 7
  • Thank you Wolfgang, I will follow your advice. Do you think that continuing to use some win32.dll functions (GetProfileString ...) and also using DBF files could lead me in some troubles in ASP.NET Core world ? I am also asking myself with such doubts because I am aware that Blazor code can be used in Linux op.system. I am asking this mainly for server side oriented Web applications.

    TIA Andrej

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 03 Oct 2020 10:48 #16055

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • Hi Andrej,
    unfortunately I have no experience with .NET Core or ASP.NET or Blazor.
    But you should try to not use any Win32 DLL functions if you plan to use your application also on other operating systems like Linux.
    AFAIK the X# RDD was written using .NET file read/write functionalities, so is should also work on Linux - but here to have better ask Fabrice if he has tried something (he has shown X# applications on Linux a few times) or Robert if he knows anyone that has tried it.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 03 Oct 2020 11:23 #16056

  • robert's Avatar

  • robert


  • Posts: 1895
  • Andrej,

    We have tested the X# runtime on Linux. But I do not know anyone that uses this in production.
    Our low level file IO (which is used by the RDDs) uses managed file streams.
    When running on windows and in shared mode we are using a special file stream to overcome some problems that the managed streams have (they are buffering too much so the changes made by other users are not visible in time).
    In one of the net builds we will be adding buffering to the file streams that are used by the RDD system, but that is all done in managed code so it should run on any platform.
    If you want to run outside windows you should avoid calling Win32 calls such as the functions to read/write INI files.
    But is is not too difficult to replace that with managed code that reads these files with managed streams.
    I am sure that a search on the web will result in many solutions for this. Look for C# and Ini files and you will find what you need.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 03 Oct 2020 11:48 #16057

  • FFF's Avatar

  • FFF


  • Posts: 1014
  • robert wrote: If you want to run outside windows you should avoid calling Win32 calls such as the functions to read/write INI files.But is is not too difficult to replace that with managed code that reads these files with managed streams.
    I am sure that a search on the web will result in many solutions for this. Look for C# and Ini files and you will find what you need.

    I use a class for this Johan Nel kindly shared years ago - which is in X#. Maybe he would contribute this. Would be nice, if we could create a community filled "repo" in download, mainly for the bread and butter tools :)
    Regards
    Karl (X# 2.6; Xide 1.26; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 03 Oct 2020 11:51 #16058

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • Hi Karl,

    Would be nice, if we could create a community filled "repo" in download, mainly for the bread and butter tools


    I would do that immediatly. Do you have any idea how to accomplish that? A simple directory or a page with documentation?
    Or maybe add it to the Wiki?
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 03 Oct 2020 14:45 #16060

  • info@task.si's Avatar



  • Posts: 7
  • Thank you to all. As I go deeply my question for function GetProfileString was a product of my lack of knowledge.
    GetProfileString is a part of kernel32.dll (Windows 10 and other desktop Windows op. system) so using it in a Web server applications would lead me probably in a runtime errors .

    If anybody will be interested I am preparing a "Development notes using X# in Blazor".
    Next step theme in researching will be about X# ResourceFile class in a multilingual Blazor app.

    Robert and others Dev Team you really did a GREAT JOB !! :cheer:

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 04 Oct 2020 11:18 #16061

  • wriedmann's Avatar

  • wriedmann


  • Posts: 2395
  • Hi Andrej,
    GetProfileString() works also on Windows servers.
    Windows Server is "only" Windows Professional with severel different settings and several added applications.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Mixing C# and X# 15 Oct 2020 10:33 #16206

  • lumberjack's Avatar

  • lumberjack


  • Posts: 696
  • Hi Karl,

    FFF wrote: I use a class for this Johan Nel kindly shared years ago - which is in X#. Maybe he would contribute this. Would be nice, if we could create a community filled "repo" in download, mainly for the bread and butter tools :)

    Just a bit busy since I moved town a month ago so still busy finding my feet and settling into my new environment. I will gladly share the jhnIniFile class with anybody interested. I have a couple of new features that I want to implement, give me a week or two. In meantime I can share as is.

    Regards,
    ______________________
    Johan Nel
    George, South Africa

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1