When I do [MarshalAs (....)].
It says MarshalAs is not found, related namespace missing or not referenced, something like that.
1. How and where do I find System.Runtime.InteropServcies.dll?
2. what namespace I can find the MarshalAs?
thanksHi,
MarshalAsAttribute is part of System.Runtime.InteropServices namespace which resides in Mscorelib.dll assembly. No need for additional reference.
thanks for the reply,
[code]
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
[DllImport("Kernel32.dll", LastAccessError=true)]
public static extern IntPtr FindFirstFile(string fileName, [ In, Out ] FindData findFileData);
}
[StructLayout(LayoutKind.Sequential)]
public class FindData
{
public int fileAttributes = 0;
public int creationTime_lowDateTime = 0;
public int creationTime_highDateTime = 0;
public int lastWriteTime_lowDateTime = 0;
public int lastWriteTime_highDateTime = 0;
public int lastAccessTime_lowDateTime = 0;
public int lastAccessTime_highDateTime = 0;
public int nFileSizeHigh = 0;
public int nFileSizeLow = 0;
public int dwReserved0 = 0;
public int dwReserved1 = 0;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 256)]
public string fileName = null;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 14) ]
public string alternateFileName = null;
}
[/code]
The above code is just a simple class that i do and it is from msdn.
compile error stops at [MarshalAs, saying Class1.cs(30): The type or namespace name 'MarshalAs' could not be found (are you missing a using directive or an assembly reference?)
what is the problem?
thanks
0 comments:
Post a Comment