Alex Yeung
Alex Yeung

Reputation: 2515

System.Design cannot be referenced in Class Library?

I have a very strange problem that I cannot fix and don't know what's going on... I am using VS 2010 Premium and .NET 4.0.

Here are my steps to simulate the problem.


Step 1. Create a new VB class library project named "MyClassLib"

Step 2. Create a new class named "MyTestingClass".

Public Class MyTestingClass
    Inherits System.ComponentModel.Design.CollectionEditor

    Public Sub New()
        MyBase.New(GetType(List(Of String)))
    End Sub

End Class

Step 3. Add two .net reference. "System.Design" and "System.Drawing".

Step 4. Create a new VB console application named "MyClassExe"

Step 5. Add "MyClassLib" reference to "MyClassExe".

Step 6. Open Module1.vb in "MyClassExe" project

Step 7. In the Main method, type

Dim a = New MyClassLib.MyTestingClass()

Step 8. Try to compile "MyClassLib". It doesn't have problem.

Step 9. Try to compile "MyClassExe". It cannot compile because the WHOLE MyClassLib cannot be found!!!


I have no idea what's going on?

Moreover, the same case happens in C#.

Does anyone know what's the problem with "System.Design"?

Thank!!!

Upvotes: 0

Views: 2885

Answers (1)

SLaks
SLaks

Reputation: 887777

Add a reference to System.Design in the Console Project.

You cannot use a class if it inherits a class in an assembly that you didn't reference.

Upvotes: 4

Related Questions