471,337 Members | 1,161 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

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

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 =
throw new ConfigurationException("Unknown Data Source Type:
string strClassName = descriptor.HandlerClass;
string strAssemblyName = descriptor.HandlerAssembly;
//Instantiate an ActionHandler for the given data source name ...
ObjectHandle oPntr = Activator.CreateInstance(strAssemblyName,
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++){
int index = 0;
object[] values = new object[rs.TableDesc.FieldCount+1];
// try to get the SHAPE from the recordset ...
Field shape = rs.Fields.Item("SHAPE");
object val = shape.Value;
Console.Out.WriteLine("SHAPE is a point? {0}", (val is
values[(values.Length-1)] =
}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;
}catch(Exception e){
Console.WriteLine("Exception while parsing rs: {0}", e.Message);
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

Jul 21 '05 #1
0 1724

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Angelos Karantzalis | last post: by
2 posts views Thread by Ron Dahl | last post: by
reply views Thread by Laurent Lequenne | last post: by
15 posts views Thread by Laurent Lequenne | last post: by
5 posts views Thread by bearophileHUGS | last post: by
reply views Thread by rosydwin | last post: by

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.