Solved

Interface not registered - when calling ADODB.RecordsetClass.MoveFirst(  )

Posted on 2004-04-30
14
900 Views
Last Modified: 2010-05-18
There is (very long) story behind this question, but it really boils down to this error message:

Interface not registered   at ADODB.RecordsetClass.MoveFirst()
   at MyEventSink.ExchEventSink.Process_mail(String bstrURLItem)


I think I know WHY I am getting this message (it is a problem with COM) but HOW do I fix it?

I don't understand Interfaces well enough to know what to do to fix this problem.

From the research I have done so far....I know that an interface (in the world of COM) is essentially a contract that declares a class will implement certain methods or properties.

So apparently the method  ADODB.RecordsetClass.MoveFirst() is not registered with COM.  What can I do to fix this so COM will not complain?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
14 Comments
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10961367
Or rather, the CLASS that contains the method ADODB.RecordsetClass.MoveFirst() is not exposed to COM through an interface?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10961778
You should be able to, within the .NET world, access ADODB the same way that you do in VB6 through the COM interoperability.  How did you code this?

Bob
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10961893
I wrote it as a C# DLL  (Event Sink for Exchange Store):

The Event Sink does fire when e-mail arrives in the folder.  But when the line:

                        oRs.MoveFirst();

tries to execute, I get the error:

Interface not registered   at ADODB.RecordsetClass.MoveFirst()
   at MyEventSink.ExchEventSink.Process_mail(String bstrURLItem)



Here is my source:

using System;
using System.Runtime.InteropServices;
using System.Xml;
using CDO;
using ADODB;
using System.IO;
using System.Text;
using System.EnterpriseServices;




namespace MyEventSink
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      
      [GuidAttribute("E3ABDD7B-BCEB-4b67-BCA3-1C4FAA694763"), ProgIdAttribute("MyEventSink.ExchEventSink")]

      public class ExchEventSink: ServicedComponent , IExStoreAsyncEvents
      {            
            public string ClassID = "ACA4D805-DEE4-4233-B506-3C7FE269A025";
            public string InterfaceId = "34ECD3ED-A300-45e2-B831-8045E16EE232";
            public string EventsId = "09DB922D-7293-4ce4-ABAD-EC9B78D055A7";


            public ExchEventSink()
            {


            }

            #region IExStoreAsyncEvents Members

            public void OnSave(IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags)
            {
                  try
                  {
                        if(System.Convert.ToBoolean(lFlags))
                        {
                              FileStream fs = new FileStream(@"c:\temp\FLAG.log",FileMode.OpenOrCreate);
                              fs.Write(Encoding.ASCII.GetBytes(lFlags.ToString()),0,lFlags.ToString().Length);
                              fs.Close();

                              Process_mail(bstrURLItem);                        
                        }
                  }
                  catch (Exception ex)
                  {
                        throw (ex);
                  }
            }

            public void OnDelete(IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags)
            {
                  try
                  {

                  }
                  catch(Exception ex)
                  {
                        throw (ex);
                  }
            }
            #endregion


            public void Process_mail(string bstrURLItem)
            {  
                  try
                  {
                        ADODB.Connection oCn = new ADODB.Connection();
                        ADODB.Recordset oRs = new ADODB.Recordset();

                        ADODB.Fields oFields;
                        ADODB.Field oField;                                    
                        
                        string sFdUrl = "http://www.buyersfund.com/exchange/tom/FaxFailure";

                        FileStream fsURL = new FileStream(@"c:\temp\URLPassedIn.log",FileMode.OpenOrCreate);
                        fsURL.Write(Encoding.ASCII.GetBytes(sFdUrl),0,sFdUrl.Length);                              
                        fsURL.Close();
                  
                        oCn.Provider = "exoledb.datasource";
                        oCn.Open(sFdUrl, "", "", -1);  

                        if(oCn.State == 1)
                        {
                              FileStream fsgc = new FileStream(@"c:\temp\GoodConnection.log",FileMode.OpenOrCreate);
                              fsgc.Write(Encoding.ASCII.GetBytes("Good Connection"),0,"Good Connection".Length);                              
                              fsgc.Close();
                        }
                        else
                        {
                              FileStream fsbc = new FileStream(@"c:\temp\BadConnection.log",FileMode.OpenOrCreate);
                              fsbc.Write(Encoding.ASCII.GetBytes("Bad Connection"),0,"Bad Connection".Length);                              
                              fsbc.Close();
                        }


                        string strSql;
                        strSql = "";
                        strSql = "select ";
                        strSql = strSql + " \"urn:schemas:mailheader:content-class\"";
                        strSql = strSql + ", \"DAV:href\" ";
                        strSql = strSql + ", \"urn:schemas:mailheader:content-class\" ";
                        strSql = strSql + ", \"DAV:displayname\"";
                        strSql = strSql + " from scope ('shallow traversal of " + "\"";
                        strSql = strSql + sFdUrl + "\"') ";
                        strSql = strSql + " WHERE \"DAV:ishidden\" = false";
                        strSql = strSql + " AND \"DAV:isfolder\" = false";


                        oRs.Open(strSql, oCn,
                              ADODB.CursorTypeEnum.adOpenUnspecified,
                              ADODB.LockTypeEnum.adLockOptimistic, 1);

                        // As an example, you only retrieve the first message.
                        // You can use a while loop through each message.

                        // Get the first message.
                        oRs.MoveFirst();
                                                

                        // Get Recordset fields.
                        oFields = oRs.Fields;
                  
                        string sUrl;
                        oField = oFields["DAV:href"];
                        sUrl = oField.Value.ToString();

                        CDO.Message iMsg = new CDO.Message();
                        iMsg.DataSource.Open(sUrl, oRs.ActiveConnection,
                              ADODB.ConnectModeEnum.adModeReadWrite,
                              ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
                              ADODB.RecordOpenOptionsEnum.adOpenSource,
                              "", "");
                        
                        FileStream fs = new FileStream(@"c:\temp\TutVersionCDO.log",FileMode.OpenOrCreate);
                        fs.Write(Encoding.ASCII.GetBytes(iMsg.TextBody),0,iMsg.TextBody.Length);
                        fs.Write(Encoding.ASCII.GetBytes(iMsg.Subject),0,iMsg.Subject.Length);                        
                        fs.Write(Encoding.ASCII.GetBytes(iMsg.Sender),0,iMsg.Sender.Length);                        
                        fs.Close();


                        // Get message fields.
                        oFields = iMsg.Fields;

                  
                        FileStream fsf = new FileStream(
                              @"c:\temp\FieldsAndValues.log",FileMode.OpenOrCreate);
                        
                        for(int i = 0; i < oFields.Count; i++)
                        {
                              oField = oFields[i];
                              Console.WriteLine("{0} : {1}", oField.Name, oField.Value);
                              fsf.Write(Encoding.ASCII.GetBytes(oField.Name),0,oField.Name.Length);                        
                              fsf.Write(Encoding.ASCII.GetBytes(oField.Name),0,oField.Name.Length);                        
                        }
                        fsf.Close();

                        


                        oRs.Close();
                        oCn.Close();
                        oCn = null;
                        oRs = null;
                        oFields = null;
                        oField = null;



                        //Exoledb.IExStoreDispEventInfo pNewEventInfo = (Exoledb.IExStoreDispEventInfo)pEventInfo;
                        /// Get something off the new variable
                        ///
                        //ADODB.Record oRecord = new ADODB.Record();
                        //oRecord = (ADODB.Record)pNewEventInfo.EventRecord;


                  }
                  catch (Exception e)
                  {                        
                        FileStream fse = new FileStream(@"c:\temp\CDO_ERROR.log",FileMode.OpenOrCreate);
                        fse.Write(Encoding.ASCII.GetBytes(e.Message),0,e.Message.Length);
                        fse.Write(Encoding.ASCII.GetBytes(e.StackTrace),0,e.StackTrace.Length);                                                
                        fse.Close();
                  }                              
            }
      
            
      }
}
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 10976889
I need some more information.  Where is this happening?  ASP.NET or Windows Form?  Is MDAC installed on the machine?  Is it the right version?  How did the Interop library for ADO get created?

Bob
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10979549
TheLearnedOne:

I have tried so many things up until this point that it may be difficult to tell you exactly what I have done up to this point.

I wrote a C# DLL and deployed it to the Server running Exchange Server 2000.

Using regsvcs I registered the C# DLL with COM+ under Component Services.  The C# DLL is serving as an EventSink for Exchanage Server, or better said, for a particular "folder" on the Exchange Server.

Using Exchange Explorer I created an Event Registration in Exchange, which effectively runs the code inside the C# DLL whenever NEW mail arrives in the folder (i.e., a new mail is saved to the Exchange Store database)

The C# EventSink (the DLL) does indeed fire when new e-mail arrives.

The PROBLEM is......while yes some of the code inside the DLL is working....other code inside the same DLL is NOT working right.    Whenever I try to run the following line:

oRS.MoveNext(  );

An exception is generated.  I have a catch block for the exception, and this is the message that is being generated:

Interface not registered   at ADODB.RecordsetClass.MoveFirst()
   at MyEventSink.ExchEventSink.Process_mail(String bstrURLItem)


I interpret this message as meaning......the ADODB.DLL is not registered in COM.   Thus, any attempt to use methods exposed inside ADODB.DLL are going to fail.

But how do I fix this?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Everything I am talking about is happening on the Exchange Server.

MDAC 2.7 is installed.  I ran a utility provided by Microsoft that detects your version of MDAC.

The current ADODB.DLL I am using was found on my C drive and copied into the Release folder for my project, and then Referenced under Add Reference...then I browsed to my Release folder and found the ADODB.DLL I had copied in.


The ADODB.DLL came from this location on my hard drive:

C:\Program Files\Microsoft.NET\Primary Interop Assemblies

0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10979558
It was kind of weird that the adodb.dll did not begin with interop.

as in:

interop.adodb.dll


Not sure if that is a big deal or not.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10979586
Does your Solution Explorer show Interop.Adodb.dll in the References section?

Bob
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10980659
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 10980696
The path for the DLL is on the N: drive, and you said that you took it from C:\Program Files\Microsoft.NET\Primary Interop Assemblies.  Could it be that you have a compatibility issue here?

Also, Copy Local for the DLL is False.  You might want to change it to True, and look in the bin folder for the solution, and see what DLL gets copied there.

Bob
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10980914
The code resides on the N drive, but the DLL came from my C drive.

I copied the adodb DLL from my C drive to my N drive, then in References referred to the copy on the N drive (Release folder)

I changed Copy Local to true, then rebuild and redeployed my project......still same error as before.

Tom



PS:  Here is the result of regsvcs when I run it on ExchangeEventSinkClassLibrary.dll

C:\ees\bin\Release>call regsvcs /appname:MyEventSink ExchangeEventSinkClassLibra
ry.dll
Microsoft (R) .NET Framework Services Installation Utility Version 1.0.3705.288
Copyright (C) Microsoft Corporation 1998-2001.  All rights reserved.

Installed Assembly:
        Assembly: C:\ees\bin\Release\ExchangeEventSinkClassLibrary.dll
        Application: MyEventSink
        TypeLib: c:\ees\bin\release\ExchangeEventSinkClassLibrary.tlb

C:\ees\bin\Release>pause
Press any key to continue . . .


After running this......the application shows up in Component Services.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10980935
While I am wrting the ADODB code in the C# source code.......code completion IS invoked and it shows all the methods, etc. that are available via the adodb DLL (such as MoveFirst, MoveLast, etc)......so the C# DLL is seeing the ADODB dll just fine.

The break down seems to be when COM attempts to do the same thing at runtime.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10980995
LearnedOne:

One thing I have noticed is when I use regsvcs......the C# DLL I am registering DOES show up in Component Services under COM+ Applications.

If I look under Component Services........and drill down to the sub folders, etc. for my event sink......there is an Interface folder with items inside:

_ExchEventSink
_Object
IDisposable
IExStoreAsyncEvents
IManagedObject
IRemoteDispatch
System_EnterpriseServices_IServicedCompnoentInfo


What are these items......and if ADODB does not show up in this list.....is that cause for concern?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10986100
Unfortunately, I don't have much experience with Component Services and COM+ (only rudimentary knowledge).  At first glance, this appeared to be a simple problem, but now I realize that my first assumption was wildly misguided.  I am not sure that I can help you.

Bob
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10987811
TheLearnedOne:

No worries.

I'll see about deleting this Question.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question