Problem with LoadExtensions method

Topics: ASP.NET 2.0
Aug 20, 2010 at 6:28 PM

Hi,

Since last week I'm facing an issue with the Utils.LoadExtensions method in the Application_Start of the Global.asax file.

Some extension files in the datastore/extensions folder seem to be corrupted and make my blog display an error. It works again If I add a try/catch block around the LoadExtensions method but doing that I don't have my extensions anymore.

So I found a solution : delete the xml files in the extensions folder. It works but the same problem come back a few hours later.

Does anyone have an idea to help my fix this ?

Thanks.

Dec 21, 2010 at 6:38 PM

Yes. I am having this same problem and it's making a live production site virtually useless. I cannot find any corrupt XML files, but I don't know what's going wrong here. Any help, MUCH appreciated!

Dec 21, 2010 at 11:39 PM
Edited Dec 22, 2010 at 1:48 AM

If we are talking about BE 2.0, I can confirm this problem.

When I try to add good known and popular YouTube or Vimeo extension I have this error (bottom).

But I found a solution, just add this line to extension file:

using BlogEngine.Core.Web.Extensions;

For example VimeoPlayer.cs :

 

using System;
using BlogEngine.Core;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using BlogEngine.Core.Web.Controls;
using BlogEngine.Core.Web.Extensions;
using System.IO;

///  
.
.
.

 

 

Server Error in '/' Application.

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: CS0246: The type or namespace name 'ExtensionSettings' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

 


Line 15: public class VimeoPlayer
Line 16: {
Line 17: private static ExtensionSettings settings;
Line 18:
Line 19: /// <summary>


Source File: e:\Inetpub\blog\App_Code\Extensions\VimeoPlayer.cs    Line: 17


Show Detailed Compiler Output:

c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\assembly\dl3\da9dd9d1\00d5c915_f69bcb01\BlogEngine.Core.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\assembly\dl3\38c79393\0017bd77_c39bcb01\BlogML.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\assembly\dl3\5019709e\0017bd77_c39bcb01\AjaxMin.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_GlobalResources.-vibanhm.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.43.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.42.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.58.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.55.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.54.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.29.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.28.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.6.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.50.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.25.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.24.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.27.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.26.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.21.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.20.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.23.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.4.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.51.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.53.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.19.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.18.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.7.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.15.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.14.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.17.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.16.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.11.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.10.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.13.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.5.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.49.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.56.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.52.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.47.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.57.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.1.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.39.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.38.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.35.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.34.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.37.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.36.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.31.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.30.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.8.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.32.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.33.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.2.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.12.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.9.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.3.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.48.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.45.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.44.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.22.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.46.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.41.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a4632e0\9393b169\App_Code.1xkvirln.40.cs"


Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.

e:\Inetpub\blog_janarolki.pl\App_Code\Extensions\VimeoPlayer.cs(17,20): error CS0246: The type or namespace name 'ExtensionSettings' could not be found (are you missing a using directive or an assembly reference?)


Show Complete Compilation Source:

Line 1:    using System;
Line 2:    using BlogEngine.Core;
Line 3:    using System.Web;
Line 4:    using System.Web.UI;
Line 5:    using System.Web.UI.HtmlControls;
Line 6:    using System.Text.RegularExpressions;
Line 7:    using BlogEngine.Core.Web.Controls;
Line 8:    using System.IO;
Line 9:    
Line 10:   /// <summary> 
Line 11:   /// Adds a Vimeo video player to the post.  I modified my own YouTube Extension for this project (http://al.bsharah.com/post/2008/10/25/BlogEngineNET-Extension-Vimeo-Video.aspx)
Line 12:   ///  which was originally modified from Sean Blakemore's Silverlight Extension.  Find his code here: http://www.flawlesscode.com 
Line 13:   /// </summary> 
Line 14:   [Extension("Adds a Vimeo video player to the post.", "1.1", "<a href=\"http://al.bsharah.com/\">Al Bsharah</a>")]
Line 15:   public class VimeoPlayer
Line 16:   {
Line 17:       private static ExtensionSettings settings;
Line 18:   
Line 19:       /// <summary> 
Line 20:       /// Adds a Vimeo video player to the post. 
Line 21:       /// </summary> 
Line 22:       public VimeoPlayer()
Line 23:       {
Line 24:           Post.Serving += Post_Serving;
Line 25:   
Line 26:           ExtensionSettings initialSettings = new ExtensionSettings(GetType().Name);
Line 27:           initialSettings.Help = "Scale your width and height as you wish.  However, try to keep your width-to-height ratio (width divided by height) within the default range to allow for HD content to be displayed appropriately.";
Line 28:           initialSettings.AddParameter("width", "Width");
Line 29:           initialSettings.AddValue("width", "400");
Line 30:           initialSettings.AddParameter("height", "Height");
Line 31:           initialSettings.AddValue("height", "225");
Line 32:           initialSettings.IsScalar = true;
Line 33:           ExtensionManager.ImportSettings(initialSettings);
Line 34:           settings = ExtensionManager.GetSettings(GetType().Name);
Line 35:       }
Line 36:   
Line 37:       private void Post_Serving(object sender, ServingEventArgs e)
Line 38:       {
Line 39:           if (e.Location != ServingLocation.PostList && e.Location != ServingLocation.SinglePost)
Line 40:               return;
Line 41:   
Line 42:           string regex__1 = @"\[vimeo:.*?\]";
Line 43:           MatchCollection matches = Regex.Matches(e.Body, regex__1);
Line 44:   
Line 45:           if (matches.Count == 0)
Line 46:               return;
Line 47:   
Line 48:           Int32 width = default(Int32);
Line 49:           Int32 height = default(Int32);
Line 50:           String BaseURL = default(String);
Line 51:           String EndURL = default(String);
Line 52:   
Line 53:           try
Line 54:           {
Line 55:               width = Int32.Parse(settings.GetSingleValue("width"));
Line 56:               height = Int32.Parse(settings.GetSingleValue("height"));
Line 57:               BaseURL = "http://vimeo.com/moogaloop.swf?clip_id=";
Line 58:               EndURL = "&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1";
Line 59:           }
Line 60:           catch
Line 61:           { return; } 
Line 62:   
Line 63:           for (int i = 0; i < matches.Count; i++)
Line 64:           {
Line 65:               Int32 length = "[vimeo:".Length;
Line 66:               string mediaFile = matches[i].Value.Substring(length, matches[i].Value.Length - length - 1);
Line 67:   
Line 68:   			string player = @"<object width=""{2}"" height=""{3}"">
Line 69:   								<param name=""allowfullscreen"" value=""true"" />
Line 70:   								<param name=""allowscriptaccess"" value=""always"" />
Line 71:   								<param name=""movie"" value=""{4}{1}{5}"" />
Line 72:   								<embed src=""{4}{1}{5}"" type=""application/x-shockwave-flash"" allowfullscreen=""true"" allowscriptaccess=""always"" width=""{2}"" height=""{3}"">
Line 73:   								</embed>
Line 74:   							 </object>";
Line 75:   
Line 76:               e.Body = e.Body.Replace(matches[i].Value, String.Format(player, i, mediaFile, width, height, BaseURL, EndURL));
Line 77:              
Line 78:           }
Line 79:       }
Line 80:   
Line 81:   }




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Coordinator
Dec 21, 2010 at 11:52 PM

When upgrading to BE 2.0, if you get an error message like you're getting that says:

"The type or namespace name 'ExtensionSettings' could not be found"

There's a simple solution.  Add the following line of code to the top of that file that is giving an error -- VimeoPlayer.cs in this case.

using BlogEngine.Core.Web.Extensions;