I dealt with a very annoying issue today involving an ASP.NET 3.5 Web Application being compiled to a single assembly through a Web Deployment Project in Visual Studio 2008. The Web.config file contains a number of mappings to ensure that the correct 3.5 Controls and dependent assemblies are loaded by ASP.NET as runtime.
It seems as though some controls, including the ListView, require that the Web.config file must be present as part of the Web Deployment Project output files. If not present, you will receive the following error when building the Web Deployment Project:
- Unknown server tag ‘asp:ListView’
To replicate:
- Create new Web Application project
- Edit Default.aspx by adding ListView control
- Create Web Deployment Project for Web Application
- Edit Web Deployment Project file and add the following line to the <ItemGroup>:
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\*.config" />
- Build the Web Deployment Project
- Observe build failure as described above
I’m not sure if this is a bug with the Web Deployment Projects, but it is certainly rather annoying as this was the last place I though of looking for the resolution.
Microsoft released the ASP.NET Charting Control for .NET 3.5 SP1 on Tuesday and it looks very promising indeed. This isn’t entirely surprising seeing as this control was bought from Dundas before being released as a free download, rather than developed my Microsoft in-house. Downloading and viewing the Samples Pack reveals just how powerful this tool is, and how it can be seamlessly integrated with just about any data source.
I’m not entirely sure what Dundas have achieved by basically creating themselves a new competitor by allowing Microsoft to give the product away for nothing. Unless they are expecting users to want to ‘upgrade’ to the Flash-based Dundas charting tools which are not provided as part of this control.
Happy charting!
A work colleague of mine made me aware of the rather useful CacheDependency class the other day and I’ve been implementing this in various places since. It is useful when you wish to store some data in an ASP.NET web application’s Cache but wish that data to remain in the Cache according to an external influence rather than a time frame.
For example, if you had a typed DataSet and stored some XML that conformed to its Schema on disk, you could use CacheDependency to store the data in the Cache until such time as the physical file is modified.
public static MyDataSet GetDataSet(string path)
{
if (HttpContext.Current.Cache["MyDataSet" + path] == null)
{
MyDataSet ds = new MyDataSet();
try
{
ds.ReadXml(HttpContext.Current.Server.MapPath(path));
}
catch (Exception ex)
{
throw new MyException(string.Format("Unable to load file '{0}' as a MyDataSet", path), ex);
}
CacheDependency dependency = new CacheDependency(HttpContext.Current.Server.MapPath(path));
HttpContext.Current.Cache.Insert("MyDataSet" + path, ds, dependency);
}
return HttpContext.Current.Cache["MyDataSet" + path] as MyDataSet;
}
In the example above, when the file located at path is modified, the Cache will be cleared due to the dependency. When GetDataSet() is next called, the latest version of the file will be loaded into the Cache instead.