How can I solve the “could not load file or assembly 'ADODB' or one of its dependencies. Access is denied” error?

て烟熏妆下的殇ゞ 提交于 2019-12-11 05:47:14

问题


I get, "Solution to "Could not load file or assembly 'ADODB' or one of its dependencies. Access is denied"" and found this link that supposedly has the solution, but it made no difference for me - I still get the same error. I gave full access to the user not only in the folder mentioned in that link (C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files) but also in my virtual directory where ADODB.dll resides (C:\PlatypusCode\platypi\Bin)

Am I barking up the wrong tree? I also gave Full access to the other account that did not have already have it, but that also made no diff. Now everybody on the "Security" tab for ADODB.dll has been granted Full Access, namely:

Authenticated Users
SYSTEM
Administrators (...)
Users (...)

Also, ADODB.dll is version 2.8, which is the version that is expected and is supposedly unloadable.

The err page has this warning:

"WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1", but trying to do so shows no such available setting:

The full err page is appended to the bottom of this post for the ultra-curious.

UPDATE

Could this be the problem? In a file in my project named "DAL05.dll.refresh" it contains this line (only):

..\..\Inetpub\wwwroot\customerreportingnet\bin\DAL05.dll

There is no "customerreportingnet" on my machine.

The virtual directory for this project is C:\CSPortalCode\csportal

Does that mean that I need to change that line in "DAL05.dll.refresh" to this:

..\..\Inetpub\wwwroot\CSPortalCode\csportal\bin\DAL05.dll

?

No...trying that made no difference in the outcome...

UPDATE 2

So here are my solution and project:

With the project highlighted, here are the properties:

So if I understand this correctly, the "Full Path" is the IIS Virtual Directory, which (C:\CSPortalCode\csportal) is indeed where the solution code exists on the hard drive:

...and how it is displayed in IIS:

ADODB.dll is there, in the virtual folder, and it is the same version as expected:

So why is ADODB.dll not being found when running the site?

Possible "issues": When I 2-click the "book" icon to the left of "ADODB.dll" in Solution Explorer, it indicates the .dll is actually version 1 (not 2.8.0.0):

???

Then again, the err msg says "...or one of its dependencies..." How can I know what the dependencies are, and track down which one is not being found (if this is the problem)?

UPDATE 3

Here's an odd thing: I deleted the ADODB.dll from C:\CSPortalCode\csportal\Bin, tried to run the project again (F5, choose to run the last successful build) and it doesn't complain about not finding the MISSING dll; instead, it complains about not finding the next reference.

So what is causing this? Why does removing a reference cause it to no longer be sought?

UPDATE 4

I don't see any properties for the DLL but path, so I don't know how I can set "Embed Interop Types" and "Copy Local" as suggested by Dustin. This is what I see with the DLL selected in Solution Explorer:

It doesn't matter whether I open it as a project (from an .sln file on the hard drive) or as a website (from an IIS site, for which I must start VS in Administrator mode) - in both cases, the DLLs are displayed in a "Bin" folder with only one property ("Full Path"), not as a Reference with multiple properties. Trying to run it has the exact same result, too; so there is no diff in appearance or behavior if opening it as a project (opening the .sln file from one location) or opening it as a website (from the IIS dialog/virtual directory where all the source (except for the .sln, .user, and two .suo files) resides.

UPDATE 5

I had noticed earlier that if I removed ADODB.dll from the project, the runtime err msg was the "next DLL up" - it then said it could not load that one, seeming to no longer care about ADODB.dll.

So, as an experiment, I renamed all the .DLLs in the virtual directory's bin folder to *.dllHide ("ADODB.dllHide", etc.)

But the result of that was to get a runtime err, "Could not load file or assembly 'ADODB.dllHide' or one of its dependencies"

So why is it even looking for a file with an extension of ".dllHide"? Does it just try to load everything in the bin folder? I see no path information anywhere where the project is telling itself where to find ADODB.dll, so I don't know what to think about this...

UPDATE 6

So I removed all the .dlls from the bin folder and tried again. Now I get this:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 
Parser Error Message: Could not load file or assembly 'System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error: 
Line 64:     <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
Line 65:     <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
Line 66:     <add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 67:     <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Line 68:     <add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
Source File: C:\CSPortalCode\csportal\web.config    Line: 66

Line 66 is highlighted/indicated as problematic. So why was it able to add the first two assemblies, but not that one (System.Web.DataVisualization)?

UPDATE 7

So it turns out that the section of web.config in question first apparently loads several assemblies without incident, only revolting once "System.Web.DataVisualization" is reached:

        <compilation debug="true" strict="false" explicit="true">
   <assemblies>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
   </assemblies>

So the/a question now is: where are the other references/assemblies/DLLs being found? If I knew that, I could possibly locate a copy of System.Web.DataVisualization and copy it to there...

UPDATE 8

Commenting out the reference to the "System.Web.DataVisualization" assembly, I now get past the configuration / loading stuff and into the "real" code:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: BC30002: Type 'SQLServer' is not defined.

Source Error:

Line 6:  Public Class CMSDAO
Line 7:      Public Function GetAccountContracts(ByVal memberNo As String, ByVal docYear As String) As DataSet
Line 8:          Dim sqlDAL As New SQLServer()
Line 9:          Dim dset As DataSet
Line 10:         Dim dataConn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))

Source File: C:\CSPortalCode\csportal\App_Code\CMSDAO.vb    Line: 8 

So I get the feeling there will probably be a bunch of these now; but once I add the appropriate .dll back into the bin folder (when I find out which one that is for "SQLServer"), will that just take me back to the original problem, with the "Cannot load 'bla'" errors?

FULL TEXT OF ERROR PAGE

Server Error in '/CPSPortal' Application. Could not load file or assembly 'ADODB' or one of its dependencies. Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileLoadException: Could not load file or assembly 'ADODB' or one of its dependencies. Access is denied. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Assembly Load Trace: The following information can be helpful to determine why the assembly 'ADODB' could not be loaded. WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. Stack Trace: [FileLoadException: Could not load file or assembly 'ADODB' or one of its dependencies. Access is denied.] [FileLoadException: Could not load file or assembly 'ADODB, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.] System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0 System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416 System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166 System.Reflection.Assembly.Load(String assemblyString) +35 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190 [ConfigurationErrorsException: Could not load file or assembly 'ADODB, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11327096 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +232 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +210 System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +76 System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +11316274 System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +185 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +551 [HttpException (0x80004005): Could not load file or assembly 'ADODB, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.] System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +76 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +1012 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +1025 [HttpException (0x80004005): Could not load file or assembly 'ADODB, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11421094 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +11294584 Version Information: Microsoft .NET Framework Version:2.0.50727.5485; ASP.NET Version:2.0.50727.5491

Does it matter that the version differ, even if but only slightly, between .NET Framework and ASP.NET (by 0.006)?

Where are the paths to the references stored in an ASP.NET project? Perhaps it is set to the wrong place...

来源:https://stackoverflow.com/questions/37038838/how-can-i-solve-the-could-not-load-file-or-assembly-adodb-or-one-of-its-depen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!