using System.DirectoryServices.dll assembly

  • Thread starter Thread starter jruzicka
  • Start date Start date
J

jruzicka

I have a statement in my c# page that read:
using System.DirectoryServices;

This is causing a runtime failure. Can someone tell me how I can make
the assembly accessable from my asp.net app without using Visual
Studio .net? Is it just a matter of moving the dll into my bin
folder? Where do I get this dll?

Thanks
 
jruzicka,

You definitely don't want to move this into your bin folder, whatever
you do. The reason you are getting a runtime failure is that you are not
setting a reference to the dll. The "using" statement does not create
references, it only allows types from that namespace to be written by
itself, without a full namespace qualifier.

To referenece the System.DirectoryServices assembly in your page, you
should be able to add the following to the top of your page:

<%@ Assembly Name="System.DirectoryServices" %>

If you have a good number of pages and you don't want to set this
reference in every page, you can modify the web.config file so that the
reference is set (the <assembly> section).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)





jruzicka said:
I have a statement in my c# page that read:
using System.DirectoryServices;

This is causing a runtime failure. Can someone tell me how I can make
the assembly accessable from my asp.net app without using Visual
Studio .net? Is it just a matter of moving the dll into my bin
folder? Where do I get this dll?

Thanks
 
I tried what you mentioned and this is the error i get now:
I put the line first thing in my login.aspx file that uses
login.aspx.cs

My webconfig compilation is set to use language "vb", would this be a
problem? The rest of my app will be using vb.net codebehind and I
want to use this c# codebehind for the login process. Have any
ideas?


Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following
specific parse error details and modify your source file
appropriately.

Parser Error Message: File or assembly name System.DirectoryServices,
or one of its dependencies, was not found.

Source Error:


Line 1: <%@ Assembly Name="System.DirectoryServices" %>
Line 2: <%@ Page Language="C#" Inherits="ITC3.login"
Src="login.aspx.cs" trace="true" %>



Source File: c:\inetpub\wwwroot\rtsnet\rts\login.aspx Line: 1

Assembly Load Trace: The following information can be helpful to
determine why the assembly 'System.DirectoryServices' could not be
loaded.


=== Pre-bind state information ===
LOG: DisplayName = System.DirectoryServices
(Partial)
LOG: Appbase = file:///c:/inetpub/wwwroot/rtsnet
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===

LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind).
LOG: Post-policy reference: System.DirectoryServices
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices.EXE.
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices/System.DirectoryServices.EXE.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices.EXE.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices/System.DirectoryServices.EXE.
 
You need the assemblies full name :

Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"%>
<%@ Import namespace="System.DirectoryServices"%>

Check the version in the GAC.

Willy.


jruzicka said:
I tried what you mentioned and this is the error i get now:
I put the line first thing in my login.aspx file that uses
login.aspx.cs

My webconfig compilation is set to use language "vb", would this be a
problem? The rest of my app will be using vb.net codebehind and I
want to use this c# codebehind for the login process. Have any
ideas?


Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following
specific parse error details and modify your source file
appropriately.

Parser Error Message: File or assembly name System.DirectoryServices,
or one of its dependencies, was not found.

Source Error:


Line 1: <%@ Assembly Name="System.DirectoryServices" %>
Line 2: <%@ Page Language="C#" Inherits="ITC3.login"
Src="login.aspx.cs" trace="true" %>



Source File: c:\inetpub\wwwroot\rtsnet\rts\login.aspx Line: 1

Assembly Load Trace: The following information can be helpful to
determine why the assembly 'System.DirectoryServices' could not be
loaded.


=== Pre-bind state information ===
LOG: DisplayName = System.DirectoryServices
(Partial)
LOG: Appbase = file:///c:/inetpub/wwwroot/rtsnet
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===

LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind).
LOG: Post-policy reference: System.DirectoryServices
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices/System.DirectoryServices.DLL.
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices.EXE.
LOG: Attempting download of new URL
file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/rtsnet/4ef57568/2619b47/System.DirectoryServices/System.DirectoryServices.EXE.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices.EXE.
LOG: Attempting download of new URL
file:///c:/inetpub/wwwroot/rtsnet/bin/System.DirectoryServices/System.DirectoryServices.EXE.
 
you wrote: <%@ Assembly name="System.DirectoryServices,
Version=<yourversionhere>,

How can I find my version?
 
Run,

gacutil /l System.DirectoryServices

from the commandline

Willy.


jruzicka said:
you wrote: <%@ Assembly name="System.DirectoryServices,
Version=<yourversionhere>,

How can I find my version?
 
thanks willy. although i dont seem to have that utility on my
machine..I was searching for it and came across something else. I
included:
<compilation defaultLanguage="vb" debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>

I added the assemblies node to the web.config file and it seems to get
past the using System.DirectoryServices line in my c# code. I guess
this node references the global assembly cache, is that correct?
But I still do not understand why I needed to do this. Is their a
machine wide setting someplace to include this assembly throughout
all my apps?
 
1. The utility must be on your machine, take a look in the x:\program
files\microsoft visual studio .net...\sdk\v1.x\bin
2. You can put this in the machine.config file (this file contains entries
for the most frequently used assemblies, search for assembly add ...), but
why would you do this, I don't assume you need this assembly for all your
web pages don't you.
Normally you include this only at the top of the aspx page requiring a
reference to the assembly, or better use code behind for your web
applications.

Willy.

jruzicka said:
thanks willy. although i dont seem to have that utility on my
machine..I was searching for it and came across something else. I
included:
<compilation defaultLanguage="vb" debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>

I added the assemblies node to the web.config file and it seems to get
past the using System.DirectoryServices line in my c# code. I guess
this node references the global assembly cache, is that correct?
But I still do not understand why I needed to do this. Is their a
machine wide setting someplace to include this assembly throughout
all my apps?
 
Back
Top