I'm trying to use System.DirectoryServices in a web site project and I'm getting this error:
The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)
My project has a reference to System.DirectoryServices in web.config:
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
And I do have using System.DirectoryServices in the files where I want to use it.
Does anybody have a clue where to look for the problem?
Right click on References under your solution.
Select Add Reference.
The reference can be found under the Framework Assemblies list.
Select System.DirectoryServices and click Add.
I think you should install Directory Services Package.
Install-Package System.DirectoryServices -Version 4.0.0
Directory Services Package
Shot in the dark: have you tried adding to the web.config:
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
Is the web-server (IIS or whatever) configured to run the folder as an application (i.e. shows as a cog), and is it using the correct version of ASP.NET? If it is running as 1.1, bits of it might work - but it would fail to find that 2.0 assembly in the 1.1 GAC.
This is a very old thread but just to provide a complete answer for the sake of posterity ;)
This issue occurs if the project is missing a reference to the .Net Component System.DirectoryServices
Adding this reference in the usual manner prefered by you will resolve the issue.
Is this a web site project, or a web application project. With the latter, references are handled via the .csproj - i.e. via the "References" node in Solution Explorer.
On Solution Explorer right-click your project, then from the resulting menu, click on Add Reference, then under the .NET tab navigate to DirectoryServices.AccountManagement
These problems occur when you are working with older .net version and trying to build with the latest IDE
It depends on which version of IDE you are using and also the current code version.
Check the web config,
In my case, I was using the Latest version i.e 4.7 and directoryService assembly are still referring to C#4.0.
Add below if you are using Latest version of id i.e 4.7
<system.web>
<location>
<compilation debug="false" numRecompilesBeforeAppRestart="100" targetFramework="4.7">
<assemblies>
<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
</system.web>
</location>
I had the same problem when I tried to convert website to web-app.
It looks like vs failing to load the assembly should be related to versioning.
switch to web.config and add the assembly to it as bellow. make sure the DLL version is matching your application targeted .NET version.
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
</system.web>
</configuration>
for getting a public key you need to launch Developer Command Prompt for VS. Change to GAC directory related framework on above ex C:\Windows\Microsoft.NET\Framework\v4.0.30319
and call
sn -T System.DirectoryServices.dll
Related
I have updated my nuget packages for an existing project. I have updated all of my packages, including the .NET Standard 2.0 nuget package. Now I am getting the error message below.
Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
I've tried to to clean, rebuild, rebooted, etc. I've googled and think that this is in reference to the .NET Standard 2.0 nuget package. I've got some entries in my runtime assembly binding section of my web.config.
I would think that I would need to reference Runtime 4.3.0.0, but I don't see a way to do this. Any suggestions are appreciated. TIA.
If you are not using ASP.NET Core, you can set assembly for System.Runtime in system.web section in web.config. By the way, please configure your .NetFramework version, too.
<system.web>
<httpRuntime targetFramework="4.5.1" />
<compilation debug="true" targetFramework="4.5.1">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
</system.web>
I am new to mvc. I just installed the Visual studio 15 and when i create a mvc project and run it without any modification. it gives me the above mentioned error. I did the same thing on another pc and it works but on my system it gives me the error. search for solutions but could not find any specific. so please guide me what to do.
"Could not load file or assembly 'AAAAAAAAAA, Version=6.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxx' or one of its dependencies." is a common error. Try the following methods in order to fix this error:
Method I: Add the following key to the section in your web.config:
<compilation debug="true" targetFramework="4.5" >
<assemblies>
<add assembly="AAAAAAAAAA, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=xxxxxxxxxx" />
</assemblies>
</compilation>
Method II: If the problem is not solved, try to run this command on PM Console:
Install-Package AAAAAAAAAA
Hope this helps...
As Power BI Embedded release to official version 1.0, I tried to upgrade PowerBI nuget packages in my application from version beta to 1.0, everything works perfectly on localhost.
But when I deploy to the web server (IIS on Windows Server 2012 R2), I got exception:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ada706e8\d6adc8aa\App_Web_index.cshtml.1c5a15dd.b_ofojaq.0.cs(77): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I am not sure how to fix it, my application on .NET 4.6.1. I had to go back beta version for production until finding the way to fix it.
It fixed by adding the line:
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
into web.config:
<compilation debug="true" targetFramework="4.6.1">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
....
</compilation>
I am part of a team working on a large application. I am a new addition to this team and am building a new piece of the app. As part of this process, I've created a WebApi application that will expose some HTTP endpoints through which I will retrieve information about the app.
Due to conditions it would take far too long to explain, I'd like to get the WebApi project to build in another directory, specifically ..\bin\Server\Debug\ as this is where most of the other portions of the app build to. I would not bother except that the app tried to use files that are found based on the working directory which is currently wrong for my WebApi app.
I tried changing it in the project settings and now I get this error:
My Googling has turned up little help thus far. Anyone know how to resolve this?
Try adding a runtime probing path in the configuration:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin\server\Debug;"/>
</assemblyBinding>
</runtime>
</configuration>
In addition to above step and to get rid of globa.asax error. Open the mark up of Global.asax file and Add follow line on the top.
<%# Assembly Name="<you_web_app_assembly_name_here>" %>
Now you'll start getting the error of System.web or BindingProvider not found etc. There's weird fix for it start adding assemblies to assembly tag under compilation.
<compilation debug="true" targetFramework="4.5" optimizeCompilations="false">
<assemblies>
<add assembly="Microsoft.AspNet.Identity.Core, Version=2.2.1, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
You'll get few more errors like this but this will get you going.
Reason: The problem I see is that there's an option to change the output path but Asp.net does on the fly compilation. Which why the error are compilation related when you try to run the website. Somewhere the run time compilation only look in \bin folder and which is why we have to specify every assembly that the project is referencing to.
Update -
Unfortunately you can not change the bin directory. After looking at all options and digging found that bin folder of Asp.net web project is not ordinary binary output folder. It's a share code folder from where the binaries are referenced directly in the project.
The binaries are compiled when a first request is received by webserver for Asp.net application. And bin folder is only use as shared binary references folder and not the actual output folder/directory.
The actual output folder of On-the-fly compilation in Asp.net is default set to %SystemRoot%\Microsoft.NET\Framework\<versionNumber>\Temporary ASP.NET Files that you can change ofcourse from compilation tag attribute [tempDirectory][3] in your web.config.
After all these research I came to this conclusion that the option for changing the directory from project -> properties -> Build -> Bin is appearing because of Asp.net website project template. This gives the user same look'n feel as any other project. But the functionality of asp.net website remains the same. The Bin folder still works as it used to work in old website template of Asp.net.
You cannot change the output directory of an asp.net application due to IIS security restrictions, this is why it is not working.
If you are trying to manage dlls due to DI, copy all other satellite dlls into bin folder of your main asp.net app
You can try copying the dll with the after build target. First change the output path back to what it was if you changed it before. Then add some code like this in your project file.
<target name="AfterBuild">
<copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).dll" />
<copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).pdb" />
<copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).xml" />
</target>
This will put the built dll in to the folder specified in destinationfolder. I usually use this for class libraries but i don't see why it would not work for a web api project
You can check out my blog post on this if you like.
http://torontoprogrammers.blogspot.com/2014/11/msbuild-targets-and-tasks.html
I'm getting the following error in a .Net c# MVC application, targetting the .Net Framework Version 4.5:
The type 'System.Net.Http.HttpContent' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I have added the reference in the project, and I have even edited the web.config to include a reference to the assembly under:
<system.web>
<compilation debug="true" targetFramework="4.0"/>
Unfortunately, I cannot find any explanation why the Exception is happening. Has anyone had the same exception?
Consider checking the machine.config and other configuration files. In the above case, a corrupted machine.config was the problem.