Page 1 of 1 in the ASPNET category
# Friday, August 06, 2010
Close up blog entry

The ClientBuildManager is a .NET BCL class that facilitates compiling ASP.NET markup files outside of IIS. I did run into an issue using this class which others may hit as well.

I compiled some ASP.NET MVC .aspx views and tried to get the type using ClientBuildManager.GetCompiledType, but the GetCompiledType function returned null. Hmm…I could see the compilation was working because the assemblies were seemingly generated correctly.

It ends up that the type would not load because the calling project did not reference all the assemblies needed to load the type. The ClientBuildManager compiles the web components in a separate application domain. When trying to retrieve the type, the assembly is loaded into the calling application domain, and then the type retrieval is attempted. If the type can not load no error is thrown, instead you get a null return value.

So make sure the application using ClientBuildManager references all assemblies referenced by the web application you are compiling.

I hope this saves someone some time. It took a bit of head banging to figure this one out. I had to debug down into System.Web to figure out what was going on :-(

Share/Bookmark
Friday, August 06, 2010 10:53:45 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, January 26, 2010
Close up blog entry

I’ve been using a Visual Studio macro to switch between markup and code-behind for years now. I’ve forgotten where I originally obtained the code for this Visual Studio macro.  If you search around you can find incarnations of it floating around the web. I created a really short tutorial explaining how to setup the macro at the end of this post.

Public Sub Switch()
  Dim FileName As String

  If (DTE.ActiveWindow.Document.FullName.ToLower().EndsWith(".cs")) Then
      ' swith from .aspx.cs to .aspx
      FileName = DTE.ActiveWindow.Document.FullName.ToLower().Replace(".cs", "")
      If System.IO.File.Exists(FileName) Then
          DTE.ItemOperations.OpenFile(FileName)
      End If
  ElseIf (DTE.ActiveWindow.Document.FullName.ToLower().EndsWith(".aspx")) Then
      ' swith from .aspx to .aspx.cs 
      FileName = DTE.ActiveWindow.Document.FullName.ToLower().Replace(".aspx", ".aspx.cs")
      If System.IO.File.Exists(FileName) Then
          DTE.ItemOperations.OpenFile(FileName)
      End If
  ElseIf (DTE.ActiveWindow.Document.FullName.ToLower().EndsWith(".ascx")) Then
      FileName = DTE.ActiveWindow.Document.FullName.ToLower().Replace(".ascx", ".ascx.cs")
      If System.IO.File.Exists(FileName) Then
          DTE.ItemOperations.OpenFile(FileName)
      End If
  ElseIf (DTE.ActiveWindow.Document.FullName.ToLower().EndsWith(".master")) Then
      FileName = DTE.ActiveWindow.Document.FullName.ToLower().Replace(".master", ".master.cs")
      If System.IO.File.Exists(FileName) Then
          DTE.ItemOperations.OpenFile(FileName)
      End If
  End If
End Sub

I created a short tutorial to show how to setup the macro in Visual Studio.

I hope this helps! Enjoy :-D

Share/Bookmark
Tuesday, January 26, 2010 12:30:34 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  | 
# Sunday, December 06, 2009
Close up blog entry

Classic ASP.NET uses the page extension .aspx. If you want to hide the .aspx page from the browser URL I’d recommend using URL rewriting to make your pages extensionless.

I’ve created a screencast which goes over the basic idea of how to implement extensionless URLs in your ASP.NET application. I use Microsoft’s URL Rewrite module which can be used for IIS 7. There are other URL rewrite modules available which can be used to accomplish the same thing for IIS 6.

I created this tutorial because of a question about hiding ASP.NET pages extensions on Stack Overflow.

Share/Bookmark
Sunday, December 06, 2009 11:38:20 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [4]  |