Tuesday, 25 November 2008

F# - Tutorial 1 - Getting Started and Hello World


recently i have been looking into F#, a rich and purely functional programming language now supported by the .NET framework and developed within the MS research centre.
F# is based on older functional languages such as: Haskell and OCML. Haskell Curry is an infamous mathematician and logistician and this is where the roots of this language originate from...

F# can be run as a standard installer from the research centre website.. or it can be integrated into Visual Studio 2008 by downloading the MSI installer. The latest release is "September 2008 CTP"

Lets have a little look at a simple Hello World application...


//------------------[F# Code]------------------
(*
 
(c) Sean G @ TutorialGenius.com 2008.
 
This sample Hello World application is the keyhole to many F# adventures. Like many other languages, the foundations begin with a Hello World example!
 
*)
 
// Set the compilation warning to light mode; pronounced: "Hash Light".
#light
 
// Output Hello World!
System.Console.WriteLine("Hello World")
 
// Stop console from closing
System.Console.ReadKey(true)

Friday, 31 October 2008

An easy 30KB ISO Mounter


Virtual CD-ROM Control Panel Download


Instructions
=========================
1. Copy VCdRom.sys to your %systemroot%system32drivers folder.
2. Execute VCdControlTool.exe
3. Click "Driver control"
4. If the "Install Driver" button is available, click it. Navigate to the %systemroot%system32drivers folder, select VCdRom.sys, and click Open.
5. Click "Start"
6. Click OK
7. Click "Add Drive" to add a drive to the drive list. Ensure that the drive added is not a local drive. If it is, continue to click "Add Drive" until an unused drive letter is available.
8. Select an unused drive letter from the drive list and click "Mount".
9. Navigate to the image file
, select it, and click "OK". UNC naming conventions should not be used, however mapped network drives should be OK.

You may now use the drive letter as if it were a local CD-ROM device. When you are finished you may unmount, stop, and remove the driver from memory using the driver control.

Wednesday, 29 October 2008

C# - Generating Strong Typed Datasets


Over the past few weeks I have been working with Strong Typed Datasets in C# to parse XML content easily and more efficiently.

If you've ever had an Xml file and struggled to flawlessly parse it without errors, and write it back (using System.Xml namespace objects like: XMLReader or XmlDocument) then you should take a look at Strong typed Datasets.

If you've worked with Datasets, then this should come naturally. The idea is, once the XML content has been parsed into the Dataset, we can access the data through column and row information within the Dataset.

Heres how we go about it...

1. Find the "xsd.exe" tool. This is shipped with all versions of Visual Studio or can be downloaded from Microsoft's download center. This will allow us to create an XSD and .cs file for our Xml File.
2. Ensure your Xml File is valid Xml.
3. Use the xsd.exe tool to create the XSD and .cs from your xml by command line.

xsd.exe .xml - This will generate the schema (XSD) based on the XML File.
xsd.exe .xsd /d - This will generate the .cs based on the schema (XSD).


Heres a batch script to automate this process...

@echo off
 
:BEGIN
 
CLS
 
COLOR A
 
REM --- Get XML file name.
echo "What is the Path/Name of the XML file (excluding '.xml'): "
set /p XMlFile=
echo.
echo.
echo "Generating XSD Schema Definitions..."
xsd.exe %XMlFile%.xml
echo.
echo.
echo "Generating Strongly Typed DataSet file..."
xsd.exe %XMlFile%.xsd /d
echo.
echo.
echo "Strongly Typed DataSet Created Successfully!"
echo.
 
PAUSE


4. Add these 3 files to your C# project. You will notice the class name in the .cs file derives its name from the main tag within your xml. Don't forget to add the namepsace if applicable!
If you have done this corrently, you will notice the class inherits the DataSet class: "global::System.Data.DataSet" .

5. Create a new instance of the class, then call the "ReadXml()" method, specifiying the path to the XML file as a string. This will parse your XML file and popualte the Dataset. As the class was generated from the XSD, the template should match up!

6. You may also note that the instance you've created in step (5) contains accessors (one for each child note of your xml!)... Each of these has a "Rows" accessor, which will return a DataRowCollection object. If we run a loop on this collection, we will be able to extract the information!


If the "ReadXml()" function fails, you may need to re-structure your XML. The erros are quite self-explanatory, but generally this will fail due to an XML parser error.

Sean

Thursday, 23 October 2008

New Blog!!


All the posts below have been migrated from the TutorialGenius.com Tips feed.

The tips feed has now been deprecated and replaced with this blog. It just saves lots of time developing a new manageable blog with a nice GUI!

Installing the same .NET component twice, side by side


If you've ever needed to install the same product (wether its a web service or a DLL) on the same machine, twice! then here is a rought guide on how its performed...

If you notice, when you install an MSI or any DLL onto a system, and this component already exists, you will usually be asked wether to upgrade or remove the currently installed copmponent.

To get around this, we can edit the MSI installer and set the [RemovePreviousVersions] property to False... then set the grey box next to the [ProductCode] property, and generate a new code... this will give your component a new GUID (Global unique ID) and then the system will treat these as two seperate components.

This can also be performed in VS6.0 using a different method!

Make the internet control work with IE7


Heres a simple solution.

Close VB.
Open regedit.

Go to the "HKEY_CLASSES_ROOTTypeLib{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}1.1win32" branch and change the default value from
"C:WINDOWSsystem32ieframe.dll1" to
"C:WINDOWSsystem32ieframe.dll"

this will allow you to use the internet control again!

XAMPP! - PHP, MYSQL, Pear for Windows!


http://www.apachefriends.org/en/xampp-windows.html

this makes life a LOT easier for installing these tools on a windows machine.

The web services enumeration components are not available - Fix


In Visual Studio, if you are attempting to update your web references (Generate a new proxy stub for your web service)... you may come across this error...

"The web services enumeration components are not available!.

you may need to install Visual Studio, but try this first....

devenv /resetskippkgs

It clears some optinos that may have been currupted and clears all SkopLoading tags.

Reference: http://msdn.microsoft.com/en-us/library/ms241276(VS.80).aspx

Deny access to IP Addresses


If you've developed an Admin ASP.NET application, or even PHP (for instance) which manages users and roles within your application, you may want to deny access to certain users and/or roles when it comes to accessing this application.

This can be achieved in web.config, but if this application is located on a remote server, you may want to deny access to all users apart from localhost. IIS allows you to set this configuration.

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/a629438c-45f5-4b6d-a131-87253ae9dc87.mspx?mfr=true

A Better .NET BackGroundWorker!


have you ever wanted a better background worker control for your .NET projects?
Check this out, it currently supports VB.NET and C#.NET and resolves some of the issue currently emcompassed by the default worker.

http://weblogs.asp.net/rosherove/pages/BackgroundWorkerEx.aspx