Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unable to use ADODB Recordset in .NET C#

1 view
Skip to first unread message

Dave

unread,
Oct 18, 2002, 8:39:29 AM10/18/02
to
Well, it changed the error message, which is now:

"An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object."

Other than that, my problem remains the same as stated below.

---------------------------

Dave,

Can you create a new instance of recordset and then populate it by method
call?

e.g.,

private ADODB.Recordset rsFBillData = new ADODB.Recordset();
rsFBillData = oFBE.GetFBillData("482-389548-9");

If this does not work, then post your question again in
<microsoft.public.dotnet.framework.interop> thread.


Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.

---------------------------

A team at work has developed a VB 6.0 COM+ object that has a few rather
complex methods that I could use for my current project. Rather than
reinvent the wheel, I want to make a few method calls to their object from
.NET / C#. So I registered their object on my box with no problems. I tried
a test from VB 6.0, making a reference, then calling a method that I'm
interested in. It all worked great.

Then in .NET, I make a reference to this object too. I also reference ADODB
v2.7. Intellisense shows the properties, methods, ect... as I would expect.
Here's a code snippet that I wrote in C#:

----
fbeBusServerDotNet.clsFBEApplication oFBE = new
fbeBusServerDotNet.clsFBEApplicationClass();
ADODB.Recordset rsFBillData = oFBE.GetFBillData("482-389548-9");
if(!rsFBillData.EOF)
{
// do stuff
}
----

Now the problem. I can't access rsFBillData, the ADODB.Recordset. In
debugging, oFBE is instantiated and the method call succeeds. At this point
everything seems fine. A "Quick Watch" shows that rsFBillData contains the
values that I would expect, like RecordCount=1, EOF=false, ect... However,
the code fails at rsFBillData.EOF, complaining that "An unhandled exception
of type 'System.ExecutionEngineException' occurred in ...". In the
"Immediate Window", I learn the following:

----
?rsFBillData.EOF
error: 'rsFBillData.EOF' does not exist
?rsFBillData
{ADODB.RecordsetClass}
[ADODB.RecordsetClass]: {ADODB.RecordsetClass}
?rsFBillData.RecordCount
error: 'rsFBillData.RecordCount' does not exist
----

The errors contradict what "Quick Watch" is showing me. According to "Quick
Watch", the properties EOF and RecordCount have values of 'false' and '1'.

How can I get this working?


Dave

unread,
Oct 18, 2002, 10:14:50 AM10/18/02
to
I've isolated the problem even more. Our project in .NET requires a key
(.snk) file, so we used TBLIMP to generate a DLL for us to reference. The
command looks like this:

tlbimp "C:\PROJECTS\Freight Billing Entry\Working
Version\Release\Server\!fbeBusServer.dll" /out:"C:\PROJECTS\Freight Billing
Entry\Working Version\Release\Server\fbeBusServerDotNet.dll"
/keyfile:"C:\PROJECTS\PROCONTROL&CITYDISPATCH\Bin\ctii.snk"

Then we reference fbeBusServerDotNet.dll in .NET, and get the below results.
Note that !fbeBusServer.dll is the VB 6.0 COM+ object.

However, I created a test project that doesn't use a key, so I simply
referenced the VB 6.0 COM+ object directly. It works!

Then I used the TLBIMP command without referencing the keyfile (the test
project is not signed). The generated DLL fails just as listed below.

So how can I get TLBIMP to work so I can use this DLL signed?


"Dave" <nos...@yahoo.com> wrote in message
news:e9C4bLqdCHA.2524@tkmsftngp10...

Bharat Patel [MS]

unread,
Oct 18, 2002, 12:41:17 PM10/18/02
to
Hi Dave,

For C# projects, this is easy to fix.

In your project where you have unsigned COM-DLL, go to Project Properteis
window.
Open Common Properties -> General section.
In this section, there is a field called "Wrapper Assembly Key File".
Provide the Key file name here and your InterOP DLL will be signed by VS
NET IDE.

0 new messages