C# and VB.net project reference each other.

  • Thread starter Thread starter Holly Li
  • Start date Start date
H

Holly Li

Hi,
Because of reuse, I need to mix C# project and VB.net
project. To illustrate the problem, I have built 3 simple
projects:
1) C# library--projc (has one class "Manager")
2) vb.net library--projb (has one class "Bob")
3) vb.net web form--projweb (has one web form with a
label on it)

Here are the code:
projc:
using System;
using busivb;
namespace clib
{
public class Manager
{
public Manager()
{
}
public static void Add(Bob bob)
{
bob.Name="hello";
}
}
}

projb:
Namespace busivb
Public Class Bob
Dim _name As String

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property
End Class
End Namespace

projweb
Imports busivb
Imports clib
Namespace testvbweb
Public Class WebForm1
Inherits System.Web.UI.Page

--" Web Form Designer Generated Code "--


Private Sub Page_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load

Dim abob As New Bob
Manager.Add(abob)
lbName.Text = abob.Name


End Sub

End Class
End Namespace

I got "Reference required to assembly 'busivb' containing
the type 'busivb.Bob'. Add one to your project." error
for the line:

Manager.Add(abob)
in the form.

Can you tell me what is wrong? Thanks.
 
Yes.
I found something on the internet that tells me to use
dlls not projects when mix c# and vb.net together. It
works when I reference c# code using dll in vb.net.
 
I found something on the internet that tells me to use
dlls not projects when mix c# and vb.net together.

For the current version of Visual Studio, but the next version (codename
Whidbey) will allow more than one language per project...
 
I found something on the internet that tells me to use

I sure am glad I didn't find that on the internet, as I've got tons of
Solutions that contain both VB.Net and C# projects in them. Funny thing is,
they all work fine. Maybe you can't believe everything you read on the
internet?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
Back
Top