Serviced Component, Excel and OleDbConnection.Open -
11-23-2005
, 02:07 PM
I'm using the OleDbConnection object to retrieve the contents of an
Excel Worksheet as a DataSet. This works fine when testing the
MyExcel.GetMonthly() method call.
When I call MyExcel.GetMonthly() from a Serviced Component, it bombs
when it tries to open the connection with "Object reference not set to
an instance of an object"
Code snippet:
OleDbConnection cn = new OleDbConnection(CnString);
cn.Open(); <-- Error occurs here
In an effort to isolate the problem I created a new class and called
MyExcel.GetMonthly() from it. Without ServicedComponent inheritence it
works fine. With ServicedComponent inheritence it worked until I added
the [ Transaction(TransactionOption.Required)] attribute, this threw
the error: "The ServicedComponent being invoked is not correctly
configured (use regsvcs to re-register)"
Re: Serviced Component, Excel and OleDbConnection.Open -
12-01-2005
, 10:20 AM
Guess I'll answer my own post
To ways to solve this problem:
1.) Put the assembly in the GAC
2.) Put the class that works directly with Excel in it's own
Class Library project. It doesn't need to inherit from
ServicedComponent,
only the rest of the Data Acess Layer needed COM+.