Tuesday, June 07, 2005

Today I had to reinstall SQL Server 2000 on my Windows XP Dev machine - but I had a few problems.

On my first couple of attempts setup would hang with the message "setup is starting the server and installing your chosen configuration". I left if on this screen for about 30 minutes the first time and ended up having to kill the process and the second time around after a reboot I gave it 5 minutes before killing it again.

After goggling my problem I found this KB http://support.microsoft.com/default.aspx?scid=kb;en-us;290991&Product=sql2k#4. After another restart I followed it's instructions but during installation I was informed that my installation had failed and to check the C:\WINDOWS\sqlstp.log log file. It was only when I looked through the log that I realised my mistake. Instead of deleting the contents of C:\WINDOWS\TEMP  I'd deleted the contents of C:\Documents and Settings\Damien\Local Settings\Temp as I'd typed %TEMP% when navigating to it. After another reboot I then following the KB's instructions again, properly this time, and the installation worked.

I'm not sure why this problem occurred in the first place as SQL Server had been uninstalled successfully before the reinstall - another little Windows mystery.

 

 

Tuesday, June 07, 2005 10:20:56 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0]Trackback
 Sunday, June 05, 2005

 

Paul Fallon will be giving a talk on Idigo at the next NIMTUG meeting (Monday 20th June). For more information and to register for the talk visit http://nimtug.org/20-june-2005.aspx. If you're not a member you'll have to join first before registering for the talk. Membership and registration for the talks are free & there's usually a social gathering after the talk with some food & drink.

Sunday, June 05, 2005 8:09:25 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]Trackback
 Thursday, May 05, 2005

Kieran Lynam will be giving a talk on ASP.Net 2.0 to NIMTUG members on Monday 16th May in Belfast. For more information and to register for the talk (which is free) visit http://nimtug.org/16-May-2005.aspx

Thursday, May 05, 2005 4:54:35 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1]Trackback
 Monday, April 25, 2005

This will probably be the last feature update of my AJAX library as it does all I need the moment, but please keep sending me your suggestions as you never know.

Update:

New feature: you now have the ability to pass complex types as parameters. The IAjaxJavaScriptObjectConverter interface has been enhanced and now allows you to define format functions for formatting JavaScript objects into strings that can be passed as parameters.

Web.config: the attribute for adding converters has been changed from 'type' to 'converter'

New Demo: I've created a DateTime converter and extended the StringCollection to include the new features. You can use these as your skeleton converters.

I've also included another demo that allows you to send a complex type as a parameter.

Online demos: The demos are now online after a couple of requests.

Potential Problem: When converting an object to be returned into JavaScript the default converter loops through all the properties and fields and converts them too. Some types reference their parents and these types will cause a memory problem as they will be caught in an infinite loop. To ensure that this does not happen only return types that are known not to do this and if you do require a type that references it parent (or its children which causes the same problem) then write a custom converter and control the conversion process. I was considering requiring that all return types must be referenced in the web.config - but due to the added complexity decided not too. So check all types before returning them!

 

Download  Demos

Monday, April 25, 2005 4:01:17 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1]Trackback
 Saturday, April 23, 2005

Update:

It was pointed out to me by Manu Seiber that not everyone has write access to the /aspnet_client/system_web/[framework version]/ directory and so can't upload the 'ajax.js' file making the library useless. Now I've added the ability to set the javascript directory that the 'ajax.js' file is located. For backward compaitability it defaults to /aspnet_client/system_web/[framework version]/ if not set.

See JavaScript File section in Read Me file.

Download

 |  | 
Saturday, April 23, 2005 10:40:18 AM (GMT Daylight Time, UTC+01:00)  #    Comments [7]Trackback
 Thursday, April 21, 2005

Changes:

  • You now export types with the method TypeExporter.Export instead of MethodHelper.Register
  • Exceptions now work properly

A coupe of people mentioned a bug when pressing F5 could they please give me more details on this and check if the bug is in this release.

http://mcgiv.com/blog/ajax/

 

 |  | 
Thursday, April 21, 2005 9:49:20 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]Trackback
 Tuesday, April 19, 2005

Bug fix:Strings are now encoded before sent to the server, although there are still some problems with unicode characters.

Change:Instead of having to Register the custom Type converters they are now placed in the "ajax" section of web.config. The benifits are that converters can be updated with out having to recompile the whole project. The ajax.js file has been updated so this will have to be replaced.

download AJAX for APS.Net

Using:

within <configuration> add the following

<configSections>

<section name="ajax" type="Ajax.AjaxConfigurationSectionHandler, Ajax" />

</configSections>

and then add each of the converters as below

<ajax>

<add type="Full Type Name, Assembly Name" />

<add type="Ajax.Web.DataTableConverter, Ajax.Web" />

</ajax>

 |  | 
Wednesday, April 20, 2005 6:38:40 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]Trackback

I've updated the Ajax library and added some more functionality.

Thanks to Michael Schwartz for pointing out a security bug - when invoking a method it wasn't checked to see if it had the JavaScriptAccessableMethodAttribute attribute. He also pointed out that DateTime and TimeSpan were not handeled properly - this is also corrected.

Added functionality:

You can now write your own Object Type to JavaScript convert and register it which then overrides the conversion the type from the default.

Converters must implement the IAjaxJavaScriptObjectConverter interface.

    public interface IAjaxJavaScriptObjectConverter
    {
        void ToJavaScript(ref StringBuilder sb, object obj);

        /// <summary>
        /// Converter can be used for multipal Types
        /// Returns the FullName of the types
        /// </summary>
        string[] TypesToConvert{get;}

    }

I've included StringCollection and DataTable as examples in the demo project. You must register a converter during the loading of the Page or UserControl - just like registering a Type for exporting.

            Ajax.JavaScriptHelper.RegisterConverter(new StringCollectionConverter());
            Ajax.JavaScriptHelper.RegisterConverter(new DataTableConverter());

Below is the converter for StringCollection - instred of recreating the object it converts it into an array of strings.

    public class StringCollectionConverter : Ajax.IAjaxJavaScriptObjectConverter
    {
        public StringCollectionConverter()
        {
        }
        #region IAjaxJavaScriptObjectConverter Members

        public void ToJavaScript(ref StringBuilder sb, object obj)
        {
            StringCollection coll = obj as StringCollection;

            if( coll == null )
            {
                return;
            }

            // output as array

            sb.Append('[');

            for(int i=0; i<coll.Count-1; i++)
            {
                Ajax.JavaScriptHelper.ObjectToJavaScript(ref sb, coll[i] );
                sb.Append(',');
            }
            if( coll.Count > 0 )
            {
                Ajax.JavaScriptHelper.ObjectToJavaScript(ref sb, coll[coll.Count-1]);
            }

            sb.Append(']');

        }


        public string[] TypesToConvert
        {
            get{return new string[]{"System.Collections.Specialized.StringCollection"};}
        }

        #endregion
    }

download AJAX for APS.Net

 |  | 
Wednesday, April 20, 2005 12:50:29 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]Trackback

download AJAX for APS.Net

I've written an AJAX library for ASP.Net applications. I got the idea from Michael Schwartz's AJAX Wrapper. It uses the same mechanism for including method signatures (inserting external .js files) but as he hasn't released the source code I'm not too sure how different/similar our implementations are but some of the known differences are:


Only uses one callback function per request (but not required, see next)


Supports synchronous calls as well as asynchronous class. If a callback function is not passed the call returns the request object.


Returns a single response object
   response.value (returned value/object from invoked method)
   response.error (exception/http error)
   response.request (the XmlHttpRequest)


Supports runtime checking of exposed Types - throws an exception if a method that is being exposed doesn't meet the criteria (public static method with parameters of simple types)

Using

Exposing Methods:

You can only expose public static methods with parameters of simple types such as int and bool. To expose the methods add the attribute

[Ajax.JavaScriptAccessableMethod]
public static void MethodName()


Including Method wrappers:

A JavaScript wrapper is generated for each exposed method which adds an extra parameter callback at the end.

public static int TestMethod(int a, int b)

becomes

function TestMethod(a, b, callback)

as youmay have noticed JavaScript being a scripting language doesn't have the rich type system that .Net has so overloaded methods won't work.

To include a type's wrappers register the type during the loading of the the Page or UserControl.

private void Page_Load(object sender, System.EventArgs e)
{
Ajax.MethodHelper.Register(typeof(TypeName));
}

Only the methods declared in the type will be exposed so there is no security problem with exposing base class methods.

Calling method from ClientSide:

Synchronously:

function test()
{
var response = TypeName.MethodName(parameter1, parameter2);
}

Asynchronously:


function test()
{
var response = TypeName.MethodName(parameter1, parameter2, callback);
}
function callback(response)
{
   
}

The response.error property will be null if everything went OK otherwise it will be an exception or "http" if there was a http error.

The response.value property will be the value/object of the methods return type. Objects only contain nonstatic public properties and fields.

function ajax_test_callback(response)
{
if( !response.error )
{
alert('Callback value:typeof = ' + typeof(response.value) + ', value = ' + response.value);
}
else if( response.error == 'http' )
{
alert('A http error occured: ' + request.status);
}
else
{
alert('An exception occured: ' + response.error);
}

}


If anyone has any feedback I really appreciate it.

download AJAX for APS.Net

 |  | 
Tuesday, April 19, 2005 10:47:49 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]Trackback
 Friday, April 15, 2005

Thanks to Clare Dillon Belfast is now also one of the locations for the "Visual C# and Windows Forms in Visual Studio 2005 Tour".

Mike Henderlight (Program Manager for the .Net Client Team) and Luca Bolognese (Program Manager for the C# team) will be giving high level talks about the new features and enhancements in C# 2.0, WinForms and Visual Studio 2005.

More information can be found on Clare's blog and you can also register for the event  which will be held at The Innovation Centre (Northern Ireland Science Park).

 

Friday, April 15, 2005 8:39:42 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]Trackback