Opening a DLL

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
User avatar
Fabrice
Posts: 409
Joined: Thu Oct 08, 2015 7:47 am
Location: France

Opening a DLL

Post by Fabrice »

Hi Thomas,
ThomasWYale wrote:The VO DLL will be used in a web application written in Python, using Flask to build the UI. I'll copy the code used in the DLL to a separate project in X# and build it that way, though would there be a difference in the DLL whether VO or X# is used to build it? And yeah, I know that source code can be shared between VO and X#.
maybe this is not exactly what you were looking for, but ....
If you move your VO DLL to X#, then you can "easily" use it from Python.
I suggest you have a look at https://pythonnet.github.io/; which allows you to use .NET code directly from Python.... and X# is pure .NET code..

HTH,
Fab
XSharp Development Team
fabrice(at)xsharp.eu
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Opening a DLL

Post by ThomasWYale »

I've been struggling for a month and a friend and I have resolved a lot of configuration issues in VS for this web application. The DLL has been generated from an X# project with x86 platform option chosen in the properties.

The only issue (so far) that remains is that when I try to call the function processSentenceWeb(), which is the point of entry, within the web app, an error message appears, "Exception thrown, function 'processSentenceWeb' not found." Using DUMPBIN with the /exports option reveals no exported endpoints.

This is despite that according to X# documentation, transported code is global, since VO has no concept of namespaces, so shouldn't everything in the DLL be visible once it's accessed by any application? A simulated application, in which a form using VOGUI resources in a dialog uses the DLL, accesses the same function and works fine.
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Opening a DLL

Post by wriedmann »

Hi Thomas,
regarding namespaces: from inside the application, a X# application may not use use namespaces, but since it is a real .NET DLL, it is using namespaces.
And I don't think an X# DLL can be used as any VO DLL because there is a difference: a VO DLL can export a C style interface whereas a X# DLL cannot.
You should be able to use your X# DLL in Flask like a C# DLL:
https://stackoverflow.com/questions/736 ... rom-python
Unfortunately, I have played a bit with "Unmanaged Exports" tool by Robert Giesecke and was not able to make it run, even with C# and Visual Studio.
Maybe someone like Robert or Chris may help you with the unmanaged exports - maybe you can offer Robert v.d. Hulst to pay him the the time he need to solve that.
It is written in German, but it is the same issue: https://www.xsharp.eu/forum/german/2673 ... t=40#22118
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4258
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Opening a DLL

Post by robert »

Guys,
It is possible to export types in an X# assembly without namespace. These types are considered to be part of a "global" namespace.
Functions and globals are always compiled as members of a compiler generated static class Functions.
For X# core assemblies this class is part of the global namespace. For other dialects the class is placed inside a namespace that is derived from the name of the assembly. FOr example: Foo.Dll has a functions class with a name Foo.Functions and for Foo.exe the name becomes Foo.Exe.Functions.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Opening a DLL

Post by wriedmann »

Hi Robert,
thank you very much!
But what I was able to understand: Thomas needs a C like interface, and the X# compiler does not creates that - maybe it could be an option in the X# compiler to do that. It is something the C# compiler cannot do - and it would be an unique feature for a .NET compiler.
It needs two steps: the Unmanaged Exports DLL by Robert Giesecke that adds a new attribute and a post build operation that uses ILDasm and ILAsm to add these export definitions.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4258
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Opening a DLL

Post by robert »

Wolfgang,
I have never looked at this. So I have no idea how this works.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Opening a DLL

Post by ThomasWYale »

Franz's last message that he implemented all 3 examples to show code in his test app seems to imply that he was able to access the DLL. I've attempted to install it with directions from here, though it's from 9 years ago.

https://stackoverflow.com/questions/102 ... le-locally

The Package Manager as shown here no longer exists in VS Community Edition, but I did open the pane for Package Manager Console and looked up how to enter expressions to install Giesecke's nupkg file. (Screenshot.jpg) It's the correct syntax as far as I can see, but there is no project Default. I didn't understand that error. I searched elsewhere and found this more recent article from 2022.

https://docs.microsoft.com/en-us/nuget/ ... ual-studio

I right-clicked References for the project in the Solutions Explorer but the option "Manage NuGet Packages..." is disabled. (Screenshot2.jpg) This is maddening. Do you know of any other ways to get it installed?
Attachments
Screenshot2.jpg
Screenshot2.jpg (39.34 KiB) Viewed 340 times
Screenshot.jpg
Screenshot.jpg (27.36 KiB) Viewed 340 times
ic2
Posts: 1804
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Opening a DLL

Post by ic2 »

Hello Thomas,

There are many articles about greyed out NuGet options. Basically there are dozens of solutions, because it's VS = Microsoft and then it probably won't work for random reasons. Like clean the solution, restarting, not working in debug mode. making sure the project is saved, etc.
We were recently unable to remove a NuGet reference from a project. We solved that by removing the xml reference from the .packagefiles and from the X# project file.

Because of all these problems, I stopped installing NuGet files. A NuGet package is just a zip file. Rename it, put the DLL's from your zip in your project directory and add the references. Ready without the whole bunch of issues Microsoft has reserved for you when using NuGet.

Dick
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Opening a DLL

Post by wriedmann »

Hi Thomas,
using Visual Studio 2019 I was able to install the extension, but was not able to make it work because it is designed to work only on .NET 2.0 executables.
For never .NET executables you have to use another tool, but even investing a few hours of work I was not able to make it work on a C# DLL.
Normally, when I have to try something like this, I try first with Visual Studio and C#, then move it over to X# in Visual Studio and then to X# on XIDE.
But in this case you will need the help from someone other, maybe "our" Robert here.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply