PC Review


Reply
Thread Tools Rate Thread

Dynamic Class Loading & System.__COMObject

 
 
Angelos Karantzalis
Guest
Posts: n/a
 
      22nd Feb 2005
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:]


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Byte[] And System.__ComObject in AD LDAP Browser =?Utf-8?B?RGFycmVuIChVSyk=?= Microsoft VB .NET 0 1st Nov 2007 08:33 PM
System.Byte[] And System.__ComObject in Active Directory LDAP brow =?Utf-8?B?RGFycmVuIChVSyk=?= Microsoft Dot NET 0 1st Nov 2007 08:09 PM
dynamic class loading KC Eric Microsoft C# .NET 4 26th Mar 2005 04:16 PM
Problem with Dynamic class loading. Parag Joshi Microsoft Dot NET 0 26th Dec 2003 04:39 AM
.Net (C#) Dynamic class loading question db404 Microsoft Dot NET 1 13th Jul 2003 12:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:15 PM.