Use .NET libraries

Hi to everybody,
I’m new to Xojo, so I’m ignorant.
I would like to use a .NET library. Specifically I need to use NiceLabel: an application for label printing.
This application expose a SDK interface trough .NET dll.
First of all I need to instantiate a class from this library.
Can someone tell me how to reach this task, or give me an example about using .NET classes?
Many thanks

Eros

This can help:
https://blog.xojo.com/2014/01/03/accessing-net-code-from-xojo/

I saw that blog, but it seems not work for me.
I need to use a SDK created by NiceLabel (NiceLabel 2017 precisely) and It seed not expose the interface (normally it is used with C# trought Visual Studio).
In order to use it you need to reference the SDK wich is in a dll (SDK.NET.Interface.dll). There is a way to use this dll from Xojo?

I also have the same isse with a dll written in C#
I heard somewhere that its because the functions not are COM objects?

I dont know much about visual studio, but would really like to use that dll.

I will be following your thread @Eros Baseotto

There is perhaps a way, kinda convoluted, but it should be possible.

Create a DLL in Visual Studio, maybe in VB. Net since that is the closest to Xojo, which sole purpose is to expose the methods and properties of the DLL, in a new DLL which uses the COM methods.

I thought https://documentation.xojo.com/api/language/declare.html was for using external DLLs?

In Xojo on Windows, I believe Declares only works with native/normal DLLs. Whereas a DLL built using .NET is not the same thing

You can expose some functionality of a managed .NET DLL assembly for COM Interop for use by unmanaged code (a.k.a, non-dot-NET languages), but you need the .NET source (or the vendor) to make the DLL COM accessible.

I could be wrong, but as far as I know, there are no languages or platforms outside of the .NET runtime that can utilize managed DLL assemblies. So it’s not surprising that Xojo cannot either.

I hope that helps.

Thanks for the info, Scott! I love to learn new things :smiley:

[quote][/quote][quote=481050:@Michel Bujardet]There is perhaps a way, kinda convoluted, but it should be possible.

Create a DLL in Visual Studio, maybe in VB. Net since that is the closest to Xojo, which sole purpose is to expose the methods and properties of the DLL, in a new DLL which uses the COM methods.[/quote]

That was an good idea! I have to investigate that. Thanks.

Or maybe make a Xojo plugin ? That have to be done with C++ right ?
In my case I don’t know C# and C++ well enough to do that.
I have the source code for the C# dll I want to use.

It might be easier to write a simple label printer yourself than make an interface to a 3rd party app that does the printing. Is there a reason you need to go via NiceLabel? Can’t you print your own labels from Xojo? Is there some feature that NiceLabel provides that can’t be written in Xojo? Does your label printer have an sdk where you can talk to it directly to achieve the functionality you need?

[quote=481050:@Michel Bujardet]There is perhaps a way, kinda convoluted, but it should be possible.

Create a DLL in Visual Studio, maybe in VB. Net since that is the closest to Xojo, which sole purpose is to expose the methods and properties of the DLL, in a new DLL which uses the COM methods.[/quote]

But does this method work with .NET Core running on a Mac?

I don’t know any way to use a Windows DLL with Xojo Mac. Visual Studio for Mac does not mention any DLL as well, but a post on Stack Overflow seems to indicate it is actually possible.

https://stackoverflow.com/questions/7901438/how-to-use-a-windows-dll-with-java-in-mac-os-x
https://visualstudio.microsoft.com/vs/mac/#vs_mac_table

There is yet a possibility, for someone who absolutely need to run a particular DLL on Mac, directly with the COM, or with the technique I was describing (although I never done it) : compile for Windows, and use CrossOver or Vine to run on Mac.

I use Nicelabel because it is a “storic” application used for label printing. Until the version 2017 (now a newer one called NiceLabel 2019) there was NiceLabel 6 that used activex and nond .Net sdk. NiceLabel is confortable for label creation.
I normally use use Delphi (in Windows environment) for programming and it works good with Nicelabel 6. But Delphi doesn’t use .Net so accessing the new SDK in quite hard. I’m right now using the old NiceLabel 6 for label designing and then a Delphi application that control the label printing. In NiceLabel you can design label and create a set of variables each of one associated with a label element, so at runtime (and with Delphi) I populate these variables before printing the label. The same Delphi application can (always at runtime) show or hide label elements and also move it to a new position. These are there reason I use NiceLabel: My label is totally decoupled from the logic tha print it.