I have been directed by my team lead to remove a dll I am responsible for
from the bin directory of our ASP.NET 2.0 web application by changing the
CopyLocal property to False. I have done this and am getting the following
error:
Could not load file or assembly 'GrangeAJAXComponents' or one of its
dependencies. The system cannot find the file specified.
I have installed GrangeAJAXComponents.dll into the GAC and verified its
version and public key. I have opened the project file in Notepad and
verified that the version number and public key match what is displayed in
the GAC:
<Reference Include="GrangeAJAXComponents, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=82f335bc3105596d, processorArchitecture=MSIL">
<HintPath>C:\Blocks\GrangeAJAXComponents\GrangeAJAXComponents.dll</HintPath>
</Reference>
The Assembly Binging Log from Fusion shows the following:
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
<snip>
LOG: DisplayName = GrangeAJAXComponents
(Partial)
<snip>
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
<snip>
LOG: All probing URLs attempted and failed.
By contrast, another dll which is referenced in precisely the same way has
the following log:
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
<snip>
LOG: DisplayName = WebCustomValidationControls, Version=2.0.0.1,
Culture=neutral, PublicKeyToken=ed0771a7483cd66d
(Fully-specified)
<snip>
LOG: Post-policy reference: WebCustomValidationControls, Version=2.0.0.1,
Culture=neutral, PublicKeyToken=ed0771a7483cd66d
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from
C:\WINDOWS\assembly\GAC_MSIL\WebCustomValidationControls\2.0.0.1__ed0771a7483cd66d\WebCustomValidationControls.dll.
LOG: Assembly is loaded in default load context.
Obviously the problem is that GrangeAJAXComponents is using a partial
binding, but for the life of me i cannot figure out why. Everything about the
way the two dll's are referenced seems to be the same. I've triple-checked
everything and don't know what to try next. Any ideas would be greatly
appreciated.
Did the fusion log for GrangeAJAXComponents say whether it tried to look in the GAC? Does your web.config also have a reference to it (in the assemblies section)?
You can also try writing a simple console application that just does something like that following, just to make sure you can load it in the simplest case:
> Did the fusion log for GrangeAJAXComponents say whether it tried to look in the GAC?
The fusion log for GrangeAJAXComponents indicates that it searched the probing URL's only; it did not try to look in the GAC. It is my understanding that it only checks the GAC for a full bind, as in WebCustomValidationControls, not for a partial bind, which
is what the fusion log indicates was attempted for GrangeAJAXComponents. However, I am unsure why a partial bind was used for GrangeAJAXComponents, since I specified the name, version, and public key correctly for both dll's as you see.
> Does your web.config also have a reference to it (in the assemblies section)?
I've tried it both ways. It is my understanding that the compilation/assemblies section of the web.config applies to web sites, not web application projects, so it would have no affect since this is a web application project. Nonetheless, I've tried it without
these elements as indicated in my original post and with two <add> elements for both dll's. In both cases WebCustomValidationControls was found using a full bind and GrangeAJAXComponents was not found due to the use of a partial bind.
> You can also try writing a simple console application that just does something like that following, just to make sure you can load it in the simplest case:
> > You can also try writing a simple console application that just does something like that following, just to make sure you can load it in the simplest case:
> I will try this tomorrow and see what happens.
I ran the following:
Imports System.Reflection
Module Module1
Sub Main()
Dim result As Assembly = Assembly.Load("GrangeAJAXComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82f335bc3105596d, processorArchitecture=MSIL")
Console.WriteLine(result.FullName)
Console.ReadKey()
End Sub
End Module
The Assembly Binging Log from Fusion shows the following:
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
<snip>
LOG: DisplayName = GrangeAJAXComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82f335bc3105596d, processorArchitecture=MSIL
(Fully-specified)
<snip>
LOG: Post-policy reference: GrangeAJAXComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82f335bc3105596d, processorArchitecture=MSIL
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\WINDOWS\assembly\GAC_MSIL\GrangeAJAXComponents\1.0.0.0__82f335bc3105596d\GrangeAJAXComponents.dll.
LOG: Assembly is loaded in default load context.
So it would seem explicitly loading the assembly using Assembly.Load works great. Why then is my Web Application Project attempting only a partial bind?
The references you have in .csproj or .vbproj are used during compilation of the web application project, for compiling the code files and class files (.cs and .vb) . The references in web.config are used during runtime, for dynamic compilation of the .aspx
pages.
Did you get the assembly not found error during compilation in VS, or during runtime? If it is during compilation in VS, then the references in the project file are used.
You have a hintpath in your project file for the reference GrangeAJAXComponents. I am not sure if that affects the loading or not, perhaps it tells VS to not look in the GAC. Does the reference to WebCustomValidationControls use a hint path too?
==============================================
If you get the answer to your question, please mark it as the answer.
> Did you get the assembly not found error during compilation in VS, or during runtime?
I do not have any errors when I compile the project. When I browse to the page that contains controls from both GrangeAJAXComponents.dll and WebCustomValidationControls.dll (both located in the GAC) I get the error, "Could not load file or assembly 'GrangeAJAXComponents'
or one of its dependencies. The system cannot find the file specified." When I copy GrangeAJAXComponents.dll to the bin directory the page loads correctly.
> I am not sure if that affects the loading or not, perhaps it tells VS to not look in the GAC.
Several other dll's are loaded successfully from the GAC and Visual Studio adds hint paths for those dll's as well. It is my understanding that at compile-time the dll's are retrieved from the hint path, while at run-time the dll is retrieved from the GAC.
No idea why. But in the end it doesn't matter to me where it is retrieved from so long as it is retrieved successfully.
> Does the reference to WebCustomValidationControls use a hint path too?
Both dll's are specified in the project file with similar hint paths: C:\Blocks\GrangeAJAXComponents\GrangeAJAXComponents.dll and C:\Blocks\WebCustomValidationControls\WebCustomValidationControls.dll.
> The references in web.config are used during runtime, for dynamic compilation of the .aspx pages.
As I've said before, I've tried adding the references to the web.config as well to no avail. Regardless of whether the reference is present in web.config, WebCustomValidationControls.dll is always found successfully using a full bind and GrangeAJAXComponents.dll
is not found (due to the partial bind).
Could you run "gacutil /if GrangeAJAXComponents.dll" again, and then run "gacutil /l GrangeAJAXComponents" to make sure that the GAC version is the same as the physical version?
Also, could you post your web.config?
Another thing you could try is to start with a new empty web application project, and then just add a single reference to GrangeAJAXComponents, and see if there are any errors. If not, then slowly add more things bit by bit, perhaps use some code from the
referenced assembly.
==============================================
If you get the answer to your question, please mark it as the answer.
I will post everything this time so you can see exactly what I see. Consequently, this is going to be a very long post.
> Could you run "gacutil /if GrangeAJAXComponents.dll" again, and then run "gacutil /l GrangeAJAXComponents" to make sure that the GAC version is the same as the physical version?
Since I've been working on other items in the interim, I started from scratch. First, I opened C:\Windows\assembly and uninstalled GrangeAJAXComponents.dll and WebCustomValidationControls.dll. Then I copied them from their respective directories back into
the GAC and verified that they were installed. I then ran the commands as you requested. The output follows. As you can see, both dll's are installed similiarly in the GAC:
C:\Program Files\Microsoft Visual Studio 8\VC>gacutil /if C:\Blocks\GrangeAJAXCo
mponents\GrangeAJAXComponents.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly successfully added to the cache
C:\Program Files\Microsoft Visual Studio 8\VC>gacutil /l GrangeAJAXComponents
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
GrangeAJAXComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82f335b
c3105596d, processorArchitecture=MSIL
Number of items = 1
C:\Program Files\Microsoft Visual Studio 8\VC>gacutil /if C:\Blocks\WebCustomVal
idationControls\WebCustomValidationControls.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly successfully added to the cache
C:\Program Files\Microsoft Visual Studio 8\VC>gacutil /l WebCustomValidationCont
rols
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
WebCustomValidationControls, Version=2.0.0.1, Culture=neutral, PublicKeyToken=
ed0771a7483cd66d, processorArchitecture=MSIL
Number of items = 1
C:\Program Files\Microsoft Visual Studio 8\VC>
I checked the project file to be sure the references were still correct. Since the project file is over 6000 lines long and I can't attach files, I'm posting only the references:
I added both references to the web.config since your last post suggested you thought that was the way to go. Again, since the web.config is nearly 1000 lines long, I'm only posting the system.web section and deleting the comments:
Next, I deleted everything from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files, cleared the IE cache, and ran iisreset. I verfied that GrangeAJAXComponents.dll and WebCustomValidationControls.dll were deleted from the bin directory.
I compiled the project and the output showed no errors.
------ Build started: Project: CommonLibrary, Configuration: Debug Any CPU ------
CommonLibrary -> C:\Projects\dotNET\Commercial2_0Solution\CommonLibrary\bin\CommonLibrary.dll
------ Build started: Project: Utilities, Configuration: Debug Any CPU ------
Utilities -> C:\Projects\dotNET\Commercial2_0Solution\Utilities\bin\Utilities.dll
------ Build started: Project: DataAccess, Configuration: Debug Any CPU ------
DataAccess -> C:\Projects\dotNET\Commercial2_0Solution\DataAccess\bin\DataAccess.dll
------ Build started: Project: Business, Configuration: Debug Any CPU ------
Business -> C:\Projects\dotNET\Commercial2_0Solution\Business\bin\Business.dll
------ Build started: Project: SegmentLibrary, Configuration: Debug Any CPU ------
SegmentLibrary -> C:\Projects\dotNET\Commercial2_0Solution\SegmentLibrary\bin\SegmentLibrary.dll
------ Build started: Project: DataService, Configuration: Debug Any CPU ------
DataService -> C:\Projects\dotNET\Commercial2_0Solution\DataService\bin\DataService.dll
------ Build started: Project: Policy, Configuration: Debug Any CPU ------
Policy -> C:\Projects\dotNET\Commercial2_0Solution\Policy\bin\Policy.dll
------ Build started: Project: Commercial, Configuration: Debug Any CPU ------
Commercial -> C:\Projects\dotNET\Commercial2_0Solution\Commercial\bin\GainCL.dll
========== Build: 8 succeeded or up-to-date, 0 failed, 0 skipped ==========
I started up fuslogvw.exe and browsed to the web page in question and got the following error:
Server Error in '/Commercial' Application.
Could not load file or assembly 'GrangeAJAXComponents' or one of its dependencies. The system cannot find the file specified.
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.FileNotFoundException: Could not load file or assembly 'GrangeAJAXComponents' or one of its dependencies. The system cannot find the file specified.
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 'GrangeAJAXComponents' could not be loaded.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\windows\microsoft.net\framework\v2.0.50727\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = GMCC\mercierj
LOG: DisplayName = GrangeAJAXComponents
(Partial)
LOG: Appbase = file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/
LOG: Initial PrivatePath = C:\Projects\DotNet\Commercial2_0Solution\Commercial\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\DotNet\Commercial2_0Solution\Commercial\web.config
LOG: Using host configuration file: c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents/GrangeAJAXComponents.EXE.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents.EXE.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents/GrangeAJAXComponents.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'GrangeAJAXComponents' or one of its dependencies. The system cannot find the file specified.]
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) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.UI.AssemblyCache.Load(String assemblyName) +73
System.Web.UI.ScriptManager.RemoveDuplicates(List`1 scripts) +652
System.Web.UI.ScriptManager.RegisterScripts() +388
System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +111
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2058052
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1566
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
The Fusion Log for GrangeAJAXComponents.dll follows:
*** Assembly Binder Log Entry (2/13/2008 @ 1:59:45 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\windows\microsoft.net\framework\v2.0.50727\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = GMCC\mercierj
LOG: DisplayName = GrangeAJAXComponents
(Partial)
LOG: Appbase = file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/
LOG: Initial PrivatePath = C:\Projects\DotNet\Commercial2_0Solution\Commercial\bin
LOG: Dynamic Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\commercial\44bde780
LOG: Cache Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\commercial\44bde780
LOG: AppName = 9d027b4
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\DotNet\Commercial2_0Solution\Commercial\web.config
LOG: Using host configuration file: c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents/GrangeAJAXComponents.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/commercial/44bde780/9d027b4/GrangeAJAXComponents/GrangeAJAXComponents.EXE.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents.EXE.
LOG: Attempting download of new URL file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/bin/GrangeAJAXComponents/GrangeAJAXComponents.EXE.
LOG: All probing URLs attempted and failed.
Here is the Fusion Log for WebCustomValidationControls:
*** Assembly Binder Log Entry (2/13/2008 @ 1:59:41 PM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\windows\microsoft.net\framework\v2.0.50727\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = GMCC\mercierj
LOG: DisplayName = WebCustomValidationControls, Version=2.0.0.1, Culture=neutral, PublicKeyToken=ed0771a7483cd66d
(Fully-specified)
LOG: Appbase = file:///C:/Projects/DotNet/Commercial2_0Solution/Commercial/
LOG: Initial PrivatePath = C:\Projects\DotNet\Commercial2_0Solution\Commercial\bin
LOG: Dynamic Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\commercial\44bde780
LOG: Cache Base = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\commercial\44bde780
LOG: AppName = 9d027b4
Calling assembly : GainCL, Version=1.0.2965.18112, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\DotNet\Commercial2_0Solution\Commercial\web.config
LOG: Using host configuration file: c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: WebCustomValidationControls, Version=2.0.0.1, Culture=neutral, PublicKeyToken=ed0771a7483cd66d
LOG: Binding succeeds. Returns assembly from C:\WINDOWS\assembly\GAC_MSIL\WebCustomValidationControls\2.0.0.1__ed0771a7483cd66d\WebCustomValidationControls.dll.
LOG: Assembly is loaded in default load context.
As you can see, even though both dll's are included in the project in exactly the same way, WebCustomValidationControls succeeds while GrangeAJAXComponents fails. More specifically, it fails because a partial bind is attempted rather than a full bind, as
in WebCustomValidationControls. Why is this happening?
> Another thing you could try is to start with a new empty web application project, and then just add a single reference to GrangeAJAXComponents, and see if there are any errors.
I took your advice and created a new AJAX-enabled web application project. I added a reference to GrangeAJAXComponents.dll and added the following markup to default.aspx:
I did not modify the code-behind or web.config. The project compiles without errors. When I run the project and IE loads default.aspx, I get the same error as before. Thus, the problem is easily reproducible in a simple project (which I had not expected).
What now?
This is strange. We must be missing something that could be simple. It is not clear why in the fusion log we see an attempt to load with only the partial name, and not the fully qualified assembly name.
Does GrangeAJAXComponents.dll have any dependencies on other dlls?
==============================================
If you get the answer to your question, please mark it as the answer.
Cheetiah
0 Points
9 Posts
Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 09, 2008 01:37 PM|LINK
hongping
Contributor
3403 Points
635 Posts
Microsoft
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 11, 2008 05:26 PM|LINK
Did the fusion log for GrangeAJAXComponents say whether it tried to look in the GAC? Does your web.config also have a reference to it (in the assemblies section)?
You can also try writing a simple console application that just does something like that following, just to make sure you can load it in the simplest case:
System.Reflection.Assembly.Load("GrangeAJAXComponents, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=82f335bc3105596d, processorArchitecture=MSIL")
If you get the answer to your question, please mark it as the answer.
Cheetiah
0 Points
9 Posts
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 12, 2008 03:30 AM|LINK
> Did the fusion log for GrangeAJAXComponents say whether it tried to look in the GAC?
The fusion log for GrangeAJAXComponents indicates that it searched the probing URL's only; it did not try to look in the GAC. It is my understanding that it only checks the GAC for a full bind, as in WebCustomValidationControls, not for a partial bind, which is what the fusion log indicates was attempted for GrangeAJAXComponents. However, I am unsure why a partial bind was used for GrangeAJAXComponents, since I specified the name, version, and public key correctly for both dll's as you see.
> Does your web.config also have a reference to it (in the assemblies section)?
I've tried it both ways. It is my understanding that the compilation/assemblies section of the web.config applies to web sites, not web application projects, so it would have no affect since this is a web application project. Nonetheless, I've tried it without these elements as indicated in my original post and with two <add> elements for both dll's. In both cases WebCustomValidationControls was found using a full bind and GrangeAJAXComponents was not found due to the use of a partial bind.
> You can also try writing a simple console application that just does something like that following, just to make sure you can load it in the simplest case:
I will try this tomorrow and see what happens.
Cheetiah
0 Points
9 Posts
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 12, 2008 05:42 PM|LINK
> > You can also try writing a simple console application that just does something like that following, just to make sure you can load it in the simplest case:
> I will try this tomorrow and see what happens.
I ran the following:
Imports System.Reflection Module Module1 Sub Main() Dim result As Assembly = Assembly.Load("GrangeAJAXComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82f335bc3105596d, processorArchitecture=MSIL") Console.WriteLine(result.FullName) Console.ReadKey() End Sub End ModuleThe output was:
The Assembly Binging Log from Fusion shows the following:
So it would seem explicitly loading the assembly using Assembly.Load works great. Why then is my Web Application Project attempting only a partial bind?
hongping
Contributor
3403 Points
635 Posts
Microsoft
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 12, 2008 05:54 PM|LINK
The references you have in .csproj or .vbproj are used during compilation of the web application project, for compiling the code files and class files (.cs and .vb) . The references in web.config are used during runtime, for dynamic compilation of the .aspx pages.
Did you get the assembly not found error during compilation in VS, or during runtime? If it is during compilation in VS, then the references in the project file are used.
You have a hintpath in your project file for the reference GrangeAJAXComponents. I am not sure if that affects the loading or not, perhaps it tells VS to not look in the GAC. Does the reference to WebCustomValidationControls use a hint path too?
If you get the answer to your question, please mark it as the answer.
Cheetiah
0 Points
9 Posts
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 13, 2008 03:19 AM|LINK
> Did you get the assembly not found error during compilation in VS, or during runtime?
I do not have any errors when I compile the project. When I browse to the page that contains controls from both GrangeAJAXComponents.dll and WebCustomValidationControls.dll (both located in the GAC) I get the error, "Could not load file or assembly 'GrangeAJAXComponents' or one of its dependencies. The system cannot find the file specified." When I copy GrangeAJAXComponents.dll to the bin directory the page loads correctly.
> I am not sure if that affects the loading or not, perhaps it tells VS to not look in the GAC.
Several other dll's are loaded successfully from the GAC and Visual Studio adds hint paths for those dll's as well. It is my understanding that at compile-time the dll's are retrieved from the hint path, while at run-time the dll is retrieved from the GAC. No idea why. But in the end it doesn't matter to me where it is retrieved from so long as it is retrieved successfully.
> Does the reference to WebCustomValidationControls use a hint path too?
Both dll's are specified in the project file with similar hint paths: C:\Blocks\GrangeAJAXComponents\GrangeAJAXComponents.dll and C:\Blocks\WebCustomValidationControls\WebCustomValidationControls.dll.
> The references in web.config are used during runtime, for dynamic compilation of the .aspx pages.
As I've said before, I've tried adding the references to the web.config as well to no avail. Regardless of whether the reference is present in web.config, WebCustomValidationControls.dll is always found successfully using a full bind and GrangeAJAXComponents.dll is not found (due to the partial bind).
What else can I do?
hongping
Contributor
3403 Points
635 Posts
Microsoft
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 13, 2008 05:14 PM|LINK
Could you run "gacutil /if GrangeAJAXComponents.dll" again, and then run "gacutil /l GrangeAJAXComponents" to make sure that the GAC version is the same as the physical version?
Also, could you post your web.config?
Another thing you could try is to start with a new empty web application project, and then just add a single reference to GrangeAJAXComponents, and see if there are any errors. If not, then slowly add more things bit by bit, perhaps use some code from the referenced assembly.
If you get the answer to your question, please mark it as the answer.
Cheetiah
0 Points
9 Posts
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 13, 2008 07:31 PM|LINK
> Also, could you post your web.config?
I will post everything this time so you can see exactly what I see. Consequently, this is going to be a very long post.
> Could you run "gacutil /if GrangeAJAXComponents.dll" again, and then run "gacutil /l GrangeAJAXComponents" to make sure that the GAC version is the same as the physical version?
Since I've been working on other items in the interim, I started from scratch. First, I opened C:\Windows\assembly and uninstalled GrangeAJAXComponents.dll and WebCustomValidationControls.dll. Then I copied them from their respective directories back into the GAC and verified that they were installed. I then ran the commands as you requested. The output follows. As you can see, both dll's are installed similiarly in the GAC:
I checked the project file to be sure the references were still correct. Since the project file is over 6000 lines long and I can't attach files, I'm posting only the references:
I added both references to the web.config since your last post suggested you thought that was the way to go. Again, since the web.config is nearly 1000 lines long, I'm only posting the system.web section and deleting the comments:
Next, I deleted everything from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files, cleared the IE cache, and ran iisreset. I verfied that GrangeAJAXComponents.dll and WebCustomValidationControls.dll were deleted from the bin directory. I compiled the project and the output showed no errors.
I started up fuslogvw.exe and browsed to the web page in question and got the following error:
The Fusion Log for GrangeAJAXComponents.dll follows:
Here is the Fusion Log for WebCustomValidationControls:
Cheetiah
0 Points
9 Posts
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 13, 2008 07:44 PM|LINK
> Another thing you could try is to start with a new empty web application project, and then just add a single reference to GrangeAJAXComponents, and see if there are any errors.
I took your advice and created a new AJAX-enabled web application project. I added a reference to GrangeAJAXComponents.dll and added the following markup to default.aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="MicrosoftGacTest._Default" %> <%@ Register TagPrefix="GainWeb" Namespace="GrangeAJAXComponents" Assembly="GrangeAJAXComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82f335bc3105596d, processorArchitecture=MSIL" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server" MaxLength="5"></asp:TextBox> <GainWeb:AutoTabExtender ID="AutoTabExtender1" runat="server" TargetControlID="TextBox1" /> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </div> </form> </body> </html>I did not modify the code-behind or web.config. The project compiles without errors. When I run the project and IE loads default.aspx, I get the same error as before. Thus, the problem is easily reproducible in a simple project (which I had not expected). What now?
hongping
Contributor
3403 Points
635 Posts
Microsoft
Re: Help with Assembly Binding in ASP.NET 2.0 Web Application Projects
Feb 13, 2008 10:25 PM|LINK
This is strange. We must be missing something that could be simple. It is not clear why in the fusion log we see an attempt to load with only the partial name, and not the fully qualified assembly name.
Does GrangeAJAXComponents.dll have any dependencies on other dlls?
If you get the answer to your question, please mark it as the answer.