Edit: I found the relative page which is about C# and COM:How does the C# compiler detect COM types?
As in title, when I was converting a program in C# to IronPython, I couldn't create instance of a class.
The original C# program:IAgilent34980A2 host = new Agilent34980A();
The rewritten IronPython program:host = Agilent34980A()
The C# program works well, while the IronPython program gets an error as:
TypeError: Cannot create instances of Agilent34980A because it is abstract
Actually Agilent34980A() is an interface, so the error is reasonable.
My question is why it works in C#? The instance is also can't be created in C# which is an interface, right?
Addition:
The C# code is from test machine marker.
The IAgilent34980A2 definition part of source code is as following:
using Ivi.Driver.Interop;
using System;
using System.Runtime.InteropServices;
namespace Agilent.Agilent34980A.Interop
{
// IAgilent34980A interface. [TypeLibType(256)] [Guid("07678A7D-048A-42A6-8884-6CC8C575BD1F")] [InterfaceType(1)] public interface IAgilent34980A2 : IIviDriver { IAgilent34980AMeasurement Measurement { get; } IAgilent34980AVoltage Voltage { get; } // There are some similar functions following. }
}
The Agilent34980A definition part
using System.Runtime.InteropServices;
namespace Agilent.Agilent34980A.Interop
{
// Agilent34980A driver class. [Guid("07678A7D-048A-42A6-8884-6CC8C575BD1F")] [CoClass(typeof(Agilent34980AClass))] public interface Agilent34980A : IAgilent34980A2 { }
}
And IIviDriver definition part
using System;
using System.Runtime.InteropServices;
namespace Ivi.Driver.Interop
{
// IVI Driver root interface [TypeLibType(256)] [InterfaceType(1)] [Guid("47ED5184-A398-11D4-BA58-000064657374")] public interface IIviDriver { // Pointer to the IIviDriverOperation interface [DispId(1610678272)] IIviDriverOperation DriverOperation { get; } // Pointer to the IIviDriverIdentity interface [DispId(1610678273)] IIviDriverIdentity Identity { get; } // There are some similar functions following. }