View Single Post
  #1  
Old September 7th 09, 05:38 PM posted to microsoft.public.outlook.program_addins
scot_paro
external usenet poster
 
Posts: 1
Default VSTO calling unmanged function


Hi, I'm really struggling with this so any help would be appreciated.
Outlook 2007, VS2008 Pro, VSTO 3, XP Pro x64 (dev) and x32 (test).

I've a C++ dll with a bunch of functions to handle the registry, some
custom authentication of the product, and some comms. I'd rather not
have to rewrite them in VB.NET/C# (I'm primarily a C++ developer).
There are extern "C" wrappers for the C++ calls.

The product was originally done in VBA, and everything works fine there


I've written an add-in and I've got the pinvoke stuff in place. I can
call Win32 functions - for testing, I pop up a message box and get the
system directory. All is well, works exactly as I'd expect.
However, when I call the functions in my unmanaged dll, the functions
get entered, but their arguments are garbage. I'm passing in a
StringBuilder to get a string of text back, but writing to the
StringBuilder parameter in the unmanged function (wchar_t*) causes an
access violation.
I've written a test project to make sure there's nothing funny with my
machine setup. I've got my unmanaged dll and a VB.NET console app. The
unmanaged functions return an int, accept a string, modify the string as
a side effect, and it all works fine.
But, when I do exactly the same thing in the add-in, it fails

Is there something I'm missing? Is this a CAS issue? Does VSTO just
not like unmanaged code?

Thanks.
-R.


--
scot_paro
http://forums.slipstick.com

Ads