0

I've created an ASP.NET web application in VS 2013. I created a folder App_Code and put a folder in that 'BLL' In there I have a file 'User.vb'

Imports Microsoft.VisualBasic

Imports System
Imports System.Web
Imports System.Configuration
Imports System.Data
Imports System.Web.Security
Imports DataAccessLayer

Namespace BusinessLogicLayer

Public Class User

#Region "Private Locals"

    Private _userID As Integer
    Private _NTUsername As String

#End Region

#Region "Constructors"

    Public Sub New()
    End Sub 'New

    Public Sub New(ByVal userID As String)
        _userID = userID
    End Sub 'New

#End Region

#Region "Public Properties"

    Public Property UserID() As Integer

etc...

I try to reference that file from an aspx.cx page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using BusinessLogicLayer; // error on this line


namespace InvoiceRouting2017
{
public partial class InvoiceList_Cred : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        lblUsername.Text = Environment.UserName.ToString();
        BusinessLogicLayer.User user = new BusinessLogicLayer.User(); // error on this line
    }
}
}

But it's giving errors on the bold lines.

Error 97 The type or namespace name 'BusinessLogicLayer' could not be found (are you missing a using directive or an assembly reference?)

mrogal.ski
  • 5,828
  • 1
  • 21
  • 30
Pete Whelan
  • 85
  • 11
  • Could you provide the structure of your project? Is that first class in a separate project (a DLL)? – Romano Zumbé Jul 25 '17 at 08:55
  • have you added dll reference under your project reference? – Hameed Syed Jul 25 '17 at 08:56
  • Ensure VB file inside `App_Code\BLL` having `Build Action` property as `Compile` & the file referenced properly in CS code. Error 97 often caused by code file which not being compiled regardless of the language (CS/VB). – Tetsuya Yamamoto Jul 25 '17 at 08:58
  • Possible dupe: https://stackoverflow.com/questions/1278024/mixing-c-sharp-vb-in-the-same-project & https://stackoverflow.com/questions/862723/use-vb-net-and-c-sharp-in-the-same-application. In same project it's a no-no, but in same solution yes. – Tetsuya Yamamoto Jul 25 '17 at 09:08
  • Tetsuya if I change build action to compile I get the error "Error 96 A namespace cannot directly contain members such as fields or methods" pointing to the User.vb file first line 'Imports Microsoft.VisualBasic' – Pete Whelan Jul 25 '17 at 09:57
  • OK so I've separated the solution out to two projects. One project with the web pages and code (c#) and one with the BusinessLogicLayer and DataAccessLayer (vb). In the c# project I reference the 'BLLandDAL' project. I'm now getting an error Error 1 Metadata file 'C:\inetpub\wwwroot\InvoiceRouting2017\BLLandDAL\bin\BLLandDAL.dll' could not be found C:\inetpub\wwwroot\InvoiceRouting2017\InvoiceRouting2017\CSC InvoiceRouting2017 – Pete Whelan Jul 25 '17 at 10:15

0 Answers0