'arg' : argument only valid for marshal of type System.Interop.UnmanagedType.CustomMarshaller
One of the arguments that was passed to the marshal attribute can only be used when the marshal format is System.Interop.UnmanagedType.CustomMarshaller.
The following sample generates CS0634:
class MyCustomMarshallerClass { } public class C { [dllimport("MyDll.dll")] public static extern void MyFunc( [marshal(System.Interop.UnmanagedType.I4, ComType="MyProgId")] // CS0634 // try the following instead // [marshal(System.Interop.UnmanagedType.CustomMarshaler, // ComType="MyProgId", // Marshaller=typeof(MyCustomMarshallerClass)) // ] object o); public static void Main() { } }