Solved

Use COM component that contains only Interfaces, no CoClass

Posted on 2008-10-16
13
486 Views
Last Modified: 2010-04-21
I'm trying to create a Class Library that will be used by a COM component.  Within my COM component, I have made references to three TLB files. One of these TLB files contains only a Interface definition with two methods, no CoClass. The interface is IWFMUpdater, in the code snippet. It is from UpdaterRuleInterface. However, I have compile errors. I get the errors:

error CS0539: 'UpdaterRuleInterface.IWFMUpdaterRule.Validate' in explicit interface declaration is not a member of interface
error CS0535: 'Pluggable.Pluggable' does not implement interface member 'UpdaterRuleInterface.IWFMUpdaterRule.Validate(string, UpdaterClient.UpdaterTransactionCoClass)'


using System;

using System.Runtime.InteropServices;
 

using UpdaterClient;

using UpdaterRuleInterface;
 

namespace Pluggable

{

	/// <summary>

	/// Summary description for Class1.

	/// </summary>

    [ClassInterface(ClassInterfaceType.AutoDispatch)]

    public class Pluggable : IWFMUpdaterRule

	{

		public Pluggable()

		{

			//

			// TODO: Add constructor logic here

			//

		}

        

        // IWFMUpdaterRule Implementation

        void UpdaterRuleInterface.IWFMUpdaterRule.Validate(string con, UpdaterClient.UpdaterTransactionCoClassClass transaction) 

        {

        }
 

        void IWFMUpdaterRule.GetConfigurationInfo(string dbAlias, ref string config)

        {

        }
 

        

        

        public void lValidate(string config) 

        {

            string ComputerName = Environment.MachineName;
 

            // Updater transaction is used to connect to the Updater. 

            UpdaterTransactionCoClassClass transaction = new UpdaterTransactionCoClassClass();

            transaction.BDE_Alias = "DBAlias";         // Database alias

            transaction.ComputerID = ComputerName;  // Name of computer from where the transaction is submitted

            transaction.MaxErrorCount = 50;

            transaction.SourceApplication = "Updater Application";

            transaction.UserName = "TCSADMIN";

            transaction.Password = "qqq";

            IWFMUpdaterRule.Validate(config, transaction);

        }

	}

}

Open in new window

0
Comment
Question by:freename
  • 10
  • 3
13 Comments
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22734605
Can you show us your declaration of the inteface from the other file too?
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22734688
Try changing these:

UpdaterRuleInterface.IWFMUpdaterRule.Validate(...)

IWFMUpdaterRule.GetConfigurationInfo(..)

to:

Validation(...)
GetConfigurationInfo(...)

0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22734734
Yep.

When I declare something like listed below, I get a compile error
public Interface ITest{

   public void test();

}
 

public class Test : ITest{

   public void ITest.test(){  <--- Compile error here

   }

}
 

public class Test2 : ITest{

   public void test(){  <--- No Compile error

   }

}

Open in new window

0
 

Author Comment

by:freename
ID: 22735019
RishadanPort,
Thanks for the quick reply. I will try to answer your questions.

The other two files don't require the Interface. I'm able to use CoClass. The "using" statement "using UpdaterRuleInterface" is the one with the interface. Looking at the TLB with OLEViewer gives:
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: UPDATE~1.TLB

[
  uuid(5BA2D0DA-37F3-4B3F-8A7B-63A7B401FC5E),
  version(1.0),
  helpstring("Aspect eWFM Updater Rule Interface Type Library")
]
library UpdaterRuleInterface
{
    // TLib :     // TLib : Updater Client Type Library : {92CF2C53-4B21-11D1-9329-00A024BF0B84}
    importlib("upclient.dll");
    // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");

    // Forward declare all types defined in this typelib
    interface IWFMUpdaterRule;

    [
      odl,
      uuid(AB2BCAED-4C39-4748-B32F-78A11EE48400),
      version(1.0),
      dual,
      oleautomation
    ]
    interface IWFMUpdaterRule : IDispatch {
        [id(0x000000c9)]
        HRESULT GetConfigurationInfo(
                        [in] BSTR DBAlias,
                        [in, out] BSTR* ConfigString);
        [id(0x000000ca)]
        HRESULT Validate(
                        [in] BSTR ConfigString,
                        [in] IUpdaterTransaction* Transaction);
    };
};

I have also tried every combination of method implementation I can think of, including what you suggest. Still get the error. Funny thing is, I only get it for the Validate method. The "GetConfigurationInfo" doesn't throw an error. So, I don't know what makes Validate different. Maybe you can see something in the IDL file that I don't.
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22736013
Is the compile error the same even with my change?
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22736036
Can you also try commenting out these functions in the pluggable class:

Validate, GetConfigurationInfo

and tell us the error code you get?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:freename
ID: 22761459
RishadanPort,
Sorry for the dealy. Had to do some other stuff. When I comment out the methods, I get the CS0535 error.

Here is what I have to do. There is an existing Updater COM object. I can't tell you what it was written in. What I'm trying to develop is a pluggable rule that the Updater COM object uses to validate stuff. The SDK for the Pluggable Rules (what I'm attempting to write) states "
A plug-in rule is manifested via a DLL with a COM interface. This COM interface is invoked by Updater as part of its rule checking. The COM interface must provide the following functions: GetConfigurationInfo() and Validate().

These two methods are defined in the TLB file UpdaterRuleInterface.tlb. It is one of the references I made.  But now I wonder if I really need to make a reference to that TLB. Can I just create my own Interface and define it using InterfaceTypeAttribute?
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22762579
Is this a runtime error or a compile error?
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22762586
Ah I see it is a compile error... just wanted to make sure of that.
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22762714
Try doing these to lines like this:
        void IWFMUpdaterRule.Validate(string con, UpdaterClient.UpdaterTransactionCoClassClass transaction) 

        {

        }

 

        void IWFMUpdaterRule.GetConfigurationInfo(string dbAlias, ref string config)

        {

        }

Open in new window

0
 
LVL 6

Accepted Solution

by:
RishadanPort earned 500 total points
ID: 22763487
Also try this passing the second parameter as a ref:

IWFMUpdaterRule.Validate(string con, ref UpdaterClient.UpdaterTransactionCoClassClass transaction)
0
 

Author Closing Comment

by:freename
ID: 31506821
I will give this to you as you are the only one that answered. I had to move on and do this using VB6. I guess MS decided that COM would suddently die when .Net came out. But, thanks for your help.
0
 
LVL 6

Expert Comment

by:RishadanPort
ID: 22864598
Sorry man. I wasn't sure how else to help. I hope you solved the problem
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now