West Wind .NET Tools and Demos
Passing Binary from VFP to .NET with wwDotnetBridge
Gravatar is a globally recognized avatar based on your email address. Passing Binary from VFP to .NET with wwDotnetBridge
  Manni Borg
  All
  Dec 1, 2021 @ 08:07am

Hi Rick,

I'm referring to this article: https://west-wind.com/wsdlgenerator/docs/_3420o5sp6.htm

I'm trying to pass an object "oData" to .NET via wwDotnetBridge. The object has two properties: ID (string) and XmlFile (byte array). First, I have to create the object in VFP by using CreateInstance() of wwDotnetBridge. Second, I have to set the two properties of the object oData.ID and oData.XmlFile. Third, I have to send the object with SendData(oData).

testXmlFile = FILETOSTR("C:\Temp\test.xml")

oData = loBridge.CreateInstance("ComInterop.MailData")
oData.ID = "123"  && works
* oData.XmlFile(1) = CREATEBINARY(testXmlFile) && Error: The parameter is incorrect.

* Instead trying with InvokeMethod
loBridge.InvokeMethod(oData.ID(1), "passBinary", CREATEBINARY(testXmlFile))  && Error: System.DBNull.passBinary wasn't found

com = loBridge.CreateInstance("ComInterop.Operations")
success = com.SendData(oData)


    [ClassInterface(ClassInterfaceType.AutoDual), Guid("..."), ComVisible(true)]
    public class MailData
    {
 
	// Methods
	...

	// Properties
        public string ID { get; set; }
        public byte[] XmlFile { get; set; }

    }

Obviously, I'm using InvokeMethod() the wrong way. Is there any way to achieve what I want, assigning the object oData a binary value?

Any help would be greatly appreciated.

Thanks, Manni

Gravatar is a globally recognized avatar based on your email address. re: Passing Binary from VFP to .NET with wwDotnetBridge
  Manni Borg
  Manni Borg
  Dec 2, 2021 @ 01:41am

Had to switch to using another method of the Assembly. Sometimes it gets too hard to deal with the different types.

Thanks for reading, Manni

Gravatar is a globally recognized avatar based on your email address. re: Passing Binary from VFP to .NET with wwDotnetBridge
  Rick Strahl
  Manni Borg
  Dec 2, 2021 @ 02:23pm

Well your syntax is definitely not right. I'm not sure what the (1) means in that context but whatever it is, it's unlikely to point at the right things either for the assignment in your code or the instance passed to InvokeMethod().

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Passing Binary from VFP to .NET with wwDotnetBridge
  Manni Borg
  Rick Strahl
  Dec 2, 2021 @ 11:28pm

Sorry there was a mistake in the code posted, here is what I tried to do:

loBridge.InvokeMethod(oData.XmlFile, "passBinary", CREATEBINARY(testXmlFile))  && Error: System.DBNull.passBinary wasn't found

XmlFile is defined as

public byte[] XmlFile { get; set; }

in the C# assembly.

Gravatar is a globally recognized avatar based on your email address. re: Passing Binary from VFP to .NET with wwDotnetBridge
  Rick Strahl
  Manni Borg
  Dec 3, 2021 @ 10:39pm

Looks like oData.xmlFile is null. So that isn't valid.

+++ Rick ---

© 1996-2024