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 / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

GetIDispatchForObject / exposing an object to a scripting client

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mclp - 28 Feb 2007 10:51 GMT
I have an object created within a C++/CLI class library that I want to
expose to a VBScript client. The class is declared as:
[ClassInterface(ClassInterfaceType::AutoDispatch)]
public ref class Foo
{
public:
// some methods...
};

The object is constructed using
Foo^ foo = gcnew Foo;

Then I try to get the COM/IDispatch interface to expose to Windows
Scripting Host, using:
Object^ my_obj = foo;
IntPtr aDisp = Marshal::GetIDispatchForObject(my_obj);  //
InvalidCastException here!

This results in System.InvalidCastException. Any ideas why?
mclp - 28 Feb 2007 17:27 GMT
It's working now.. Seems I also needed to set attribute (I thought it
was the default):
[ComVisible(true)]
PLS - 02 Mar 2007 05:48 GMT
> It's working now.. Seems I also needed to set attribute (I thought it
> was the default):
> [ComVisible(true)]

It WAS the default. It's not in VS2005. This is an improvement, IMHO,
although nasty if you didn't happen to read the section on breaking
changes.

   ++PLS

Rate this thread:







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.