Tuesday, August 11, 2009

Counting code lines in .NET Visual Studio project

I recently found a really useful tool to count the number of lines in a c# or vb.net project or solution.

The tool is available for free download at the following URL:

http://richnewman.wordpress.com/2007/07/09/c-visual-basic-and-c-net-line-count-utility-version-2/

Wednesday, March 11, 2009

WCF error: "This collection already contains an address with scheme http"

WCF error: "This collection already contains an address with scheme http".

The explanation is that "WCF services hosted in IIS can have only one Base Address".

Easy fix:

Just add the following lines in the system.serviceModel section:

<serviceHostingEnvironment>

<baseAddressPrefixFilters>

<add prefix="http://www.example.com"/>

</baseAddressPrefixFilters>

</serviceHostingEnvironment>


Labels:

Tuesday, February 17, 2009

Redirect a page URL in javascript

The following code will redirect a page from index.aspx to the root URL in javascript:

var u = 'http://www.mysite.com/';
if (self.parent.frames.length != 0) self.parent.location=u;
if (self.location != u) self.location=u;//

Monday, February 16, 2009

301 Redirect in ASP.NET / C# Code

If you want to redirect a URL on a permanent basis using ASP.NET and C# code as an alternative to using IIS 6 or IIS 7, you can append the code to the old ASP.NET page.


Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "http://www.newpagelocation.com/");
Response.End();

Hope this helps!

Friday, January 23, 2009

File Access Error .IPX IPIX 360 FILES

If you encounter an error with the message "file access error" when serving IPIX files via a windows server and IIS it is likely that:

1) Your browser has no java support (in this case you will NOT see the IPIX logo)
2) Your IIS Server is not configured to serve these files:

i) Right click the website in IIS > Properties

ii) Select the HTTP headers button

iii) Add a new MIME type with a .IPX extension and MIME type of application/x-ipx

Hope this helps someone - it drove me mad for 2 hours!




Thursday, December 11, 2008

Paypal country code dropdown select html

I recently needed to build a paypal dropdown country list to pass to a PAYPAL checkout form, it took me a while to find the permitted values and build an HTML select list so I have included it here for anyone who may find it useful! View the source of this page to get the html code for the select box!

Wednesday, October 15, 2008

Convert Object Array To Dataset

Bind an Object Array to a dataset using the following code.

Code Snippet

using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace BusinessObject.Util
{
///
/// Utility Class for Object Arrays.
///

public class ObjectArray
{
private Object[] _objectArray;

public ObjectArray(Object[] objectArray)
{
this._objectArray = objectArray;
}

public DataSet ToDataSet()
{
DataSet ds = new DataSet();

XmlSerializer xmlSerializer =
new XmlSerializer(_objectArray.GetType());
StringWriter writer = new StringWriter();
xmlSerializer.Serialize(writer, _objectArray);
StringReader reader =
new StringReader(writer.ToString());

ds.ReadXml(reader);
return ds;
}
}
}

How to use the code:

Person[] personList;

personList = Course.GetPersonList();

ObjectArray objectArray = new ObjectArray(personList);Create a DataSet and convert your ObjectArray to a DataSet using the method:

DataSet ds = new DataSet();
ds = objectArray.ToDataSet();

Reference Taken From
http://tom.gilki.org/programming/net/Utils/ObjectArrayDataSet/index.shtml

This entry was posted on February 21, 2007 at 9:44 am and is filed under .NET 1.1.