1. Christopher Craft
  2. PowerBuilder
  3. Thursday, 18 May 2023 21:13 PM UTC

PB 2022 1900

I am a newby to this so be kind to me :-)

We are in the process using SnapDevelop to create a wrapper for Zxing but have had some issues around using .NET Standard or .NET Core.  When importing the DLL using the .NET DLL Importer we would get errors if compiled using .NET Standard (cannot load file or assembly 'System.Runtime, Version 4.2.2.0 ...').  If it was compiled using .NET Core then it will import but this results in us having to install .NET Core onto machines in order for it to work. We have not done .NET 6 because I thought I read somewhere to not use that one right now.

I do not want a requirement for the customer to load a version of .NET core.  We currently have a requirement of .NET framework 4.5 or above so I would say that is my 'target framework'.

Couple questions:

  • Why might you choose one framework type over the other?
  • What is the correlation of the Framework Type option in the DLL Importer to the target framework in SnapDevelop?

Thanks again,

Chris Craft

Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Thursday, 18 May 2023 22:02 PM UTC
  2. PowerBuilder
  3. # 1

Hi Chris,

> Why might you choose one framework type over the other?
You chose .NET Framework if you make use of libraries that are Windows specific such as for accessing the Registry, accessing the WMI, etc.
.NET Core / .NET are what you should go for if you're sure that your development is OS-agnostic (i.e. you don't use any features that require access to Windows-specific components)

Now, .NET Core is out of support as of this year, its successor is .NET (5, 6, 7, etc), .NET 6 being the latest LTS version supported until end of 2024, so .NET 6 is pretty much the best option for this case.

 

> What is the correlation of the Framework Type option in the DLL Importer to the target framework in SnapDevelop?
The option you select in the importer must match the C# project type (.NET Framework, .NET Core, .NET). .NET Framework and .NET Core/.NET are incompatible and you will get an error when trying to import a DLL from the wrong .NET "flavour".
.NET Core is compatible with .NET, but you're still better off selecting the appropriate type.

 

>If it was compiled using .NET Core then it will import but this results in us having to install .NET Core onto machines in order for it to work.

If you publish your C# libraries with the option "Self-contained" you will not need to install the runtime onto the client computer, but this will result in more DLLs being produced and a larger publish size. Now, I'm not sure if PowerBuilder can actually USE the DLLs without the runtime installed, I will have to get back to you on that.

Regards,
Francisco

 

EDIT: I've been informed that the documentation states the Runtime must be installed on the end machine after all

Comment
  1. Christopher Craft
  2. Friday, 19 May 2023 00:21 AM UTC
Thank you Francisco for that explanation.

If I understand...when importing the DLL:

1) If created with .NET Standard then select .NET Framework

2) If created with .NET 6 then select .NET Core or .Net but since .NET Core is going away I should use .Net



This also leads me to a couple more questions:

1) Since .NET 6 is the only option in the drop down what does that mean if it runs on a machine that has .NET 5 (or 4)?

3) When you say 'OS-agnostic' - are you referring to only the code in SnapDevelop or does that also include the DLL we are writing the wrapper for?



Thanks again!

Chris Craft
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Monday, 22 May 2023 17:55 PM UTC
"1) If created with .NET Standard then select .NET Framework"

According to the documentation, yes, you should select .NET Framework when importing a .NET Standard library. However please keep in mind that .NET Standard 2.1 no longer covers .NET Framework. So if your assembly is targeting this version you might be out of luck here.



"2) If created with .NET 6 then select .NET Core or .Net but since .NET Core is going away I should use .Net"

If the assembly is .NET 6, you must select .NET, if the assembly is .NET Core, you MIGHT select .NET Core or .NET (I haven't tested this). But why would you do that when the .NET Core option is right there



"1) Since .NET 6 is the only option in the drop down what does that mean if it runs on a machine that has .NET 5 (or 4)?"

I doubt .NET 6 assemblies will run in a previous runtime version. However, you might be able to run .NET 4/5 assemblies on .NET 6



"3) When you say 'OS-agnostic' - are you referring to only the code in SnapDevelop or does that also include the DLL we are writing the wrapper for?"

I'm not sure of this myself, I haven't ran into this particular scenario so far so I cannot give advice on this. But my gut feeling tells me that if the C# code itself does not make use of any Windows API and it only interacts with the DLL itself, you can go .NET (not Framework)



Regards - Francisco
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.