Page 1 of 1
Registration C#-DLLS
Posted: Sun Sep 19, 2021 4:39 pm
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
Registration C#-DLLS
Posted: Sun Sep 19, 2021 8:45 pm
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?
.
Registration C#-DLLS
Posted: Mon Sep 20, 2021 2:55 am
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
Registration C#-DLLS
Posted: Mon Sep 20, 2021 7:02 am
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.
Registration C#-DLLS
Posted: Mon Sep 20, 2021 7:29 am
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
Registration C#-DLLS
Posted: Wed Sep 22, 2021 8:20 am
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
Registration C#-DLLS
Posted: Wed Sep 22, 2021 11:44 am
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