xsharp.eu • Opening a DLL - Page 2
Page 2 of 2

Opening a DLL

Posted: Wed Mar 16, 2022 8:04 am
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

Opening a DLL

Posted: Wed Apr 13, 2022 10:59 pm
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.

Opening a DLL

Posted: Thu Apr 14, 2022 4:05 am
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

Opening a DLL

Posted: Thu Apr 14, 2022 8:28 am
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

Opening a DLL

Posted: Thu Apr 14, 2022 8:45 am
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

Opening a DLL

Posted: Thu Apr 14, 2022 9:10 am
by robert
Wolfgang,
I have never looked at this. So I have no idea how this works.

Robert

Opening a DLL

Posted: Fri Apr 15, 2022 1:36 pm
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?

Opening a DLL

Posted: Fri Apr 15, 2022 6:58 pm
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

Opening a DLL

Posted: Sat Apr 16, 2022 3:51 pm
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