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 / September 2004

Tip: Looking for answers? Try searching our database.

C++ projects and output groups

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gregory Nickonov - 03 Sep 2004 19:38 GMT
Hi,

I have a managed package that deals with project output groups. Output
groups are accessed through IVsProjectCfg2.get_OutputGroups() method using
following code:

private IVsOutputGroup[] GetOutputGroups( IVsProjectCfg2 config )
{
   uint[] elementCount = new uint[1];
   IVsOutputGroup[] groups;

   NativeMethods.ThrowOnFailure( config.get_OutputGroups( 0, null,
elementCount ) ); // Getting total number of output groups
   groups = new IVsOutputGroup[elementCount[0]]; // Allocating target array
   NativeMethods.ThrowOnFailure( config.get_OutputGroups( elementCount[0],
groups, null ) ); // Filling out array

   return groups;
}

Everything is OK with C#, VB and even Setup projects, but as soon as I pass
configuration object from C++ project I've got an NullReferenceException at
the second call to get_OutputGroups. First call reports that this
configuration has 5 output groups, second call (to fill array) fails. I just
can't understand where the problem is. Another strange thing is that if (in
debugger) I'll change elementCount[0] from 5 to 1 just before second call
(when array is allocated) than reference to one of the groups is placed to
groups array. I've experimented with other values (from 2 to 5 :-) but in
all other cases error is reported by the call.

Can anybody point me to workaround or provide any hint?

Regards,
Gregory.
Gregory Nickonov - 03 Sep 2004 19:47 GMT
Never mind, I've just solved the problem :-) For those who is interested see
description below.

Quote from VSIP documentation on get_OutputGroups() method:
 celt
 [in] Requested number of output groups to be returned.
 prgpcfg
 [in, out, size_is(celt)] Pointer to an array of IVsOutputGroup interface
pointers.
 pcActual
 [out, optional] Pointer to the actual number of output groups returned.
If I got it right, than "pcActual" parameter is optional and can be set to
null, as I did. But that's not the case for C++ projects. Changing the
second call to be like:

NativeMethods.ThrowOnFailure( config.get_OutputGroups( elementCount[0],
groups, elementCount ) );

solved the problem.

Regards,
Gregory.

"
> Hi,
>
[quoted text clipped - 11 lines]
>     groups = new IVsOutputGroup[elementCount[0]]; // Allocating target array
>     NativeMethods.ThrowOnFailure( config.get_OutputGroups(
elementCount[0],
> groups, null ) ); // Filling out array
>
[quoted text clipped - 15 lines]
> Regards,
> Gregory.

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.