Friday, December 10, 2010

ASP.NET Impersonation and "Could Not Load File or Assembly" Error

When setting up an ASP.NET site on a server if you are using impersonation on the web site, typically set via the setting, you need to ensure that the user account being impersonated has access to the server. Typically this means you need to add that user account to the Users or Administrators group on the server. 

If you do have the appropriate permissions granted to the impersonating user, you will most likely receive an error message similar to "Could not load file or assembly or one of its dependencies. Access is denied". This is because the account does not have access to write to the c:\Windows\Microsoft.Net\Framework\\Temporary ASP.NET Files" directory.

I have run into this issue numerous times and keep forgetting how to fix, so I finally decided to post it here, in hopes that I will find it the next time and hoepfully help someone else out as well.

Thursday, December 9, 2010

Improving Your Brain Power

Last year my kids received a Nintendo DS for Christmas and my wife purchased Brain Age: Train Your Brain in Minutes a Day! We both really enjoyed the challenge and the kids were actually pretty good at it too. The other day I stumbled upon a website that provides similar (and probably better) brain training. The site is Lumosity and it is a great collection of brain training and grain games that can lead to:
  • Clearer and quicker thinking
  • Improved memory for names, numbers, directions, etc.
  • Increased alertness and awareness
  • Elevated mood
  • Better concentration at work or while driving
Right now they are offering a free 7 day trial of their subscription service. I highly recommend checking it out.

Tuesday, December 7, 2010

VB.NET Sort Comparer

I found myself needing to sort Generic List of custom objects, in this case a list of the last seen users on a website. I wanted to sort the list by Date Last Seen Descending. I am primarily a C# developer, so I knew how to do this with a Delegate method. But, I am using an older version of VB and Delegates are not available. So I headed over to StackOverflow and found this great question, How to Sort A System.Collection.Generic.List in VB.NET. After looking at this article I created the following code:

public class UserLastSeen
public int Id { get; set; }
public string Name { get; set; }
public DateTime LastSeen { get; set;}

public class UserLastSeenSorter
public void GetSortedList()
List(Of UserLastSeen) userList = GetUserList()
userList.Sort(AddressOf UserLastSeenDescendingComparer)
private Function UserLastSeenDescendingComparer(ByVal user1 As UserLastSeen, _ ByVal user2 as UserLastSeen) As Integer
Return user2.LastSeen.CompareTo(user1.LastSeen)

This worked great and was very easy.