c# implements VB.net interface

  • Thread starter Thread starter cs
  • Start date Start date
C

cs

We have a VB.NET interface that I just dont have the time to rewrite at the
moment, and I need to implement it on C#, I have done it already however I
get the following error when referencing my implementation, I have added all
the references needed already.
c:\inetpub\wwwroot\webclient_1\WebClasses.vb(44): Reference required to
assembly 'WebInterfaces' containing the implemented interface
'WebLink_Interface'. Add one to your project.
 
Ensure you reference the correct version of the assembly containing the
interface, and that you have added necessary "using" / "Imports" statements.
If this does not help, could you please post some code?
 
All the references were correct and we use strong names, etc etc. all
imports were fine as well.
I gave up on the thing and rewrote the code (with the exact same class name,
name space, etc) in VB.NET (YUK!) and recompiled without making any
modifications to the code that instantiated the thing, and it worked just
fine, its almost like you cant implement a VB interface on C# and call it
from VB again.

Dmitriy Lapshin said:
Ensure you reference the correct version of the assembly containing the
interface, and that you have added necessary "using" / "Imports" statements.
If this does not help, could you please post some code?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

cs said:
We have a VB.NET interface that I just dont have the time to rewrite at the
moment, and I need to implement it on C#, I have done it already however I
get the following error when referencing my implementation, I have added all
the references needed already.
c:\inetpub\wwwroot\webclient_1\WebClasses.vb(44): Reference required to
assembly 'WebInterfaces' containing the implemented interface
'WebLink_Interface'. Add one to your project.
 
You should be able to do this. Are you sure the C# project has all the same
references as the VB project that created the interface?
 
yeah it was all correct and on its own it would compile fine, it was whoever
was using the implementation that wouldnt compile, what was wierd is that
the error was asking for the assembly containing the interface, which was
added correctly because other code on the assembly giving the error
reference that assembly that it said it was missing, very odd error.
 
cs said:
yeah it was all correct and on its own it would compile fine, it was
whoever was using the implementation that wouldnt compile, what was
wierd is that the error was asking for the assembly containing the
interface, which was added correctly because other code on the
assembly giving the error reference that assembly that it said it
was missing, very odd error.
Me and other Developers in my Company ran into the same problems. It
has nothing to do with assembly versions and things like that. It always
happens to me when I reference VB assemblies from/via C# as project
references in Devstudio. A workaround for me is, to reference the
compiled VB assemblies directly using the Browse Button in the Add
Reference Dialog

The problem is simple to reproduce
-Open a new solution
-Add a vb class library project (VB.proj)
-Define a public class
Public Class Dummy
End Class
-open new C# class library project
-reference the VB class project as a project reference
-implement a function that returns the dummy VB type
namespace CS
{
public class Xox
{
public static VB.Dummy dummy()
{ return new VB.Dummy(); }
}
}
-open up a new VB conole project
-refernce the C# and the VB assembly via project refernces
-try this code in the main function:
Dim dummy As VB.Dummy 'compiles
dummy = New VB.Dummy 'compiles
dummy = Cs.Xox.dummy() 'Error

Now change the Project references of all projects to direct references
by deleting the references first and adding them again using the Browse
Button and select the compiled assembly. It will work.

This looks like as a bug in the IDE.

Cheers,
Andy
 
Back
Top