In a full trust, OOB app, I need to be able to open a file (such as a PDF or tiff) through PInvoke.
The PInvoke.net site gives this as the signature:
[DllImport("kernel32.dll", BestFitMapping = false, ThrowOnUnmappableChar = true)]
static extern int OpenFile([System.Runtime.InteropServices.MarshalAs(UnmanagedType.LPStr)]string lpFileName, out OFSTRUCT lpReOpenBuff, OpenFileStyle uStyle);
However, when I drop this into a test Silverlight App, VS flags the OFStruct as "Cannot resolve symbol"
OpenFileStyle also gets flagged the same way.
How do I modify the signature so it can be used?
Ok, I get it now. OFStruct is a "User Defined Type" which needs to be defined in the project in which the PInvoke call is being used.
On the PInvoke.net site, it gives the C# code for the struct. So I copied and pasted into the app. Then the Signature found it and I was able to use the PInvoke.
The same applied to the OpenFileStyle enum.
Greg