Jon's Blog

.NET Development & More

Visual Studio: System.Web.AspNetHostingPermission Failed

I got this error in Visual Studio when I was running one of our projects on a new development machine where I had just recently installed a fresh copy of Visual Studio 2008.  After installing the Microsoft .NET SDK this error went away.  Hopefully this post helps someone else out there.

Problem Debugging ASHX HTTP Handler

Today I had a problem hitting a breakpoint in an .ASHX file I created.  I noticed the project was using the built-in Visual Studio Development Server.  Once I switched over to using IIS I had no problem hitting the breakpoint.  I thought it was very strange, but hopefully this might help someone else out if they manage to find this post via Google.

LINQ: Mapping to an Enumerated Type in the LINQ Designer

Below is the syntax you can use in the Properties window of the LINQ Designer to map to an enum.  Set this under the Type property and use the fully qualified name of your enum.

Example: global::MyClassLibrary.MyStuff.MyClassName

Screenshot:

Visual Studio: Build failed due to validation errors in dbml file

Today, while attempting to build a class library on our build box I received the following error in Visual Studio 2008:

"Build failed due to validation errors in [FileName].dbml.  Open the file and resolve the issues in the Error List, then try rebuilding the project."

However, when I went to the dbml file no errors were shown in the error list.  To resolve this I deleted the .designer.cs file associated with the dbml file.  Then in Solution Explorer I right-clicked on the dbml file and selected "Run Custom Tool."  This regenerated the .cs file and I was then able to see the error, which was the following:

"DBML1005: Mapping between DbType 'Date' and Type 'System.DateTime' in Column '[ColumnName]' of Type '[TypeName]' is not supported."

This was easy enough to fix.  The Server Data Type just needed to be changed to DateTime.  Strangely enough having just Date on my development machine did not break the build.

I believed the root of the problem may be that the version of Visual Studio on my development machine was 9.0.30729.1 SP and the build machine was 9.0.21022.8 RTM.

LINQ, Visual Studio, and Stored Procedure Mapping

So the other day while attempting to drag a stored procedure onto the LINQ Designer in Visual Studio I received the following error:

VS_LINQ_Proc_Error

The stored procedure was rather complex including a call to FREETEXT and for some reason the LINQ Designer would not accept it, so I manually mapped the stored procedure for the DataContext.  For future reference, here is some sample code:

public partial class MyDataContext
{
[Function(Name = "dbo.MyStoredProc")]
public ISingleResult<MyClass> MyProcName(
[Parameter(Name = "Parameter1")] int? parameter1,
[Parameter(Name = "Parameter2")] ProductCategory? parameter2,
[Parameter(Name = "Parameter3")] bool? parameter3)
{
IExecuteResult result = this.ExecuteMethodCall(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())),
parameter1, parameter2, parameter3);

return ((ISingleResult<MyClass>)(result.ReturnValue));
}
}

 

Then you can call the stored procedure in code like so:

var results = myDC.MyProcName(parameter1, parameter2, parameter3);