Registration C#-DLLS

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Alf
Posts: 54
Joined: Wed Dec 30, 2020 10:04 am

Registration C#-DLLS

Post by Alf »

Hi to all,

I my X#-appls, I use a couple of DLLs, written in C#. The number increases nearly from day to day :) .

According to my experience, these DLLs must be registered via RegAsm on the customer machine. This is of course no problem when using innosetup (i.e.). Nevertheless my question: is there a trick to avoid the registration?

Sorry for my stupidity.

Alf
User avatar
Chris
Posts: 4907
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Registration C#-DLLS

Post by Chris »

Hi Alf,

I do not see a reason for the dlls being necessary to be installed in the GAC.
What problems are you seeing when you simply distribute the dlls in the same folder with your .exe?

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Registration C#-DLLS

Post by wriedmann »

Hi Alf,
even if these DLLs are COM DLLs written in C#, then you should be able to use them without registering them in the system.
I had some C# DLLs that I needed to use, and I had distributed them always by copying them only to the executable folder on the target machine, or even better, to a shared folder on the network server so all users can access the application directly from them without even installing it.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
TerryB1
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Registration C#-DLLS

Post by TerryB1 »

Hi Alf

I understand why you are concerned. But there is no need to worry.

.Net works on different principles to those you may have been used to. Any "Sharp" code, no matter what language is used translates to an Intermediate Assembler Language and is therefore totally software. Your executable files "lock in" to their hardware hosts - whether it is your own development machine or you users machine - in just the same way.

Terry

Alf - rather than saying " totally software" which it obviously is, I should have said "has no hardware dependency". Hope that makes more sense.
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Registration C#-DLLS

Post by robert »

Alf,
It is not quite clear to me if you want to use the C# components from X# (this is the X# product forum) or from VO (because you are
referring to RegAsm, which seems to indicate that you want to use them as COM components).
In VO you will have to register them or create a manifest file (look for registry from COM on the web).
In X# you can directly use them.

If you want to use them in VO you may also want to consider to create one "master" component that is your entrypoint to all other components. Simply create a method for each component.
Something like this:

Code: Select all

CLASS MyComComponent
METHOD CreateComComponent1 as ComComponent1
   RETURN  ComComponent1{}
METHOD CreateComComponent2 as ComComponent2
   RETURN ComComponent2{}
END CLASS
This master component would have to be updated when you add a new C# dll (simply add a reference and create a new method)
but the VO code could simply call the new method and would not have to update its manifest.

In all cases you will have to add [ComVisible(TRUE)] attributes to the types that you want to expose.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Alf
Posts: 54
Joined: Wed Dec 30, 2020 10:04 am

Registration C#-DLLS

Post by Alf »

Hi Chris, Wolfgang, Robert, Terry,
thanks for helpful advice. You are right. There is really no need to register dotnet-DLLs - when I add them as a reference.
But in my about hundred years old code, ported from VO to X#, I used OLEAutoObject(). I take your answers as an opportunity to update my code next days. :)
Alf
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Registration C#-DLLS

Post by wriedmann »

Hi Alf,
you can solve that very easily using conditional compiling during the migration phase.

Code: Select all

local oFpr as IXmlFattura
		
#ifdef __XSHARP__
	oFpr := XmlFattura{}
#else
	oFpr := IXmlFattura{}
#endif
oFpr:ReadXML( cFileName )
In VO, IXmlFattura is subclass of OleAutoObjectEx that refers to an X# COM module.
In the X# version I'm referring the X# DLL directly.
And since the methods are the same, this is the only code difference.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply