1. Drew Buchanan
  2. PowerBuilder
  3. Monday, 1 July 2019 19:12 PM UTC

Related to: https://community.appeon.com/index.php/qna/q-a/pb2017r3-net-assembly-target-passing-structure-by-reference-in-public-function-causes-c-error-cs0051#reply-14144

When I try to deploy my .NET Assembly, I get the following error when trying to compile the generated C# code:

[CLASS_NAME]_[OBJECT_NAME]_wrapper.cs(1543,23): error CS0051:

Inconsistent accessibility: parameter type 'ref c__[STRUCTURE_NAME] []' is less accessible than method '[NAMESPACE].[OBJECT_NAME].[METHOD_NAME]([NAMESPACE].[STRUCTURE_2_NAME] [], string, ref c__[STRUCTURE_NAME] [], ref string)'

[STRUCTURE_NAME] when I looked at the generated C# was marked as internal, but the method was public. Which makes sense, that's what caused the Inconsistent accessibility error.

However, when I removed the offending method from my assembly and looked at the other structures in the assembly via the Visual Studio Object Explorer, those structures were public.

Is there a way within PowerBuilder to force those structures to be public to enable the C# to compile?

Accepted Answer
Kevin Ridley Accepted Answer Pending Moderation
  1. Wednesday, 3 July 2019 15:28 PM UTC
  2. PowerBuilder
  3. # Permalink

I'm not an assembly expert but I'll take a stab at this since it hasn't been answered yet.  Not sure why any PB developer would still be using structures in any newer development.  Just use a standard nvo with instance var attributes instead of the structure.  I think there was an effort to eliminate structures at one point, but probably left them for backward compatibility.  Remember all those "_____ (structure) will be implicitly private in the next release" messages back in the day when migrating or doing a full rebuild?  Anyway, it makes more sense to just use a nvo anyway, especially if you plan to reuse the assembly with anything other than PowerBuilder someday.  Only PB would ever know what a PB structure is.  You will probably want your assembly to be as generic as possible, so again, use a nvo with standard attributes.

 

Just my $.02

KR

Comment
  1. Drew Buchanan
  2. Wednesday, 3 July 2019 15:40 PM UTC
That definitely makes a lot of sense. I've actually only been working with PowerBuilder since the beginning of 2019, so I didn't do a lot of the migrating surrounding these objects.



Migrating this would be quite the pain, but it's better than just not being able to deploy the assembly.



Thanks
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 3 July 2019 17:48 PM UTC
  2. PowerBuilder
  3. # 1

Hi Kevin;

  FWIW:  Just the reverse .. the only thing that you can pass between PB & C/C++ or C# is a structure. C & C# would not understand NVUO's. So using NVUO's as structures would limit you to only within the PB World.

Regards ... Chris

Comment
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.