Archive for June, 2006

Protected: Microsoft WPF Issues…

Categories: WPF
Enter your password to view comments.

This content is password protected. To view it please enter your password below:


It hasn’t been that long since I blogged about innovation in Greece
Well it seems that someone else beside me cares and decided to do something about it. OTENET (the Government’s internet provider) is hosting a 50000€ competition for the most innovating idea. I just wish that this will be a fair competition and that this will lead into things getting better for IT in Greece.


I’ve been playing around with WinFx… sorry .Net Framework 3.0 for quite some time now and faced a number of issues with those early releases with the most irritating one being the crashing of Visual Studio 2005 when, while debugging an application, an unhandled exception occurred. It’s comforting to see though that most of the things that annoyed my in those early releases have already been resolved by the VS Team in .Net Framework 3.0 beta 2.


Microsoft’s personal web starter kit, included in Visual Studio 2005, contains two small bugs.
Issue 1: In the photos administration page the ObjectDataSource used for the CRUD (CreateRemoveUpdateDelete) operations does not provide any parameter declarations for the update and delete functions. Thus when trying to update or delete a photo you get an exception saying that the method call requires a parameter that’s not provided.

<asp:ObjectDataSource ID=”ObjectDataSource1″ Runat=”server” TypeName=”PhotoManager” SelectMethod=”GetPhotos” InsertMethod=”AddPhoto” DeleteMethod=”RemovePhoto” UpdateMethod=”EditPhoto” >
  <
SelectParameters>
    <
asp:QueryStringParameter Name=”AlbumID” Type=”Int32″ QueryStringField=”AlbumID” />
  SelectParameters>
  <
InsertParameters>
    <
asp:QueryStringParameter Name=”AlbumID” Type=”Int32″ QueryStringField=”AlbumID” />
  InsertParameters>
asp:ObjectDataSource>

Issue 2: If you install the database backend by running the script provided (personal-add.sql) in the PWS folder (usefull when you’re usind a shared hosting service) the EditAlbum and EditPhoto stored procedures have different parameter names than the ones provided in the Photos.aspx administration page (original_AlbumId and original_PhotoId is needed) causing a parameter exception when trying to update either an album or a photo.
CREATE PROCEDURE EditAlbum
@Caption nvarchar(50),
@IsPublic bit,
@AlbumID int
AS …
CREATE PROCEDURE
EditPhoto
@Caption nvarchar(50),
@PhotoID int
AS …

I’m sure that the people behind the SK have already noticed the problem and published or going to publish a fix for it. I just thought that I should let everyone know since I’ve already stumbled on them.


It seems that the way visual studio understands the SQLExpress server name has changed or that security settings have disabled the .SQLExpress syntax (which obviously meant local computer SQLExpress instance) on Vista. So if you try to create a new database from the AddItem menu item of visual studio 2005 or connect to an existing one that uses the above syntax in the connection string you will most probably get an error saying that “failed to generate a user instance of sql server”.
What you’ll have to do (this took me a while to figure out, so you should thank me 🙂 ) is modify the server name/instance to the fully qualified one. If you want to create a new database you should first create it from the management studio, then add it to your project and modify the connection string.


Continuing my Vista setup and exploration, I begun installing all the software and components I used in order to develop software. Most of the MSI installation packages (including Microsoft’s CAB) though failed to complete under Vista.
It seems that some kind of privileged action needed in order to complete the installation, which is probably write access to the program files directory in order to write an InstallerState file is not allowed not even when the executable is running under an administrative account. The error message says that “Access to the path c:program filesprogramprogramInstall.InstallState is denied (P.S not event the administrator can change the access rights). The installation completes successfully though when a different installation path is specified (e.g. C:Program).
Ok it’s nice to protect the OS from various things that could damage it but from the experienced user’s perspective it gets really frustrating having to confirm every administrative action through a dialog or not allowing write access to the Program Files folder.


I’m developing a web application which takes advantage of Microsoft Enterprise Library’s Logging block to log Errors in a custom sink I’ve developed. Now in order to log unhandled exceptions I’ve hooked on the Application_Error event of the HttpApplication object, the code looks something like that:


void application_Error(object sender, EventArgs e)


{


  HttpApplication app = (HttpApplication)sender;


  Exception error = app.Server.GetLastError();


  if (error != null)


  {


    LogEntry errorEntry = new LogEntry();


    errorEntry.Title = error.Message;


    errorEntry.Categories.Add(“General”);


    errorEntry.EventId = (int)(LoggingErrorCodes.Unhandled_Error);


    errorEntry.Severity = System.Diagnostics.TraceEventType.Error;


    errorEntry.ExtendedProperties.Add(“CallStack”, error.StackTrace);


    Logger.Write(errorEntry);


    app.Server.ClearError();


  }


}


So far so good, when I run the application though, I was getting an exception for almost every request made, which resulted of course in a log entry beeing written on the log. The exception had the intuitive message “File does not exist.” , the exception type was HttpException and the call stack indicated that the exception was originating from the ProcessRequestInternal method of HttpStaticHandler class. Finally the page was loading up fine (no obvious errors).
Ok here is the trivia question (don’t read bellow before answering that ;-)) can you imagine why this was happening?


After spending a couple of hours on that and doing a little disassembling on the HttpStaticHandler class (sorry MS had no other way) I’ve discovered that a file was actually missing and that’s why I was getting the exception,


internal static void ProcessRequestInternal(HttpContext context)


{


  HttpRequest request1 = context.Request;


  HttpResponse response1 = context.Response;


  string text1 = request1.PhysicalPath;


  if (!HostingEnvironment.UsingMapPathBasedVirtualPathProvider)


  {


    StaticFileHandler.RespondUsingVirtualFile(request1.FilePath, response1);


  }


  else


  {


    FileInfo info1;


    if (!FileUtil.FileExists(text1))


    {


      throw new HttpException(0x194, SR.GetString(“File_does_not_exist”));


    }



But which file? Once more the page I was requesting was loading up fine. Can you, after these clues, imagine what was going on?


If you still don’t know, here is the solution to the trivia. I’ve put a watch on the ((HttpApplication)sender).context.Request object and set a breakpoint in the application error event handler. From the Request object I found out that the blank.gif (from the name you can see why I was seeing no difference on the page) was missing from a javascript component that was trying to load it at runtime.

If only the guy who wrote the ProcessRequestInternal method of the HttpStaticHandler class had added the text1 local variable in the exception information it would have saved me a lot of time and efford from trying to find out the error. So the lesson learned here is “Always include helpful information to your exceptions” it will make the life of other developers a lot easier…


I’ve just noticed that I didn’t have comments enabled for my posts, sorry guys that wasn’t intentional but a configuration error.
What troubles me is that nobody contact me, to let me know of this error. This could either mean that nobody reads my blog or that no one had anything to say on my posts.
In any case I won’t be discouraged I will keep blogging regularly and hope that someone is or will be reading me …


The world’s oldest computer, seems to be Greek as joint British-Greek research seems to suggest.…
What’s strange though, is how from a culture that could innovate by creating such computing devices we reached the point of being almost last (40th among other European countries) according to the
ICTDI (Information Communication Technology Diffusion Index) of Europe’s Information Society (i2010).


Installing all the software I need in my new Operating System, I’ve stumbled across my first real problem, (had various other small ones, which didn’t worth mentioning) Source Control. VSS 2005 does not install on Vista. I get a software requirement error, stating that Windows XP SP2 is needed in order to complete the installation. So if someone plans on checking out code from office and work at home with it in his Vista enabled laptop, he better forget about it, or use another source control system L. I wonder if there is any work around I could use…
I’m curious what source control Microsoft’s engineers/developers use for their code if  VSS does not work with vista?