1. ATK Gimmy Susan
  2. PowerBuilder Beta
  3. Monday, 25 November 2019 00:17 AM

 

I try to use the new C# Class Importer, which allows PowerBuilder to use .NET assemblies directly without having to first create a COM Callable Wrapper for them.

 

i have this error:

 

some ideas ?

 

Thanks

 

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 25 November 2019 04:18 AM
  2. PowerBuilder Beta
  3. # Permalink
1
Votes
Undo

Just ideas:

1) compile with a different version of .net: try 4.5.1 or 4.7.x (.net core?)

In the help file, "about c# assembly", you'll find this information: 

The C# assembly supported by PowerBuilder must be developed on .NET Framework 4.0 or later or .NET Standard 1.0 or later. And the assembly DLL file will require the corresponding version of .NET Framework to run, especially if the DLL file is a .NET Standard class library. Please check the Microsoft website or the following table for the compatible versions between .NET Standard and .NET Framework.

 

.NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Framework 4.5 4.5 4.5.1 4.6 4.6.1 4.7.2 4.7.2 4.7.2

 4.0 is missing in this table. Also I've tried 4.7.1 and that worked. I find the whole compatibility thing quite confusing to be honest.

2) in the assembly, do not mark the dll as COM visible. I only did a small test so far and did not mark the DLL as com visible and it worked. I'm not sure if that's important though.

- that's all I can think of

 

Comment
There are no comments made yet.
Richard Keller Accepted Answer Pending Moderation
  1. Wednesday, 11 March 2020 22:46 PM
  2. PowerBuilder Beta
  3. # 1
0
Votes
Undo

If you are using Nuget Packages the C# Importer Cannot find them. So be aware of that.   You can copy the nuget library to a publish directory to bypass.     Also, it looks like it only support primitives right now, so any complex C# classes in the methods or return values doesn't seem to be supported.    Can anyone else confirm that?

Comment
True, simple C#/.NET data types. There are also extra restrictions on how you may use datetime values. I serialized complex C# data structure into JSON = string. Then I had to mimic similar structure in PB or navigate the JSON document directly.

My experience: C# Class Importers needs direct reference to the .DLL.
  1. Michael Kramer
  2. Thursday, 12 March 2020 00:57 AM
Hi Richard,



Michael Kramer is right. You can refer to the following link for more details:

https://docs.appeon.com/appeon_online_help/pb2019r2/application_techniques/ch20s01.html#d0e14827



Regards,

  1. Mark Lee @Appeon
  2. Thursday, 12 March 2020 02:31 AM
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 26 November 2019 09:36 AM
  2. PowerBuilder Beta
  3. # 2
0
Votes
Undo

Hi ATK,

I suggest you verify Miguel's suggestion and see if it works for you.

If not, I also suggest you report this issue to our support ticketing system :https://www.appeon.com/standardsupport/newbug

and provide a sample test case for us to reproduce it.

Just ideas:

1) compile with a different version of .net: try 4.5.1 or 4.7.x (.net core?)

In the help file, "about c# assembly", you'll find this information: 

The C# assembly supported by PowerBuilder must be developed on .NET Framework 4.0 or later or .NET Standard 1.0 or later. And the assembly DLL file will require the corresponding version of .NET Framework to run, especially if the DLL file is a .NET Standard class library. Please check the Microsoft website or the following table for the compatible versions between .NET Standard and .NET Framework.

 

.NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Framework 4.5 4.5 4.5.1 4.6 4.6.1 4.7.2 4.7.2 4.7.2

 4.0 is missing in this table. Also I've tried 4.7.1 and that worked. I find the whole compatibility thing quite confusing to be honest.

2) in the assembly, do not mark the dll as COM visible. I only did a small test so far and did not mark the DLL as com visible and it worked. I'm not sure if that's important though.

- that's all I can think of

 

 

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Monday, 25 November 2019 07:13 AM
  2. PowerBuilder Beta
  3. # 3
0
Votes
Undo

Most of my testing I've done using .NET Standard 2.0.

I suggest compiling for .NET Standard when possible since that allows your assembly to run on both .NET Framework and .NET Core.

Comment
Thanks for the tip!
  1. Miguel Leeuwe
  2. Monday, 25 November 2019 12:19 PM
.NET Standard 2.0 covers a much wider API surface than 1.0 and 1.5. - and SnapDevelop supports .NET Standard 2.0 so you can use Visual Studio, VS Code, and SnapDevelop on same solution + projects back and forth as you like. Quite convenient.
  1. Michael Kramer
  2. Monday, 25 November 2019 13:03 PM
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.