Odd build error

Morcyk

New member
Joined
Jan 14, 2009
Messages
2
Programming Experience
10+
This issue may straddle more than just ASP .NET, but since it's an ASP .NET web site I'm having an issue with, here it is.

The environment: VB .NET, Framework 3.5, VS 2008, ASP .NET web site

The issue:
1. Building (Rebuilding too) the site results in the following error, but only in the output window (error list shows 0 errors, 0 warnings):
C:\Web\Default.aspx.vb(85,0): error BC30456: 'Drive' is not a member of 'Car'.
Validation Complete
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

2. The problem is, 'Drive' IS a member of 'Car'. Not only that, but if I hover over the 'Drive' method call on my instance in the IDE, it shows it as being a member of 'Car'. The 'Drive' method shows up in intellisense. I can even right click this "unknown" item and go to definition and it takes me to the spot that 'Drive' is defined. I've already tried restarting IIS and the computer with no luck. I'm at a loss on this one.

Here's the affected code.:

web (default.aspx):
<asp:Content ID="Content2" ContentPlaceHolderID="cphSiteData" Runat="Server">
<div class="cssDivCenter">
<asp:TextBox ID="txtMake" runat="server"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_OnClick" />
</div>
</asp:Content>

click event (default.aspx.vb excerpt):
Public Sub btnSubmit_OnClick(ByVal sender As Object, ByVal e As EventArgs)
Dim myCar As New Car()

'THIS IS THE LINE THE ERROR IS THROWN ON
If Not myCar.Drive() Then
'Do Something
End If
End Sub

class & interface data:
Public Interface IVehicle
Function Drive() As Boolean
End Interface

Public MustInherit Class Vehicle
Implements IVehicle

Public MustOverride Function Drive() As Boolean Implements IVehicle.Drive
End Class

Public Class Car
Inherits Vehicle

Public Overrides Function Drive() As Boolean
Dim retVal As Boolean = True

Try
'Do something
Catch ex As Exception
'exception
End Try
Return retVal
End Function
End Class
 
I found the issue, so here's what was happening:

I had another class of the same name in the project that was causing a conflict. The odd part is that IDE specific items (intellisense, go to definition, etc.) were using the instance I was expecting, which is why it looked okay to me, but the build was using this other class. Fully qualifying the name fixed it.

Hope this helps someone else.
 
Back
Top