473,892 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# to COM interop call returning an array of objects.

Hello,

The following code makes an interop call to a Com object
from C#:
//Create a Bom object
NewsBusObjsRCW. NewsBomObjClass myNewsBom = new
NewsBusObjsRCW. NewsBomObjClass ();

//Get the parts array
NewsBusObjsRCW. NewsPartObjClas s[] myNewsPartArray =
myNewsBom.theNe wsLocObject.the NewsRevObject.t heNewsPartObje
ctArray;
When I do a build I get the following error:

Property, indexer, or event 'theNewsPartObj ectArray' is
not supported by the language; try directly calling
accessor
methods 'NewsBusObjsRCW ._NewsRevObj.ge t_theNewsPartOb jectAr
ray()'
or 'NewsBusObjsRCW ._NewsRevObj.se t_theNewsPartOb jectArray
(ref NewsBusObjsRCW. NewsPartObj[])'
The interop calls work fine for other attributes of the
NewsRevObj (the following code works fine):

string myName =
myNewsBom.theNe wsLocObject.mth eNewsRevObject. theName
There is a problem with returning an array of objects.
Can anyone help me out with this?

Thanks,
Dave

Nov 15 '05 #1
2 2328
Man, this message looks like Deja Vu. I could have sworn I've seen it here
before. Do a search on Google groups and I'll bet money that you find your
answer.

Pete

"Interop newbie" <an*******@disc ussions.microso ft.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
Hello,

The following code makes an interop call to a Com object
from C#:
//Create a Bom object
NewsBusObjsRCW. NewsBomObjClass myNewsBom = new
NewsBusObjsRCW. NewsBomObjClass ();

//Get the parts array
NewsBusObjsRCW. NewsPartObjClas s[] myNewsPartArray =
myNewsBom.theNe wsLocObject.the NewsRevObject.t heNewsPartObje
ctArray;
When I do a build I get the following error:

Property, indexer, or event 'theNewsPartObj ectArray' is
not supported by the language; try directly calling
accessor
methods 'NewsBusObjsRCW ._NewsRevObj.ge t_theNewsPartOb jectAr
ray()'
or 'NewsBusObjsRCW ._NewsRevObj.se t_theNewsPartOb jectArray
(ref NewsBusObjsRCW. NewsPartObj[])'
The interop calls work fine for other attributes of the
NewsRevObj (the following code works fine):

string myName =
myNewsBom.theNe wsLocObject.mth eNewsRevObject. theName
There is a problem with returning an array of objects.
Can anyone help me out with this?

Thanks,
Dave

Nov 15 '05 #2
Dave,

So did you try what was suggested in the error message?

NewsBusObjsRCW. NewsPartObjClas s[] myNewsPartArray =
myNewsBom.theNe wsLocObject.the NewsRevObject.g et_theNewsPartO bjectArray();

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1999
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system: API Consumer ( Native C++/C# ) || ******************************************* * ...
4
1921
by: C# beginner | last post by:
Hi all I am trying to call my C# class library from COM. My C# library works perfectly in the .NET environment. I have registered my C# component using regasm and also placed it in the GAC. But for some reason my VBScript COM component can't interop with .NET. I am calling my .NET component as follows. Set GSF = CreateObject("CSAppName.ClassName")
2
2200
by: Boris | last post by:
The .NET documentation talks about blittable and non-blittable types. While objects of type System::Object* are non-blittable it doesn't say anything about objects of user-defined classes. All the COM interop examples I've seen always return objects of types of the System namespace. But what if you want to return an object of a user-defined managed class? public __gc class A { public: int i; A(int value) : i(value) { }
4
3412
by: DotNetJunkies User | last post by:
I am calling a VB6 dll from a vb.net windows application that returns an array of strings. My issue is it seems to truncate after a NULL character. For Example VB 6 is returning a string with the HEX value of 4E 31 00 00 01 00 20 20 20 20 20 00 00 00 20 20 20 31 32 30. But when it gets back to Vb.net all I have is 4E 31 or N1. Now I can return the same string as a return value of a function and I get it all. Please Help, Patrick Horn...
17
1867
by: Aaron | last post by:
I've got a doozie of a problem! I and others have been trying to figure this out for too long and I've come to the conclusion that I should probably look for some support.. Ok, I have a COM component written in C++ (I don't have the source just the binary) and am referencing it from VB. I would say about 99% of the functionality exposed by this COM component works fine from vb .net but I am having a problem calling a method which has a...
6
13431
by: Scott M. Lyon | last post by:
As I mentioned in my other post, I'm attempting to, using COM Interop so I can update existing VB6 code to (for several specific functions) return a Hashtable from a .NET library. I've had very little luck processing the Hashtable itself in VB6 (I can add a reference to the project so it knows what a Hashtable is, but I'm not having much luck looping through all objects in the Hashtable), so I decided to try a different idea.
5
2149
by: Richard Lewis Haggard | last post by:
I am trying to create multi-dimensioned arrays in conventional ASP pages and pass these arrays as arguments to functions that are in a C# interop assembly. ASP complains because it doesn't recognize that the created array is the same as the declared interface argument. The C# function is expecting to receive a 2 dimensioned array and is declared like this: public object InteropFunc( string s1, object arValues ); What should the ASP...
1
6021
by: Brendan Grant | last post by:
I’ve got a C# library that I’ve built into a COM component that will be used from a VC++ 6 application and while the creation of the COM object side of things seem to be working fine, using the object fully is another matter. On the C# side of things I’ve got an object defined like so: public class PID : IPID { private string type;
2
6738
by: Torsten Z | last post by:
Hi, I have tried several things to passing an array of objects or a Object Collection from .NET to VB6 but I can't get it work. Passing one object works fine, but more than one not. Has anybody a solution for that.
0
9981
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11241
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10836
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9644
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5857
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4683
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4279
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.