E319 No overloaded constructor with 2 parameters for type "MarshalAsAttribute"

Is this an Oxygene bug or by your design that attributes cannot be constructed with more than one parameter?

It is try for StructLayout as well as for MarshalAs

I am trying to port this c# example to a similar idea in my Oxygene project:

[StructLayout(LayoutKind.Sequential,
Pack = 1, CharSet = CharSet.Unicode)]
public struct DISPLAY_DEVICE
{
    public int cb;
    [MarshalAs(
    	UnmanagedType.ByValArray,
    	SizeConst=32)]
    	public char[] DeviceName;
    [MarshalAs(
    	UnmanagedType.ByValArray,
    	SizeConst=128)]
    	public char[] DeviceString;
    public int StateFlags;
    [MarshalAs(
    	UnmanagedType.ByValArray,
    	SizeConst = 128)]
    	public char[] DeviceID;
    [MarshalAs(
    	UnmanagedType.ByValArray,
    	SizeConst = 128)]
    	public char[] DeviceKey;
}

			[StructLayout(LayoutKind.Sequential)]
			MyTestRec = public record	
				public
				[MarshalAs(UnmanagedType.I2)]newStripHebrewExport: INT;	// compiles fine
				[MarshalAs(UnmanagedType.SafeArray, VarEnum.VT_I2)]printInfo: PrintInfoArrayOfInt16; // Error

No matter what the second argument looks like in both attributes I am getting error E319.

Any ideas?

https://msdn.microsoft.com/en-us/library/vstudio/system.runtime.interopservices.marshalasattribute(v=vs.100).aspx

MarshalAsAttribute only has two .ctors as far as i can tell, neither of them takes two parameters, but only one.

You can initialize properties as part of the constructor call, but the syntax for that is :=, e.g.

[StructLayout(LayoutKind.Sequential, Pack := 1, CharSet := CharSet.Unicode)]

(Pack = 1 would be a boolean expression comparing an unknown identifier Pack to 1. Contrast that to C#, where = is the assignment operator, and == the equality one).

If you select the value property of the MarshalAsAttribute link you sent, you can see that there are CustomMarshallers. Selecting this get you to this link that indicates the ability to have more than one agrument, to further identify the variable.

https://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&k=k(System.Runtime.InteropServices.UnmanagedType);k(DevLang-Csharp)&rd=true

Many examples look like the c# example above - more than one argument.

Thank you for the StructLayout example. It compiles.

For the one that fails you want:

[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType := VarEnum.VT_I2)]

instead of:

[MarshalAs(UnmanagedType.SafeArray, VarEnum.VT_I2)]