473,473 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic Class Loading & System.__COMObject

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, a little struct I've written inside the
SDEHandler assembly, that describes a Point with X,Y doubles as fields.

My problem is that after the caller has executed a method resulting in that
DataSet on a dynamically loaded instance of the SDEHandler, the DataSet
seems to contain instead of SDEPoint instances, objects of type
System.__ComObject.

Casting that into an SDEPoint fails miserably, kust like my other efforts by
using System.Activator, ObjectHandle & ObjRef.

Can anyone point out anything that might be causing me all that frustration
???

Some code snippets:

1) The code that creates the SDEHandler instance in the first place:

public IActionHandler GetHandler(DataSource.DataSource source){
ActionHandlerDescriptor descriptor =
(ActionHandlerDescriptor)handlerDescriptors[source.Type];
if(descriptor==null)
throw new ConfigurationException("Unknown Data Source Type:
"+source.Type);
string strClassName = descriptor.HandlerClass;
string strAssemblyName = descriptor.HandlerAssembly;
//Instantiate an ActionHandler for the given data source name ...
try{
ObjectHandle oPntr = Activator.CreateInstance(strAssemblyName,
strClassName);
return (IActionHandler)oPntr.Unwrap();
}catch(Exception e){
throw new InitialisationException(e);
}
}
2) the code inside the action handler, that fills the DataSet:
... blah-blah ...
for(int i=0; i<rsCount; i++){
try{
int index = 0;
object[] values = new object[rs.TableDesc.FieldCount+1];
// try to get the SHAPE from the recordset ...
try{
Field shape = rs.Fields.Item("SHAPE");
object val = shape.Value;
Console.Out.WriteLine("SHAPE is a point? {0}", (val is
MapObjects2.Point));
values[(values.Length-1)] =
Utilities.ToSDEPoint((MapObjects2.Point)val);
}catch(Exception e){
Console.Out.WriteLine("Failed to get the SHAPE field: {0}", e.Message);
}
foreach(DataColumn col in tbl.Columns){
string strColName = col.ColumnName;
Field fld = rs.Fields.Item(strColName);
values[index] = (fld!=null)?fld.Value:null;
index++;
}
tbl.Rows.Add(values);
rs.MoveNext();
}catch(Exception e){
Console.WriteLine("Exception while parsing rs: {0}", e.Message);
break;
}
}
3) And the code that parses the DataSet & prints out the cols/values ...
public static void PrintDataTable(DataTable dt){
Console.Out.WriteLine("Printing Table:"+dt.TableName);
DataColumnCollection cols = dt.Columns;
foreach(DataRow row in dt.Rows){
for(int i=0; i<cols.Count; i++){
object val = row[i];
Console.Out.WriteLine("Val is a {0}", val.GetType().ToString());
Console.Out.WriteLine(cols[i].ColumnName+" = "+row[i]);
}
}
}

... apparently, all my SDEPoint instances have become System.__ComObject
instances somehow, that will refuse any type of casting, or simple way of
interrogation about properties

Cheers.
Angel
O:]
Jul 21 '05 #1
0 1828

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

Similar topics

9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
0
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...
2
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} :...
0
by: Laurent Lequenne | last post by:
Hello All, I'm currently developing a free windows Scrabble (in french :)) application that uses extensively the WebBrowser class of NET 2.0 for configuration, and data browsing. It works 100%...
15
by: Laurent Lequenne | last post by:
Hello All, I'm currently developing a free windows Scrabble (in french :)) application that uses extensively the WebBrowser class of NET 2.0 for configuration, and data browsing. It works 100%...
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
2
by: Bigi | last post by:
Hi, Please help, this has been driving me nuts for nearly 2 days now. This vb6 code works: Public oEng As New ebizEngine Public oMsg As ebizMessage Function EbizGetFromQueue() As String
5
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
0
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,...
0
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...
0
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.