Widgets November 2008


I dream in code

About the author

Robert Williams is an internet application developer for the Salem Web Network.
E-mail me Send mail
Go Daddy Deal of the Week: 30% off your order at! Offer expires 11/6/12

Recent comments




Code Project Associate Logo


The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Accessing Global Resource Files from a Class Library in ASP.NET

If you add an App_GlobalResources Folder to your 2.0 web application you may want to access some of the values within it from a class library - such as a Business Logic Layer (BLL). Since there is unlikely to be a reference from your BLL to the main site, and even if there were, the designer class that shadows the resource file is declared with "Friend" keywords so that class would not be visible to the BLL. Therefore trying to call it using the Resources.[Filename].[key] syntax that works from anywhere within the site will not work. Instead you can simply create a wrapper like the following somwhere within your class library:

    1 Imports System.Resources

    2 Imports System.Web


    4 Namespace Resources

    5     Public Class ResourceWrapper


    7         Public Shared Function Strings1(ByVal key As String) As String

    8             Return HttpContext.GetGlobalResourceObject("Strings1", key)

    9         End Function


   11         Public Shared Function Strings2(ByVal key As String) As String

   12             Return HttpContext.GetGlobalResourceObject("Strings2", key)

   13         End Function


   15         Public Shared Function Strings3(ByVal key As String) As String

   16             Return HttpContext.GetGlobalResourceObject("Strings3", key)

   17         End Function


   19     End Class

   20 End Namespace


Then you can retrieve values from the resource files from within your class library simply by passing in the key you want to retrieve:




This example assumes that you have created three .resx resource files inside the App_GlobalResources folder of an ASP.Net Web Application, and that you created them within Visual Studio (as opposed to a text editor for example), and that you named the files "Strings1.resx", "Strings2.resx" and "Strings3.resx", and that Strings1.resx contains the key "SupportEmail".


The Great thing about adding .resx files in this fashion is that you can actually edit the values in a text editor on the live site without having to recompile and republish your entire project. Having said that, adding new key value pairs in the text editor will not create the properties in the class that shadows it, and removing or renaming existig key value pairs could cause runtime errors so if you need to do anything other than change the value of an existing key, do so within visual studio and republish.

Posted by Williarob on Thursday, November 20, 2008 6:06 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Silverlight 1.0 Applications Not Working in Firefox 3.x

If, like me, you suddenly noticed that your silverlight 1.0 application no longer works in Firefox 3.0 then all you need to do is to update your silverlight.js file to the latest version: Download it here: (3.58 kb)

Categories: Silverlight
Posted by Williarob on Thursday, November 20, 2008 7:15 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Could not load file or assembly 'System.Web.Abstractions, Version=, Culture=neutral, PublicKeyToken= 31bf3856ad364e35' or one of its dependencies.

If you had tried to visit this site in mid-November, this is the ugly error message you would have received: "Could not load file or assembly 'System.Web.Abstractions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies". My last update had been 2 full weeks before the site went down. My hosting provider (GoDaddy) assures me that nothing has changed at their end, I knew nothing had changed at my end and the last modified dates of my files on their server reflected this. A republish of the site did not help. Deleting all the files from the server, testing it locally (which worked even though I did not have the missing assembly on my PC) and republishing did not resolve the issue. So while I still have no idea why my project suddenly requires the System.Web.Abstractions.dll assembly I did at least figure out how to bring it back online. First I downloaded the Microsoft ASP.NET MVC Beta installer and ran it on my local machine. Then I searched my hard drive for the System.Web.Abstractions.dll file again and found it here: "C:\Program Files\Microsoft ASP.NET\ASP.NET MVC Preview 3\Assemblies". I FTP'd the file into my bin folder on the server and tested my site. Almost the same error, but instead of not finding the assembly at all, it now found the wrong version. It was looking for version and the latest MVC Beta (BETA 3) has version A quick Google search lead me to this solution which suggested adding a bindingRedirect to my web.config. I added it right before the closing </configuration> tag at the very bottom of my web.config:

  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <assemblyIdentity name="System.Web.Abstractions" publicKeyToken="31BF3856AD364E35"/>
    <bindingRedirect oldVersion="" newVersion=""/>

And voila, the site is back up. Did anyone else experience this issue recently? 2 weeks prior to this I had updated from BlogEngine.Net 1.3 to 1.4.5; and for the first time compiled the site with Visual Studio 2008 instead of Visual Studio 2005. I had also upgraded the Ajax Control Toolkit to version 3.5. However, as I mentioned before, all of this happened a full two weeks before the site went down with this error. I suspect that (since not even a single line of text was changed on this site in all that time) GoDaddy must have applied a service pack, or an update to their server to cause the dependency on the missing assembly. If anyone has more information, please let me know.


Posted by Williarob on Wednesday, November 19, 2008 7:00 PM
Permalink | Comments (2) | Post RSSRSS comment feed