2

I'm working with referenced VB6 DLL's. The problem is that the results of a method/function call are not the same. Below the code examples:

First VB.Net

Dim Validations() As String
myErr = myEntry.ValidateLine(Validations)

When validation fails, the string array Validations is filled with the error description string. I've tried to accomplish the same in C#:

private string[] valArray = null;
sdkError = sdkEntry.ValidateLine(valArray);

Does anyone have an idea why I can't get C# to fill the string array?

Additionally, the function in VB is called with ref to a System.Array ...

ValidateLine(ref System.Array ValErrors), perhaps it has something to do with this?

1
  • Have you tried with ArrayList ? Commented Feb 4, 2012 at 10:32

2 Answers 2

2

My guess is that VB is implicitly passing your variable by reference. You could try doing the same thing in C#:

sdkError = sdkEntry.ValidateLine(ref valArray);

(It's not immediately clear how you're invoking the VB DLL, mind you.)

Sign up to request clarification or add additional context in comments.

Comments

0

Your VB creates and empty array, your C# creates a null array. I'm guessing the VB dll needs a non null value.

Try swapping your C# to this:

private string[] valArray = new string[]{};

2 Comments

The DLL still isn't going to be able to populate that array. (Also, = new string[0] would be simpler, or just = {};.)
The VB is also creating a null array reference, identical to the C#

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.