473,416 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

C# class not implementing VB.NET interface

OK...I must be missing something...can someone tell me what I'm not doing properly...

First, create an assembly with a single interface in VB.NET as follow

Public Interface IDo
Function Bark(ByVal lVolume As Long) As Strin
End Interfac

Pretty simple..

Now...in a second (C#) assembly...create a class that implements that interface...like so..

using System
using DogInterface

namespace CSImplemete

/// <summary
/// Summary description for Class1
/// </summary
public class Husky : IDo

public string Bark(long lVolume

return "Deep Bark!! at " + lVolume.ToString() + " level"


This is also pretty simple (as you can see...the namespace for the IDog is DogInterface...that is also the name of it's assembly). This all compiles very well...I have a single solution with both projects in it

Now...I create a new assembly...a VB.NET windows application in the same solution that will use that Husky Class. I have referenced the two assemblies from above and placed a single button on the form

In a click event for the test button, I have the following code

Imports CSImplemete
Imports DogInterfac

Public Class Form
Inherits System.Windows.Forms.For

[" Windows Form Designer generated code "

Private Sub cmdBark_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBark.Clic

Dim objDog As CSImplemeter.Husk

End Su

End Clas

The problem is that I get an error on the line of code that dimension the objDog. The squiggly line goes under the CSImplementer.Husky and says..

"Reference required to assembly 'DogInterface' containing the implemented interface 'DogInterface.IDog'. Add one to your project.

But...I already added it to the project. Am I missing something here??...or is there a real problem??

BTW...I am using .NET Enterprise Architect version 7
Jul 21 '05 #1
5 2162
> "Reference required to assembly 'DogInterface' containing the implemented
interface 'DogInterface.IDog'. Add one to your project."


Did you add the reference to the assembly itself, or just the Imports
clause?

You need to reference the .dll itself in your application (see the solution
explorer references folder).

Kelly
Jul 21 '05 #2
Paul,
To reiterate Kelly's comments.

You need to reference BOTH assemblies in your third project, the assembly
where IDog is defined, plus the assembly where Husky is defined

VB.NET does not infer the reference to the IDog assembly from the Husky
assembly, you need to explicitly give the reference to the IDog assembly.

Hope this helps
Jay

"Paul" <an*******@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
OK...I must be missing something...can someone tell me what I'm not doing properly....
First, create an assembly with a single interface in VB.NET as follows

Public Interface IDog
Function Bark(ByVal lVolume As Long) As String
End Interface

Pretty simple...

Now...in a second (C#) assembly...create a class that implements that interface...like so...
using System;
using DogInterface;

namespace CSImplemeter
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Husky : IDog
{
public string Bark(long lVolume)
{
return "Deep Bark!! at " + lVolume.ToString() + " level";
}
}
}
This is also pretty simple (as you can see...the namespace for the IDog is DogInterface...that is also the name of it's assembly). This all compiles
very well...I have a single solution with both projects in it.

Now...I create a new assembly...a VB.NET windows application in the same solution that will use that Husky Class. I have referenced the two
assemblies from above and placed a single button on the form.
In a click event for the test button, I have the following code:

Imports CSImplemeter
Imports DogInterface

Public Class Form1
Inherits System.Windows.Forms.Form

[" Windows Form Designer generated code "]

Private Sub cmdBark_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBark.Click
Dim objDog As CSImplemeter.Husky

End Sub

End Class

The problem is that I get an error on the line of code that dimension the objDog. The squiggly line goes under the CSImplementer.Husky and says...
"Reference required to assembly 'DogInterface' containing the implemented interface 'DogInterface.IDog'. Add one to your project."
But...I already added it to the project. Am I missing something here??...or is there a real problem??
BTW...I am using .NET Enterprise Architect version 7.

Jul 21 '05 #3
Yes...I have added a reference to both of the assemblies to the test windows project assembly. That is the main frustration behind this one...I added it as a reference, then it tells me to add it as a reference.
Jul 21 '05 #4
OK...figured out a way...but it is really strange....my referenece that I was using was via the 'Projects' tab in the 'Add Refereces' functionality. I removed that reference and added a reference that was directly from the .dll that is generated upon compile (using the 'Browse...' button). This worked.

I don't really understand it...I am guessing that a reference to the project created some sort of circular reference because the reference to the Husky implementation also pointed to the project referenece.

Any other gueses anyone!!....well...I did get the solution...thanks for the replies Kelly and Jay!
Jul 21 '05 #5
Paul,
Which version of VS.NET?

I have similar "circular references" in strictly between VB.NET projects in
VS.NET 2003.

I'm curious if VS.NET 2002 is having a problem or if C# in the mix is having
the problem.

Hope this helps
Jay

"Paul" <an*******@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
OK...figured out a way...but it is really strange....my referenece that I was using was via the 'Projects' tab in the 'Add Refereces' functionality.
I removed that reference and added a reference that was directly from the
..dll that is generated upon compile (using the 'Browse...' button). This
worked.
I don't really understand it...I am guessing that a reference to the project created some sort of circular reference because the reference to the
Husky implementation also pointed to the project referenece.
Any other gueses anyone!!....well...I did get the solution...thanks for

the replies Kelly and Jay!
Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MKoleoso | last post by:
Problem: C#- Unable to create instance of a class implementing from an interface I have: namespace someNamespace { public __gc class SomeClass1 { }
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
5
by: Daniel Bass | last post by:
..Net is great for modulerising libraries, so that all you need do to access a DLL, is simply call Add Reference and wallah, it's as though the library were written in your project. But what...
3
by: Richard | last post by:
Hi, I'm new to C# and are having difficultly implementing an interface class. Basically I want to define an interface class, then inherit it. I want some of the methods to be public, and...
9
by: Codex Twin | last post by:
Hi I have a common model for a Data Access Layer scenario. I have an abstract base class, called DalBase which contains a list of abstract methods. Lets call them: public abstract void Shine();...
3
by: Frans Bouma | last post by:
Hi, I have a serious problem with VB.NET and a DataTable derived class and I can't figure out how to solve it. I have implemented it in C# where it works perfectly, but I can't port one...
2
by: Kevin Frey | last post by:
Consider this simple example: interface IReader { bool Read( ); }; class MyReader : IReader { bool Read( ); // or should it be bool IReader.Read( ) ?
6
by: kasper.rung | last post by:
I am having trouble implementing an interface. The interface requires a method to return an object, but it does not seem to be able to treat a reference type as an object. I have the following...
5
by: Tony Johansson | last post by:
Hello! Here I have an Interface called ITest and a class called MyClass which derive this intrface. As you can see I don't implement this method myTest in class MyClass because i use the...
1
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
I have a assembly from a third party that exposes an Event I want to Trap the event and tie to a Method in a Class where I am consuming their assembly. The class is actually a UserControl How...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.