views:

51

answers:

1

Hi,

I've made an interface called ApprovalEvent in a separate file with the namespace myproject... I've also made a class called PurchaseOrder... it's also in the same namespace, just in a separate file. Whenever I try to make PurchaseOrder implement ApprovalEvent it always says that ApprovalEvent is undefined...

How can I make the class recognize that the interface exists but is in a different file?

Here's some code:

File #1

Namespace myproject
    Public Interface ApprovalEvent
        Function getDetails() As String
    End Interface
End Namespace

File #2

Namespace myproject
    Partial Class PurchaseOrder 
        Inherits Entities.Modules.PortalModuleBase 
        Implements ApprovalEvent

        Function getDetails() As String Implements ApprovalEvent.getDetails
            return "details"
        End FUnction
    End Class  
End Namespace

Thanks,
Matt

A: 

Hey,

Separate project too? Does the one project include the other as a reference if so? That shouldn't be a problem from what I can see. It works no problem. Try temporarily including the interface in the same file too, see if that helps.

Brian
No, same project. It does work if I put it in the same file... just can't find it in the other file. The other file is in the same directory as well...
Matt
Is the file included in the project (i. e. right click it and choose Include in Project)? Does the file with the interface have a Namespace statement in it? If you could show some code it would be helpful.
Chris Dunaway
1 sec, I'll see if I can grab some. Yes it is included in the project
Matt
What type of project is this? Is it a web site or web application project? If so, where are the files located in the project?
Brian
web site. The files are within a folder called Approval under DesktopModules. I just added some code, hopefully that'll help...
Matt
In web site project, all code files need to be in the App_Code folder that are not code-behind page files. So your interface would and if this class isn't a code-behind file, both would need to be in app_code. Even better would be to have any code files in a separate project, then reference that project in the web site.
Brian
I made a site project and the code started working! Thanks!
Matt
No problem. Could you mark the thread as the answer then? Thanks.
Brian
Sorry about the huge delay on marking it answered. Thanks again for the help.
Matt
No worries. Glad I could help.
Brian