locked
How to import a namespace RRS feed

  • Question

  • User-6580369 posted
    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.DirectoryService" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
    
    <head runat="server">
    <meta name="WebPartPageExpansion" content="full" />
    <meta http-equiv="Content-Language" content="en-us" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled 1</title>
    <style type="text/css">
    .style1 {
    	text-align: center;
    }
    .style2 {
    	text-align: left;
    }
    </style>
    </head>
    
    <body>
    		<script type="text/vb" runat="server">	
    	Private Sub PopulateGrid()
    		Dim dListing As DirectoryEntry = GetListing()
    	End Function
    

    I am getting "DIrectoryEntry is not defined". I assume this is because I need to add a reference. I normally develop in Visual Studio, and would go "Project > Reference > Select Component", and then import the namespace. I figure I have to do the same thing here, but I have no idea how. I am using Sharepoint Designer to create a single ASP page.

    Warning: BC40056: Namespace or type specified in the Imports 'System.DirectoryService' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
    Source Error:
    
    
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\77af5d62\8d9d3330\App_Web_15_63a4413b-9b82-46e0-8377-2f9fb64c70b8_-573700.rmssqttv.0.vb  
    
    Line 20: Imports System.Configuration
    Line 21: Imports System.Data.SqlClient
    Line 22: Imports System.DirectoryService
    Line 23: Imports System.Linq
    Line 24: Imports System.Text

    Friday, November 6, 2015 12:42 PM

Answers

  • User61956409 posted

    Hi tmontney,

    Welcome to ASP.NET forum.

    tmontney

    <%@ Import Namespace="System.DirectoryService" %>

    We could import a namespace into a Web page via <%@ Import namespace="value" %>, but “DirectoryService” is not in System namespace. Please make sure if you include required dll file in your project.

    tmontney

    I am getting "DIrectoryEntry is not defined". I assume this is because I need to add a reference. I normally develop in Visual Studio, and would go "Project > Reference > Select Component", and then import the namespace. I figure I have to do the same thing here, but I have no idea how. I am using Sharepoint Designer to create a single ASP page.

    You could try to copy the dll file into your bin folder and try it again.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 9, 2015 12:13 AM