I'm trying to implement an interface I created, in a VisualAPL class. When I instantiate the class directly, the methods and properties work. When I instantiate the class and cast it to the interface, the methods and properties throw exceptions.
The code is below. Any ideas what is wrong?
The interface, written in C#:
using
System;
using System.Collections.Generic;
using System.Text;
namespace TestInterface3{
public interface ITest{
Int32 LeftArg {get; }
Int32 RightArg {get; }
Int32 AddArgs(Int32 dummy);
}
}
The class, written in VisualAPL
#region
Using directivesusing
System;using
System.Collections.Generic;using
System.Text;refbyfile
@"c:\temp\testinterface3.dll";using
TestInterface3;#endregion
namespace
VisualAPLTest{ public class VisualClass : ITest{
// Private variables.
private Int32 m_leftarg;
private Int32 m_rightarg;
// The constructor.
public VisualClass(Int32 left, Int32 right){
// Store the variables.
m_leftarg ← left
m_rightarg ← right
}
// The two properties.
public property LeftArg {
get { return m_leftarg; }
}
public property RightArg {
get { return m_rightarg; }
}
// The public method.
public Int32 AddArgs(Int32 dummy){
return m_leftarg + m_rightarg;
}
}
}
The calling code that works is:
VisualAPLTest.VisualClass testClass = new VisualAPLTest.VisualClass(3, 5);
The calling code that fails is:
TestInterface3.ITest testClass = new VisualAPLTest.VisualClass(3, 5);
I'm getting the error An unhandled exception of type 'System.Exception'
occurred in VisualAPLTest.dll
Thanks for your help. Chris.