A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

VSTO calling unmanged function



 
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old September 8th 09, 04:21 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default VSTO calling unmanged function

What if instead of passing a StringBuilder object you pass a string and
Marshal it as UnmanagedType.BStr, does that work?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"scot_paro" scot_paro.3y5jco@invalid wrote in message
news:scot_paro.3y5jco@invalid...

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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
calling ms word Southern at Heart Outlook and VBA 1 February 25th 08 06:16 AM
contacts calling Jeff Outlook - Using Contacts 3 March 1st 07 10:39 PM
How to use "Look up Outlook Contact" function with code? VSTO 2005 David Webb Outlook and VBA 1 July 28th 06 07:29 PM
Calling all MVPs Rob Outlook - General Queries 1 July 25th 06 04:04 AM
Calling For Backup! Ron Outlook Express 2 July 14th 06 05:42 PM


All times are GMT +1. The time now is 08:57 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.