.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

COM interop: issue with C-style array of interface pointers

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

Dear community,

I have an issue with COM interop. I need to marshal a C-Style array of interface pointers.  I have changed IL to get this array marshaled correctly but I have issues accessing the array elements in the managed code.  Below are the IDL as well as my three tries that did not work.

Any suggestions?



[local] HRESULT Next([in] ULONG cElems, [out] ISomeObject *prgElems, [out] ULONG *pcFetched); \

View Complete Post

More Related Resource Links

Interop Marshalling of C++ with pointers in the structure

I have a vendor supplied dll that is written in C++. I need to use it in a C# application and am trying to use Interop. I have .h files and example .cpp code from the SDK, but I'm clearly in over my head. There are dozens of functions defined in this API, but if I can just get started on how to do this, I'd appreciate some guidance. My biggest headeache is pointers. Here's examples of the C++ and how far I got with C# (which i'm sure I totally botched) MY.h: part of the included headers typedef struct my_handle *MY_Handle; MY_API_PUBLIC int _cdecl MY_HandleCreate(MY_Handle *my_handle, const char *serial_number, const char *client_id, const char *product_type, const char *product_version); MY_API_PUBLIC int _cdecl MY_HandleDestroy(MY_Handle *my_handle); MY_API_PUBLIC int _cdecl MY_Init(void); MY_API_PUBLIC int _cdecl MY_Shutdown(void); MY.cpp: some example functions. int MY_Init(void); int MY_HandleCreate(MY_Handle *my_handle, const char *serial_number, const char *client_id, const char *product_type, const char *product_version); int MY_HandleDestroy(MY_Handle *my_handle); int MY_Shutdown(void); MY.cs: The class created to house the interop stuff. class MYClass { //MY_Init() [DllImport("ts.dll", SetLastError = true)] public static extern int MY_Init(); //MY_Shutdown() [DllImport("ts.dll", SetLastError

How to pass double pointers for COM Interop via MethodInfo.Invoke ?

Hello, I need to make COM IntetrOp at runtime using reflections. My native COM Object's exposed methods have some parameters as pointers (DWORD*) and some double pointers (DWORD**) and some are user defined types(e.g SomeUDTType objSmeUDTType) and its pointer to pointer(i.e. SomeUDTType **pSomeUDTType). I need to pass pointers to pointers. For now how can I be able to populate "object" array as pointers to pointers of SomeUDTType. Working Example:      STDMETHODIMP MyCallableMethod(DWORD *value_1,BSTR *bstrName,WESContext **a_wesContext tlbImp.exe generated output:      DTINIDLLib.RuntimeCallingClass.MyCallableMethod(ref uint, ref string, System.IntrPtr) Regards UsmanMutlithreading

Problem : Need to make COM InterOp at runtime using reflections Passing Pointers as parameters?

Hello, I need to make COM IntetrOp at runtime using reflections. My native COM Object's exposed methods have some parameters as pointers (DWORD*) and some double pointers (DWORD**) and some are user defined types(e.g SomeUDTType objSmeUDTType) and vice versa its pointer(i.e. SomeUDTType *pSomeUDTType). Now for dynamic method invocation, we have single option for passing parameters as array of object i.e object[] and filling this array statically. But I need to pass pointers and references and pointers to pointers. For now how can I be able to populate object array as mixed data of simple data types, pointers or references and pointers to pointers. Working Example: Native COM exposed method : STDMETHODIMP MyCallableMethod(DWORD *value_1,BSTR *bstrName,WESContext a_wesContex Translated by tlbimp.exe (COMInterop) UDTINIDLLib.RuntimeCallingClass.MyCallableMethod(ref uint, ref string, UDTINIDLLib Now calling these methods at runtime using reflection at runtime, See here :        Assembly asembly = Assembly.LoadFrom("E:\\UDTInIDL\\Debug\\UDTINIDLLib.dll");         Type[] types = asembly.GetTypes();         Type type = null;    //foreach (Type oType in types)         {             try      &nb

WCF - Apache Rampart Interop Issue

Hi all, First of all, I would like to say that I am a Java developer and yet have no experience or knowledge about .Net or WCF. Recently, I had to develop an Axis2/Rampart client to a service written in WCF. The security Policy of the service is like the following; <wsp:ExactlyOne> <wsp:All> <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> <wsp:Policy> <sp:InitiatorToken> <wsp:Policy> <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> <wsp:Policy> <sp:WssX509V3Token10 /> </wsp:Policy> </sp:X509Token> </wsp:Policy> </sp:InitiatorToken> <sp:RecipientToken> <wsp:Policy> <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never"> <wsp:Policy> <sp:WssX509V3Token10 /> </wsp:Policy> </sp:X509Token> </wsp:Policy> </sp:RecipientToken> <sp:AlgorithmSuite> <wsp:Policy> <sp:Basic256 /> </wsp:Policy> </sp:AlgorithmSuite> <sp:Layout> <wsp:Policy> <sp:Lax/> </wsp:Policy> </sp:Layout> <sp:IncludeTimestamp /> <sp:EncryptSignature /> <sp:OnlySignEntireHeadersAndBody /> </wsp:Policy> </sp:AsymmetricBindin

Multilingual Interface (Hindi) custom, webpart issue disappearance in share point 2007

Hi This is regarding the disappearance of custom  web parts in the multilingual site developed using MOSS 2007. The multilingual feature has been implemented using variations. All the custom web parts disappear when viewed after some time.  When the custom web parts are deployed to the site, it appears and they disappear when viewed after some time.  I have done local deployment as well as GAC deployment of the web parts dll. Both have the same effect. I have added the respective resource files for the web parts in the user control folder.    Thanks In Advance uttam  

Show WPF Window from any application via Com-Interop (OLE) Interface



I have a C# dll library which contains several utilities and WPF Windows.
I need to use these from an unmanaged application (actually written in Delphi 2009).
To do so I added an Ole interface to my dll.
In my initial call I start a thread and create an Application object in it whith its own Dispatcher.
Every time I need to show a WPF Window I do this by Invoking an the Applications thread.
This works so far, but seems to have a bit overhead when I try to open a WPF window for example.
Here is some of my code below:

  public interface IOleBridge
   bool Startup();

   void ShowWindow();

  // [ComSourceInterfaces(typeof(IOleBridgeEvents))]

Custom task user interface issue?



I have designed a custom task with a general view that holds a properties grid in a general view node. I have developed a custom editor to help user set the value of that property, Of Corse, I point my property to use that editor in design time using System.ComponentModel.EditorAttibuteClass . The editor appears as a modal dialog box. 

The issue is that when I put the Dock property of the properties grid to Fill then the ellipsis button doesn't appear but if I set the dock property to None then it appears (I mean the ellipsis button) and then I can click it to configure the property though that Modal dialog box.

So the question should I do additional steps to avoid this anomally

Thank you


The complexity resides in the simplicity

Array and Parameter Issue


SQL 2008

I have a column called Category that I am trying to filter on.  For example,

UserName           Category

JDoe                   Web Service, Business, Art, Entertainment

TJefferson           WebService, Sports, Business

BSelf                  Art

JBuffett               Politics, Shopping

The parameter getting passed in is (Web Service, Business, Art) so the records for JDoe, TJefferson and BSelf should be returned.  I can't figure out how to filter the records since the column in the table is a comma delimited string and the parameter is also.  I parsed the parameter into a table.  The data is not normalized because it is an import from a 3rd party application.  Here is what I have so far:

@Employee as

Microsoft.Office.Interop.Excel, Version= issue


Hello Friends,

I just got a new computer. Running VS2008 professional with MS Office 2010 on a Win 7 64-bit machine... 

I am using the Excel in my Web Site (NOTE: It is not a Web App so I do not have a csproj file in there) 

I am getting this error on my Windows 2003 Web servers (I have 2 of them): 

Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am assuming this has something to do with MS Office 2010 (office 2003 is installed on the servers) 

Microsoft.Office.Interop.Excel dll files from my directory and picked the version 11. This error message still comes up. 

Please HELP!!!! Thanks

If you have a n dimension array - how do you make it efficient? Do you run out of pointers?


I have a program that needs to create an array of arbitrary dimension.  In other words, if you pass 2 to a routine, that routine has to allocate a 2 dimensional array.  

So I wrote a routine to do this.  Lets assume for simplicity that every dimension has the same number of values.  And lets suppose that if we want to get a value out of this array, we pass the indices as an array too.

So for example, if we have a 3 dimensional array, and we want to access array(3,2,7) we pass an one dimensional array that has 3,2,and 7 in it.

I've found a way to do this, but it requires a lot of multiplications to find the index.  So I thought of an alternative, which is this:

Select Case n
 Case 1
  dim ArrayN(0) as integer
 Case 2
  dim ArrayN(0)(0) as integer
 Case 3
  dim ArrayN(0)(0)(0) as integer
 Case Else

Microsoft.Interop.Security.AzRoles registration issue


Hi All,

I am facing an issue with the Azroles dll when using with a Smart client application. 

Below is the complete exception:

Handling instance: fb5809ad-828d-45b6-873a-5dd0d4e65cf5

Date and time: 30/11/2010 11:47:00

Machine name: LDSCXA3

IP Address:

Current User: ITVPLC\AdarSree

Application Domain: ConMaint.exe

Assembly codebase: file:///M:/Program Files/Genersys/ConMaint.exe

ASP.NET repeater control - databind with style

even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nice looking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files.

A Simple and Extensible Radio Button Style GridView

The GridView is one of the significant controls in ASP.NET 2.0 and later versions. No doubt it reduces a lot of work time. However, customizing the GridView control is not an easy task. For example, it's hard to add a radio button column to the GridView. This article demonstrates the reason why a radio button column cannot act as normal and how to create a simple and extensible radio button GridView.

COM Interop in C# 4.0

Let's take a bit of a recap of how far we've come. We've chatted about dynamic binding in C# and how that all plays in with the DLR, and about named and optional arguments and how they change the way methods are bound. The only other major piece in C# 4.0 is this notion of COM interop. We chatted about how dynamic really is a gateway to interop with different object models and languages (ie interacting with dynamic languages, dynamic object models, javascript objects, HTML DOM etc), but in C# 4.0, we want to go a bit further and provide you a few more tools to help make your interop life much easier.

IsapiModule Error 500 Issue


I am about exhausted trying to figure out this error:

HTTP Error 500.0 - Internal Server Error

Description: The page cannot be displayed because an internal server error has occurred.

Error Code: 0x8007007b

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/ReportServer

Physical Path: c:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

When I enable Failed Request Tracing Rules and view the log output I am supposing that the actual problem is in the 2nd call where there are 2 backslashes before the actual filename in the specified path:


CALL_ISAPI_EXTENSION DllName="C:\Windows\Microsoft.NET\Framework\v2.0.50727\\aspnet_isapi.dll"


Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

Gmail style multiple Sign-in type combo...is it possible in asp.net?


I am developing a multi-company application and want my users to give the functionality like the following to switch companies.


Is this possible? then how?

Please help


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend