472,977 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 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
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 1795

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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.