1

I am getting an error of "Could not load file or assembly 'Microsoft.AI.Web' or one of its dependencies" in the browser of my asp.net app. Microsoft.AI.Web is from Microsoft.ApplicationInsights.Web NuGet package.

I noticed this:

LOG: Appbase = file:///D:/Source/Workspaces/AppName/Branches/Main/Application/WT/
LOG: Initial PrivatePath = D:\Source\Workspaces\AppName\Branches\Main\Application\WT\bin

the dll in question is located at D:\Source\Workspaces\AppName\Branches\Main\Application\packages\Microsoft.ApplicationInsights.Web.2.4.1\lib\net45\Microsoft.AI.Web.dll

As for personal dll's -- In the project-->properties-->build-->output path--> I have it set as "..\Any\Debug\". When I build the project the DLL's populate there.

I checked References and code in .csproj file and all the dll are located where I specified to.

I am not sure why it's trying to look at the bin file of the project when I told the output is somewhere else AND to look for the dlls in that same folder(through references and .csproj file). How do I make it so that VS will look for the dlls in the folder path I want instead of "WT\bin"?

When I change my project output path to "bin", it can detect the dll's there EVEN though the path of the dll remains the same( D:\Source\Workspaces\AppName\Branches\Main\Application\packages\Microsoft.ApplicationInsights.Web.2.4.1\lib\net45\Microsoft.AI.Web.dll).

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
TDeoodfig
  • 99
  • 2
  • 9

1 Answers1

1

Since it's a Microsoft strong signed DLL, add it to the server's GAC.

If you place it in the GAC, it'll find the file automatically. Another plus there is that if you need it for another project deployed on the same server, you don't need to deploy it again.

Here's some information on how to install a DLL into the GAC on the server machine, assuming gacutil is not installed there. Look at the accepted answer, not the question. Drag and drop a DLL to the GAC ("assembly") in windows server 2008 .net 4.0

Copy gacutil.exe and gacutil.exe config from your machine to the server's C:\Windows\Microsoft.NET\Framework\v4.0.30319

Then run on the server: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\gacutil.exe" /i "PATH TO YOUR DLL"

Ctznkane525
  • 7,297
  • 3
  • 16
  • 40
  • sorry, I do not know what you mean by "add it to the server's GAC". Could you elaborate? Do you mean instead of downloading the Microsoft.ApplicationInsights.Web NuGet package(contains Microsoft.AI.Web) to D:\Source\Workspaces\AppName\Branches\Main\Application\packages\, I would move them over to GAC folder in C drive and point the dlls to there in References? – TDeoodfig Jan 03 '18 at 15:38
  • If you've got a DLL in the GAC folder of your server you don't need it in the project folder – nano Jan 03 '18 at 15:40
  • If you place it in the GAC, it'll find the file automatically. Another plus there is that if you need it for another project deployed on the same server, you don't need to deploy it again. – Ctznkane525 Jan 03 '18 at 15:45
  • I will try that. But that still doesn't answer my original question. Why is VS looking for the dll's in a different folder? There shouldn't be any difference where I put the dll as long as I point it to the location in the References/.csproj right? – TDeoodfig Jan 03 '18 at 16:15
  • For the development machine, it's looking in your application bin folder, which is a default behavior. If you have it as a reference, then use the option to copy the reference to the output directory. If you do an F5 on the references list, you should see it as an option. – Ctznkane525 Jan 03 '18 at 16:17
  • @Ctznkane525 I have had "CopyLocal" as true. F5 starts the app, I don't know if you have different keybindings. I have also tried deleting the bin folder and it does not build anything there. It builds to "..\Any\Debug\" like I want to. It won't pick up the dll(in D:\Source\Workspaces\AppName\Branches\Main\Application\packages) if the output is set to "..\Any\Debug\" while if the output is "bin" it will. – TDeoodfig Jan 03 '18 at 16:24
  • @Ctznkane525 copy the dll from the Main\Application\packages to the output folder of "..\Any\Debug\" will not work since it already exists in "..\Any\Debug\". Since it is referenced, when I build, it will copy the dll from packages folder to Debug folder. Still not working though. – TDeoodfig Jan 03 '18 at 16:30
  • I don't know, but if you don't want to use the GAC and want another alternative, you can always use the build events section of the project and have it open to the area you desire after the build. – Ctznkane525 Jan 03 '18 at 16:48
  • @Ctznkane525 I tried adding the dll to GAC and then pointing it to that folder in References and it still shows the same error message. – TDeoodfig Jan 03 '18 at 18:41