473,748 Members | 10,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#, System.__ComObj ect casting problem

I have a program written in C# that handles communication between two
pieces of software. My problem only deals with getting a text array
from one program to this C# "Bridge". I can get the text array to the
bridge, where it is received as a system.object. My problem is casting
this system.object to a string array. The code I'm using is below.
System.Array advArgs = args as System.Array; //creates array for
parameters being received

object advCommands = advArgs.GetValu e(2); //gets the 3rd parameter
which is the array from the external software, stores it in
advCommands.

GCListOrArray GCarray = new GCListOrArray() ; //GCarray is new
GCListOrArray interface, this interface was written by the external
software develpoer for applications like this.

GCarray = (GCListOrArray) advCommands; //Convert advCommands to
GCListOrArray interface type

Basically, when I try to WriteLine, the compiler says that it cannot
cast System.__ComObj ect. I have tried everyway I know of casting it,
but had no luck. Any suggestions?

Thanks in advance.

Tyler

Aug 31 '06 #1
2 8742
Tyler,

I don't see why whis would work. Basically, you are trying to cast an
array type to this GCListOrArray type, which isn't possible, because the CLR
array types are just that, arrays of instances of that type, nothing else.

You need another way to convert the arry to a GCarray (really interface,
if it was defined in COM) class.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<st******@gmail .comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
>I have a program written in C# that handles communication between two
pieces of software. My problem only deals with getting a text array
from one program to this C# "Bridge". I can get the text array to the
bridge, where it is received as a system.object. My problem is casting
this system.object to a string array. The code I'm using is below.
System.Array advArgs = args as System.Array; //creates array for
parameters being received

object advCommands = advArgs.GetValu e(2); //gets the 3rd parameter
which is the array from the external software, stores it in
advCommands.

GCListOrArray GCarray = new GCListOrArray() ; //GCarray is new
GCListOrArray interface, this interface was written by the external
software develpoer for applications like this.

GCarray = (GCListOrArray) advCommands; //Convert advCommands to
GCListOrArray interface type

Basically, when I try to WriteLine, the compiler says that it cannot
cast System.__ComObj ect. I have tried everyway I know of casting it,
but had no luck. Any suggestions?

Thanks in advance.

Tyler

Aug 31 '06 #2
I'm new to C#, I got thrown on this project. I'm not sure if
GCListOrArray is defined in COM. How would I check to see if it were
defined?

Thanks, Tyler

Aug 31 '06 #3

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

Similar topics

0
1876
by: Angelos Karantzalis | last post by:
Hi y'all, here's a tricky one: I've written a wrapper around a Com Interop-generated assembly in C#. It's called SDEHandler & implements a previously defined interface, so that I can use it as a provider, and load instances of it dynamically. In other words, I use it as a "plugin implementation" of a well-known API (a Provider?). Inside it I create a DataSet, which gets filled with at least a column containing values of type SDEPoint,...
0
5623
by: Fidias Gil de Montes | last post by:
In a Distributed Windows application, I receive the following message when the client calls the server: ************** Exception Text ************** System.InvalidCastException: Unable to cast object of type System.__ComObject to type System.Data.DataSet. Server stack trace: at servidor.IclaseSvr.prueba2(DataSet ds) at
3
5282
by: Axel Strube-Zettler | last post by:
I'm stuck now for a whole afternoon with a little Interop problem: static object m_ovl = m_app.GetInterfaceObject("VL.Application.nn"); (m_app.GetInterfaceObject() returns the in-process VL Application) m_ovl is a System.__ComObject, and I can't find a way to cast or cenvert it to the correct datatype.
2
9154
by: Ron Dahl | last post by:
In Word VBA the expression "ActiveDocument.Paragraphs(1).Style returns "Heading 3" In VB.Net the expression "appWord.ActiveDocument.Paragraphs(1).Style" returns "{System.__ComObject} : {System.__ComObject}" How can I get vb.net to return "Heading 3" instead of "{System.__ComObject} : {System.__ComObject}". Thanks in advance for any help.
0
2675
by: woollymammoth | last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be an easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that record is named "Try". The VB script function accessing the record value is running on a web hosting server with ASP.Net 2.0 on a web page. Result always is it "can't convert from a Field to type 'String'". Printing out the SQL variable results in...
1
5824
by: woollymammoth | last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be a really easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that record is named "Try". The VB script function accessing the record value is running on a web hosting server with ASP.Net 2.0 on a web page. Result always is it "can't convert from a Field to type 'String'". Printing out the SQL variable results...
2
7437
by: les | last post by:
I have a c# class that I want to work, when compiled into a dll, either in asp.net or classic asp 3.0. It references System.EnterpriseServices and ASPTypeLibrary and as far as the dll used either an asp.net page or an asp page goes, it functions, apart from the following part which is meant to gather, for logging, request.servervariable objects When called by an asp page they return the string System.__ComObject instead of an i.p. address...
0
1445
by: dhaval321 | last post by:
Hello, Actually i am making plugin in spinfire software..And when i m using threading then the error of "Unable to cast COM object of type 'System.__ComObject' to interface type 'Actify.Xview3D.ISF_Node' comes........where Actify And Xview3D are namespaces whereas ISF_Node is the interface...Now please help me out from this problem...its urgent
0
1382
by: dhaval321 | last post by:
Hello, Actually i am making plugin in spinfire software..And when i m using threading then the error of "Unable to cast COM object of type 'System.__ComObject' to interface type 'Actify.Xview3D.ISF_Node' comes........where Actify And Xview3D are namespaces whereas ISF_Node is the interface...Now please help me out from this problem...its urgent
0
8991
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
9541
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
9370
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...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
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
4602
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...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.