Problem Instantiating JavaScriptCompressor()

Dec 21, 2012 at 5:40 PM

I am using Yahoo.Yui.Compressor.dll (2.2.0.0) and trying to instantiate JavaScriptCompressor():

JavaScriptCompressor yahooJSCompressor = new JavaScriptCompressor();

Whenever I do, I immediately see the following exception:

 

Could not load file or assembly 'Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' 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 'Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The system cannot find the file specified.

Source Error:

Line 105:        public String GetFileTextCompressed(String sFilePath)
Line 106:        {
Line 107:            JavaScriptCompressor yahooJSCompressor = new JavaScriptCompressor();
Line 108:            return yahooJSCompressor.Compress(GetFileTextUncompressed(sFilePath));
Line 109:        }


Source File: C:\inetpub\wwwroot\cims\Dev\Web Application\Handlers\CombineFiles\DerivedClasses\Factories\CombineJavaScriptFilesFactory.cs    Line: 107

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' could not be loaded.

=== Pre-bind state information ===
LOG: User = IIS APPPOOL\DefaultAppPool
LOG: DisplayName = Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
 (Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/cims/Dev/Web Application/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\cims\Dev\Web Application\bin
Calling assembly : Yahoo.Yui.Compressor, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\cims\Dev\Web Application\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: Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/cims_dev/b41c6135/d20bd857/Iesi.Collections.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/cims_dev/b41c6135/d20bd857/Iesi.Collections/Iesi.Collections.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/cims/Dev/Web Application/bin/Iesi.Collections.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/cims/Dev/Web Application/bin/Iesi.Collections/Iesi.Collections.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/cims_dev/b41c6135/d20bd857/Iesi.Collections.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/cims_dev/b41c6135/d20bd857/Iesi.Collections/Iesi.Collections.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/cims/Dev/Web Application/bin/Iesi.Collections.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/cims/Dev/Web Application/bin/Iesi.Collections/Iesi.Collections.EXE.


Stack Trace:

[FileNotFoundException: Could not load file or assembly 'Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The system cannot find the file specified.]
   Yahoo.Yui.Compressor.JavaScriptCompressor.InitialiseBuiltIn() +0
   Yahoo.Yui.Compressor.JavaScriptCompressor..cctor() +86

[TypeInitializationException: The type initializer for 'Yahoo.Yui.Compressor.JavaScriptCompressor' threw an exception.]
   Yahoo.Yui.Compressor.JavaScriptCompressor..ctor() +0
   Voyager.Handlers.CombineFiles.DerivedClasses.CombineJavaScriptFilesFactory.GetFileTextCompressed(String sFilePath) in C:\inetpub\wwwroot\cims\Dev\Web Application\Handlers\CombineFiles\DerivedClasses\Factories\CombineJavaScriptFilesFactory.cs:107
   Voyager.TestScriptCompression.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\cims\Dev\Web Application\TestScriptCompression.aspx.cs:22
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627



Version Information: Microsoft .NET Framework Version:2.0.50727.5466; ASP.NET Version:2.0.50727.5456

<!-- [FileNotFoundException]: Could not load file or assembly 'Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The system cannot find the file specified. at Yahoo.Yui.Compressor.JavaScriptCompressor.InitialiseBuiltIn() at Yahoo.Yui.Compressor.JavaScriptCompressor..cctor() [TypeInitializationException]: The type initializer for 'Yahoo.Yui.Compressor.JavaScriptCompressor' threw an exception. at Yahoo.Yui.Compressor.JavaScriptCompressor..ctor() at Voyager.Handlers.CombineFiles.DerivedClasses.CombineJavaScriptFilesFactory.GetFileTextCompressed(String sFilePath) in C:\inetpub\wwwroot\cims\Dev\Web Application\Handlers\CombineFiles\DerivedClasses\Factories\CombineJavaScriptFilesFactory.cs:line 107 at Voyager.TestScriptCompression.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\cims\Dev\Web Application\TestScriptCompression.aspx.cs:line 22 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.testscriptcompression_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cims_dev\b41c6135\d20bd857\App_Web_ncfs1btd.4.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -->
Dec 25, 2012 at 2:05 PM

This happened to me also and solved the problem easily, apparently what i did that caused this problem was copying out Yahoo.Yui.Compressor.dll into my project resources directory alone, the clue to solving this is stated in the error "could not load file or assembly 'iesi.collections'", so basically you need to copy Iesi.Collections.dll and EcmaScript.NET.dll along with Yahoo.Yui.Compressor.dll to get it to work, just to be safe though just copy everything in the downloaded library to your resource folder.

Coordinator
Dec 25, 2012 at 8:46 PM
If you use nuget, you should get only the assemblies you need.
If you download from the site then you need the three Albizart listed if you want to use the library directly.
Add the msbuild or nant assembly for that type of build engine if you use it, and add everything else for erm...whatever the other bit PK address recently...



On 25 Dec 2012, at 14:05, Abizart <notifications@codeplex.com> wrote:

From: Abizart

This happened to me also and solved the problem easily, apparently what i did that caused this problem was copying out Yahoo.Yui.Compressor.dll into my project resources directory alone, the clue to solving this is stated in the error "could not load file or assembly 'iesi.collections'", so basically you need to copy Iesi.Collections.dll and EcmaScript.NET.dll along with Yahoo.Yui.Compressor.dll to get it to work, just to be safe though just copy everything in the downloaded library to your resource folder.

Dec 26, 2012 at 3:22 PM

Thanks guys.  Adding those two additional .dlls solved my problem.

 

Brad

Coordinator
Dec 27, 2012 at 10:57 AM
Edited Dec 27, 2012 at 10:57 AM

@bperniciaro and @Abizart

Thanks for checking out and using YUICompressor :) Also great to hear that the problem was solved.

 

Quick question, though. By the nature of your question, you both downloading the zip file from the codeplex site, right?

If so - why are you guys using the zip download instead of Nuget? Both are perfectly fine ... just curious :)

 

-PK-

Dec 27, 2012 at 1:17 PM

To be honest the code for YUICompressor wasn't very easy for me to find.  I searched for "YUICompressor" and ended up on the developer page (http://developer.yahoo.com/yui/compressor/#work).  From here it wasn't completely obvious where to go next to find the code.  More than once I downloaded the entire YUILibrary thinking it must be in there.  Ultimately I did a search on Google for "YUICompressor Download" or something similar and was brought to the CodePlex site so this is where I downloaded 2.2.0.0 from.  I never had any idea I could get it from anywhere else. 

As I was reading this thread I figured I could get it from somewhere else so I found the "Download Release" link on the YUIlibrary.com page (http://yuilibrary.com/projects/yuicompressor/).   However, this link takes me to "github" with version 2.4.7.  I'm still not sure how to access "Nuget".

So you see it is a bit confusing to determine where we're supposed to be getting the code and exactly what we need to download for a particular task.

Coordinator
Dec 27, 2012 at 1:46 PM

hi m8,

This project is the .NET port of the Yahoo YUI Compressor (which is written in java).  The links you provided are to the original yahoo compressor, and to an overarching YUI project that includes the compressor library, which are run by completely different teams.  Our project should be functionally the same as their yui compressor, but otherwise there is no relationship between us and them. 

If you googled for "YUICompressor .NET" then you would have found us easily enough, but other than that, I'm afraid there's not a lot we can do about the confusion - the YUI guys would have no reason really to include a link on their pags to our project...

Dec 27, 2012 at 2:11 PM

That makes sense.  I inherited my project from someone else and was simply looking to upgrade so I didn't do a lot of researching as I was looking for the new DLLs.  Maybe that was my problem.

Coordinator
Dec 28, 2012 at 6:02 AM

Ah gotcha. You should seriously research what Nuget is and learn to use that in all your Visual Studio solutions/projects. It's one of the best features that has come out, in recent years.

It can also auto notify you when libraries you are using (like YUICompressor.NET) get upgraded :)

Dec 28, 2012 at 1:34 PM

Used it yesterday to grab the latest version of the Ajax Control Toolkit and plan to do the same for YUICompressor.NET.  Thanks for the info.

Dec 31, 2012 at 1:35 PM
Edited Dec 31, 2012 at 1:38 PM

removed