I've created a class library and built a dll (release build). I've then referenced the DLL in another project (I've tried several). I can see the namespace and classes in Object Browser and I can declare instances of the classes but I cannot use or see any of the methods or properties! there is no IntelliSense whatsoever and calling the methods manualy r开发者_JAVA百科esults in a 'Declaration expected' error.
Within the class library solution I have a unit test project referencing the class library project which works all works fine (and all the tests pass).
Can anyone provide any pointers to what might be going wrong here? I've built plenty of dlls in the past and have had no trouble referencing them at all.
**EDIT: Sample class (as you can see it's very simple)
Public Class NTSCurrency
Implements IComparable
Public Sub New()
End Sub
Public Sub New(ByVal code As String, ByVal name As String)
_Code = code
_Name = name
End Sub
Private _Code As String
Private _Name As String
Public Property Code() As String
Get
Return _Code
End Get
Set(ByVal value As String)
_Code = value
End Set
End Property
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Overrides Function ToString() As String
Return Me.Name
End Function
Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
Dim cur As NTSCurrency = CType(obj, NTSCurrency)
Return Name.CompareTo(cur.Name)
End Function
End Class
** UPDATE: Just tested this dll with an existing solution and it works fine. Is there a setting somewhere for new projects?
Check what scope you have given to your class, methods and properties. Are they public, or if they are protected are you inheriting from the class? If the class is abstract then you will not be able to instantiate an instance of it.
Andrew
Nobody laugh...
This was because I was trying to reference the dll methods and properties outside a sub or method definition.
2 hours of my life wasted.
Thanks to all who helped.
So you have assembly A which you can call from assembly B (unit tests) but not from assembly C (production code)? Sounds bizarre to me. Have I misunderstood you?
You could try gradually changing assembly B code into assembly C one tiny step at a time and see where it stops working.
精彩评论