Shared class library

This forum is meant for questions and discussions about the X# language and tools
Post Reply
RolWil
Posts: 68
Joined: Mon Jul 18, 2022 3:16 am

Shared class library

Post by RolWil »

Hi all,

I have something you'll no doubt be able to help me with:

Goal: create a Class shared by a dozen or so projects (the Class provides the functionality to create reports in HTML format).

Question: how to accomplish this (I use the Harbor dialect). I see there are class templates, but they create DLL’s. Is there a way the class code can be pulled in at compile time?

Thanks folks,
Roland
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Shared class library

Post by wriedmann »

Hi Roland,
to have a class shared by several projects you have to create a DLL and to include it in the references of every application.
This library can be part of the same project as the executable or of a different project.
There are other, more advanced possibilities to share code, but they have some drawbacks and need much more attention.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4910
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Shared class library

Post by Chris »

Hi Roland,

If the class consists of one or a few prg files it is not difficult, you just need to add the file in all of your apps/projects that need it, as a linked file. In order to do that in XIDE, when you add the file, just say "No" when asked to copy it to the app folder. I think Wolfgang refers to the complexity of making sure all your apps use the compiler options that this class requires, but I think that's manageable.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply