PInvoke from a class library

G

Guest

Cross-posting from the csharp newsgroup,

Are there any restrictions in using MarshalAs when p/invoke-ing from a class
library as opposed to a windows application in .NET CF 2.0?

The following code will not compile in a CF class library with the error
MarshalAs not found. The same code runs happily in both a Windows
Applicationa and a standard class library.

Is there a simple fix (other than pinvoking only from a .EXE file)?

using System.Runtime.InteropServices;
....
[DllImport("my.dll", CharSet = CharSet.Unicode)]
public static extern bool Test1([In, Out, MarshalAs UnmanagedType.U4)]
ref uint testValue)

Thanks,

Peter
 
G

Guest

The CF marshaler is not as robust as the desktop. That said, I'm not sure
why you're decorated this method. A ref uint will marshal by default as
you're trying to tell it, and CE is always Unicode.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top