Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / August 2004

Tip: Looking for answers? Try searching our database.

Passing unmanaged DTE interface to managed code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Foust - 09 Aug 2004 19:01 GMT
I have some DTE-related work I need to do in my VSIP project that is going
to be much easier to implement from managed code instead of unmanaged C++.
How do I pass the DTE interface pointer from my unmanaged code into a
managed assembly?  I implemented a managed C++ dll that exports a function
my unmanaged code calls to pass in the DTE interface pointer as an unmanaged
void*.  I haven't been able to figure out how to box the interface pointer
back into a managed DTE object?  I tried using
System.Reflection.Pointer.Box(pv, type) to box the pointer, but it gives me
an argument-exception because the type refers to an interface and not a
pointer.

Is there an easier way for managed code to get at the DTE interface?  I
tried using GetActiveObject, which works just fine as long as there is only
one instance of VS.NET running.  If there are multiple instances running
then it is possible that the wrong DTE interface will be returned.  From
what I see in the documentation, the only way to get at the DTE interface
(or any other interface) is to either be derived from IServiceContainer or
have been given an IServiceProvider interface, neither of which is true for
my simple managed dll.
"Ed Dore [MSFT]" - 11 Aug 2004 01:52 GMT
Hi Bill,

Is the managed DLL that contains the export a mixed mode DLL? Generally
speaking, I'd avoid passing the DTE object as a void*. From your unmanaged
code, you probably have an IDispatch* on the DTE object, just pass this as
an IDispatch* or IUnknown*. On the managed side, you can use the
Marshal.GetObjectFromIUnknown to retrieve the managed representation of the
DTE object.

Let me know if that doesn't make sense.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Brett Keown [MSFT] - 16 Aug 2004 18:06 GMT
Hi Bill,

Did you have any follow-up questions for Ed in regards to this post?

Brett Keown
Microsoft Support
brettke@online.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.
Allen Denver [MS] - 26 Aug 2004 00:32 GMT
See my blog entry titled Can Addins & managed packages live together?;
Getting to the DTE object model from a package at
http://blogs.msdn.com/allend/archive/2004/03/31/104829.aspx for info on how
to accomplish this in managed code.  You don't actually get the native dte
interface pointer, you just query for the DTE as a service.

Good luck,
Signature

Allen Denver (Microsoft)
http://blogs.msdn.com/allend
-- This post is provided 'AS IS' with no warranties and confers no rights.

> I have some DTE-related work I need to do in my VSIP project that is going
> to be much easier to implement from managed code instead of unmanaged C++.
[quoted text clipped - 15 lines]
> have been given an IServiceProvider interface, neither of which is true for
> my simple managed dll.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.