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

**URL:** https://talk.remobjects.com/t/e319-no-overloaded-constructor-with-2-parameters-for-type-marshalasattribute/5955
**Category:** Oxygene
**Created:** [March 27, 2015, 1:47pm UTC](https://talk.remobjects.com/t/e319-no-overloaded-constructor-with-2-parameters-for-type-marshalasattribute/5955 "2015-03-27T13:47:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![OrlyM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@OrlyM](https://talk.remobjects.com/u/OrlyM)
#### Post date: [March 27, 2015, 1:47pm UTC](https://talk.remobjects.com/t/e319-no-overloaded-constructor-with-2-parameters-for-type-marshalasattribute/5955/1 "2015-03-27T13:47:56Z")

</div>

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:

```auto
[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?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 27, 2015, 2:08pm UTC](https://talk.remobjects.com/t/e319-no-overloaded-constructor-with-2-parameters-for-type-marshalasattribute/5955/2 "2015-03-27T14:08:21Z")

</div>

[https://msdn.microsoft.com/en-us/library/vstudio/system.runtime.interopservices.marshalasattribute(v=vs.100).aspx](https://msdn.microsoft.com/en-us/library/vstudio/system.runtime.interopservices.marshalasattribute%28v=vs.100%29.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).

---

<div class="post-metadata">

### Author: ![OrlyM](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@OrlyM](https://talk.remobjects.com/u/OrlyM)
#### Post date: [March 27, 2015, 2:35pm UTC](https://talk.remobjects.com/t/e319-no-overloaded-constructor-with-2-parameters-for-type-marshalasattribute/5955/3 "2015-03-27T14:35:47Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [March 27, 2015, 3:00pm UTC](https://talk.remobjects.com/t/e319-no-overloaded-constructor-with-2-parameters-for-type-marshalasattribute/5955/4 "2015-03-27T15:00:27Z")

</div>

For the one that fails you want:

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

```

instead of:

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

```
