Updated: 16/05/2004; 22:46:18.
Hannes 'Shorty' Decorte's Radio Weblog
Learning .Net and the Experiences doing so


dinsdag 23 december 2003

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    comment []

    © Copyright 2004 Hannes 'Shorty' Decorte.
     
    December 2003
    Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4 5 6
    7 8 9 10 11 12 13
    14 15 16 17 18 19 20
    21 22 23 24 25 26 27
    28 29 30 31      
    Nov   Jan



    Other .Net Bloggers

    Bart De Smet
    Jan Tielens
    Patrick Verbruggen
    Patrick Tisseghem
    Tom van de Kerkhof's Bloggings
    Tom's Corner
    Yves Hanoulle

    Aggregated Feeds

    Belgian .NET Bloggers