• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Creating an instance error

We have a "dll" code that's written in a proprietory language. It's like VB4 something.
Anyway, I want to use methods of this COM dll.

I did this: (i'm new to C# but want to try it in C# before I go to VB.Net)
I right-clicked on References, found that dll and added it to the References. For example ABCD
In the code I have:
using System.Runtime.InteropServices;
namespace whatever
 {
   public partial class _Default : System.Web.UI.Page {
     ....
      protected void Button1_Click(object sender, EventArgs e)
        {
           ABCD._DlcD myTest2 = new ABCD._DlcD();
            myTest2.PScreen("A01", 07, 07, 009, 009, "Tim", "Somewhere", 009, "ENGLISH", "DMASTER", 1);
        }
}
 }

*** why do I get this error when I compile..what am I missing:
Cannot create an instance of the abstract class or interface 'ABCD._DlcD'      
0
Camillia
Asked:
Camillia
  • 2
  • 2
1 Solution
 
Gautham JanardhanCommented:
as the error says ABCD._DlcD will be abstract class or interface u will have to instantiate it into a class derived from ABCD._DlcD ;
0
 
CamilliaAuthor Commented:
not sure what u mean...do u have an example?
0
 
Gautham JanardhanCommented:
consider these two classes
public abstract class AbstractClass
      {
            public virtual void FunctionToOveride();
      }
      public class ConcreteClass : AbstractClass
      {
            public override void FunctionToOveride()
            {
                  Console.Write("Hi there");
            }

      }

if u try

AbstractClass NewObject = new AbstractClass() it wil throw the error -> Cannot create an instance of the abstract class or interface

the correct way would be
AbstractClass NewObject = new ConcreteClass ();


0
 
CamilliaAuthor Commented:
thanks, let me try and post back
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now