I believe you want "byref<Guid>" rather than "Guid*" and "&" rather than "&&".

By on 10/7/2009 11:39 PM ()

Yeah, your right. I was doing a pointer and not byref. BTW, from what I can tell the byref notation for the function prototype is "&" (The definition seems to verify this; "val HidD_GetHidGuid : Guid byref -> unit"). I had to guess that one... :)

Still no love though, I get the same error with the following:

[<DllImport("hid.dll")>]

extern void HidD_GetHidGuid(Guid& hidGuid)

let mutable hidClass = Guid.Empty

HidD_GetHidGuid(&hidClass)

Console.WriteLine(hidClass.ToString())

Console.ReadKey() |> ignore

I've looked over the interop section in Expert F# & Foundations of F#, the language spec, and The Google and cant seem to find anything.

BTW, not sure if this makes a difference but I'm developing in VS2008 on Server 08 R2 (Which is x64). I also tried it on another box running Windows7 Ent x32 with the same results.

So it doesent look like a 32/64 bit issue. The C# version runs fine in either OS.

Looks like this should just work.

Thanks for your input,

m

By on 10/8/2009 9:54 AM ()

It looks like it may also need

[<Out>]

on the parameter.

By on 10/8/2009 10:38 AM ()

Tried this but no dice:

[<DllImport("hid.dll")>]

extern void HidD_GetHidGuid([<Out>] Guid& hidGuid)

let mutable hidClass = Guid.Empty

HidD_GetHidGuid(&hidClass)

Console.WriteLine(hidClass.ToString())

Console.ReadKey() |> ignore

Its compiles but I get the same runtime exception when I make the call.

Thanks,

m

By on 10/8/2009 11:13 AM ()

Tried this but no dice:

[<DllImport("hid.dll")>]

extern void HidD_GetHidGuid([<Out>] Guid& hidGuid)

let mutable hidClass = Guid.Empty

HidD_GetHidGuid(&hidClass)

Console.WriteLine(hidClass.ToString())

Console.ReadKey() |> ignore

Its compiles but I get the same runtime exception when I make the call.

Thanks,

m

All three interop signatures you've posted in this thread work for me on my machine. What happens if you use the full path to the .dll in the attribute?

-Keith

By on 10/8/2009 12:51 PM ()

Ug, I'm such an idiot! I fired up ProcMon to see what dll it was hitting and I quickly realized that because one of the assemblies in my solution was called "hid.dll" it was hitting that instead of the one under system32, duh. I used the full path and voila! Good call Keith!

Sorry guys, thanks for all your help!

m

By on 10/8/2009 1:53 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper