Encountered strange problem concerning Project References in a Solution.
Situation:
- VB Control Library (Lib1)
- C# Control Library (Lib2) containing reference (project reference) to Lib1
- VB Windows Application (App 1) containing reference (project reference) to Lib2 and reference (project reference) to Lib1
I got the following error on compiling:
"C:\Temp\WindowsApplication2\Form1.vb Project 'App1' makes an indirect reference to assembly 'Lib1', which contains 'Lib1.UserControl1'. Add a reference to 'Lib1' to your project."
I changed the project reference to Lib1 in App1 to a dll reference (referenced the Lib1 dll out of the bin directory of Lib2). Then I got the following error on compiling:
"C:\Temp\WindowsApplication2\Form1.vb(49): Handles clause requires a WithEvents variable."
Apparantly the Handles (Click Event) Clause of the Control1 (Lib1) sited on Form1 (Lib2) is a problem. Handles Clause is in Form1 (inherits Form1 of Lib2) of App1. Can understand this one though (probably by design in VB.Net)
Workaround: use the AddHandler statement (the C# way)
For the fun of it I created the following situation:
VB Control Library (Lib1)
C# Control Library (Lib2) containing reference (project reference) to Lib1
C# Windows Application (App 1) containing reference (project reference) to Lib2 and reference (project reference) to Lib1
So I changed the VB Windows Application to a C# one.
Guess what :))) => No errors here?!?
To investigate a little further the following situation:
VB Control Library (Lib1)
VB Control Library (Lib2) containing reference (project reference) to Lib1
VB Windows Application (App 1) containing reference (project reference) to Lib2 and reference (project reference) to Lib1
So I changed the C# Lib2 to a VB one.
Guess what :))) => No errors here?!? I was stumbled, and you...? Apparently the Handles Clause is no problem when all projects are in VB?!?
Then the following situtuation:
VB Control Library (Lib1)
VB Control Library (Lib2) containing reference (project reference) to Lib1
C# Windows Application (App 1) containing reference (project reference) to Lib2 and reference (project reference) to Lib1
So I changed the VB Windows Application to a C# one.
=> No problemo.
There is also no problem with all projects in C# (off course). All the modifiers where set to public by the way.
What wonders me most is what the problem is with Lib1 VB, Lib 2 C# and App1 VB.
Maybe shouldn't say this but sticking to C# seems a good idea :))).
9:28:53 PM
|