First, the parameters are correct. You don't even need to use
MarshalAs
for string, as this marshaling is the default. (By the way, it is allowed and recommended to omit "Attribute" from names like "MarshalAsAttribute" at the place of attribute application.)
The only reason of unbalance stack I could possibly see is calling convention. In this case, it could be C (first calling conventions candidate). So, try this first:
DllImport("PIRLIB.dll", EntryPoint = "pir_learnCCF", CallingConvention = CallingConvention.Cdecl)]
public static extern void pir_learnCCF(string serial, byte state);
See:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.callingconvention.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.callingconvention.aspx[
^].
—SA