Subscribe: Wimdows.NET
http://weblogs.asp.net/wim/rss.aspx
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
api  array  arraysegment  count  module  namespace nsproblem  namespace  net  nsproblem  offset  public  return  string  web  xml 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Wimdows.NET

Wimdows.NET



Wim's .NET blog



 



Unexpected behaviour: Defining values in enums

Fri, 23 Feb 2007 15:35:00 GMT

I don't normally regurgitate other blogger's posts like a headless chicken, but in this case it's worth mentioning.

Stephen, a colleague of mine, and a picky sod (who puts their enums in alphabetical order? - no serious comments on that remark, pulllleazee!), ran into some unexpected behaviour with regards to enums. Worth a read.

 




Teaser - upcoming forum software / message board AtlasForums

Tue, 10 Oct 2006 19:34:00 GMT

Here's a quick screen grab from an upcoming forum project I'm working on: AtlasForums. As I progress with this, I'll post more and more details as I get closer to launch.

(image)  

Hope you like what you see so far.

Cheers!




Bug in Community Server URL Rewriter

Mon, 02 Oct 2006 17:26:00 GMT

As just seen when trying to access Patrick's blog post about Forums.

Looks like the CS URL rewrite engine looks for forward slash followed by "Forums" and zero or more characters, ending at ".aspx", which obviously messes up any blog posts starting with Forums in the title...oops!

Sounds like a straight forward enough fix though.

Update: this seems to have been fixed now. 




CreativeCreek.net - portfolio website service launched (ASP.NET 2.0)!

Sun, 24 Sep 2006 14:06:00 GMT

Just like to let you all know I've just launched a porfolio website service, CreativeCreek.net, developed in ASP.NET 2.0.

It's been a limited beta for a while now, but you need to get apps out there first in order to get useful iteration cycles going and expand on all the features.

If you're into photography or know someone who is, you may want to check it out




Dump the Module keyword in VB.NET!

Sun, 03 Sep 2006 11:53:00 GMT

Though I'm mainly a C# developer, I now and then get exposed to some VB.NET stuff. No, this is not going to be a C# vs. VB.NET debate. We've seen enough heated arguments and flame wars on that topic over the years.

Something about VB.NET Console applications created in Visual Studio.NET (all versions), bugs me though: the dreaded Module keyword. The default skeleton for a Console app in VB.NET looks like this:

Module Module1
    Sub Main()
    End Sub
End Module


Whilst under the hood, a module is simply a class with static members and a private default constructor to prevent instantiation, I don't think its use should be promoted like that. And I really wonder why MS hasn't changed the default Console app skeleton to look as follows:

Class Program
    Shared Sub Main()
    End Sub
End Class


In my opinion, the Module keyword shouldn't have even existed in VB.NET. It's one of the reasons why a lot of VB.NET code I've seen simply gets dumped in a Module, and Object Oriented Programming goes out the window. Of course, there's nothing stopping you coding like that in VB.NET without using the Module keyword, or even in C# for that matter. But it is a step in the right direction in trying to get developers to think about object oriented class design first (static/shared vs. instance members etc), before shoving anything and everything in a Module.



Zune MP3 player - DRM'ed or not?

Fri, 25 Aug 2006 23:27:00 GMT

Here's a question for a debate. Do you think Microsoft's upcoming audio player, dubbed Zune, will play only DRM compatible content?
 
If that is the case, I won't be touching it with a barge-pole; same reason I haven't got myself an iPod.

If I have legal MP3 files, ripped them from CD's I own or bought them legally I feel I should be able to play this on however many devices I want, as long as I own them. That means my MP3 player, my phone, server, desktop, laptop, you name it - without restrictions.

If Microsoft wants to have an edge over the IPod, they need to make sure it works without DRM mangled content. If not, it will flop. Big time.

What do you guys think? 



ViewState, CheckBox, ControlState...errr...

Thu, 24 Aug 2006 14:49:00 GMT

J. Michael Palermo writes about the CheckBox in ASP.NET maintaining its state regardless of the EnableViewState attribute to False in ASP.NET 2.0.

Hang on - isn't that the same in ASP.NET 1.0 and 1.1? Oh yes.

All web controls that implement the IPostBackDataHandler maintain their basic 'value-state' (for lack of a better description) using the HTTP POST form collection. Irrespective of setting the EnableViewState property for the web control to False.

Nothing has changed in ASP.NET 2.0 as far as that is concerned. The CheckBox control along with TextBox and other controls that implement the IPostBackDataHandler interface, still maintain their basic value-state using their respective HTTP POST values. ControlState has nothing to do with this.

ControlState is a way to allow more fine-grained control over individual portions or behavioural elements of a web control, which under the bonnet actually still uses the ViewState statebag. Fritz Onion's article outlines this nicely and in more detail.



Generic Parse method on Enum - a solution

Thu, 06 Jul 2006 08:59:00 GMT

David Findley writes about how he wishes we had a generic Parse method on the Enum class in .NET 2.0.

Though I agree in principle, it's actually quite trivial to create a generic static class with a Parse method, which alleviates some of the pain.

Here's my stab at it:

    public static class EnumUtil
    {
        public static T Parse(string s)
        {
            return (T)Enum.Parse(typeof(T), s);
        }
    }


Say we have the following enum:

    public enum Color
    {
        Black,
        White,
        Blue,
        Red,
        Green
    }

We can now simply use the generic EnumUtil class as follows:

Color c = EnumUtil.Parse("Black");

I feel that this helper method doesn't actually warrant a class in its own right, so you may want to add it to one of your Util classes (if you happen to have a generic one!) instead.




ArraySegment Structure - what were they thinking?

Wed, 14 Jun 2006 14:24:00 GMT

From the MSDN docs:ArraySegment is a wrapper around an array that delimits a range of elements in that array. Multiple ArraySegment instances can refer to the same original array and can overlap.Turns out this structure doesn't even deserve the definition 'wrapper'. It simply takes the array, offset and number of elements in your segment, and sets a few properties accordingly.Subsequently when you want to iterate over the items in your ArraySegment, you still need to use a combination of Offset and Count to achieve this. How is this different from not creating an ArraySegment and define your Offset in-situ as well as the number of elements?I was expecting to be able to do something like this:ArraySegment seg = new ArraySegment(new string[] { "John","Jack","Jill","Joe"},1,2);// Access first item in segmentstring first = seg[0];// Iterate through ArraySegmentforeach (string s in seg){    Console.WriteLine(s);}Turns out you can't. There's no indexer for ArraySegment and no enumerator. You have to access the .Array property and use .Count and .Offset as passed to the constructor. What is the point of that!?So I rolled my own generic DelimitedArray class which does exactly that. See the inline code below.    public class DelimitedArray    {        public DelimitedArray(T[] array, int offset, int count)        {            this._array = array;            this._offset = offset;            this._count = count;        }        private int _offset;        private T[] _array;        private int _count;        public int Count        {            get { return this._count; }        }        public T this[int index]        {            get            {                int idx = this._offset + index;                if (idx > this.Count - 1 || idx<0)                {                    throw new IndexOutOfRangeException("Index '" + idx + "' was outside the bounds of the array.");                }                return this._array[idx];            }        }        public IEnumerator GetEnumerator()        {            for (int i = this._offset; i < this._offset + this.Count; i++)            {                yield return this._array[i];&nb[...]



ASP.NET 1.1 server control for - enabling relative URL paths using tilde "~"

Thu, 27 Apr 2006 10:56:00 GMT

Here's a simple - but useful Link webcontrol class that supports the "~" tilde syntax for relative paths for the href attribute of the element.

[DefaultProperty("Text"),ToolboxData("<{0}:Link runat=server Href=\"\" Rel=\"Stylesheet\" Type=\"text/css\">")]
public class Link : System.Web.UI.WebControls.WebControl
{
    private string _href;

    public string Href
    {
        get { return _href; }
        set { _href = value; }
    }

    protected override void Render(HtmlTextWriter output)
    {
        output.WriteBeginTag("link");
        output.WriteAttribute("href",base.ResolveUrl(this.Href));
        foreach (string key in this.Attributes.Keys)
        {
            output.WriteAttribute(key,this.Attributes[key]);
        }
        output.Write(HtmlTextWriter.TagRightChar);
        output.WriteEndTag("link");
    }
}

You can then simply drop it in the section of your page (provided you've used the Register directive to register the assembly):



The reason I had to roll my own is that when you add runat="server" for the element, it turns into a HtmlGenericControl instance on the server, which is obviously used for numerous HTML elements, and as such no specific path resolve mechanism is applied to any of its attributes, since the attributes are different per HTML element.

Hope it helps someone out.



PayPal API: what a nightmare!!!

Fri, 27 Jan 2006 12:42:00 GMT

I've been trying to get up and running with the PayPal API, see www.paypal.com/developer.What a complete nuisance that is!

The test accounts you create (on the sandbox, http://www.sandbox.paypal.com) actually need to be verified, before you can request an API cerificate. I finally managed to complete 2 out of the 3 verification steps but setting up the bank funding just fails:

I can add a US bank account, and according to the documentation (PP_Sandbox_UserGuide , page 22), you will see the 'Continue' button after adding an account which will take you to the overview page. Well, there is no 'Continue' button, and no 'Confirm Bank Account' link in the Activate  Account box either, which means I cannot complete that step, and can't request an API cert. to start using the API.

I have tried to add a UK bank account, using the sortcode prodived in the same user guide, but it always fails saying that it's an incorrect sort code and incorrect 8 digit account number.

Why the bloody heck is their documentation inconsistent with the behaviour of the sandbox? And why on earth do people have to jump through so many hoops to use their API?

Have you used the PayPal API? Any thoughts on this?



Public available data - FREE screenscraping or pay for API

Mon, 23 Jan 2006 20:42:00 GMT

Been working on a semi-commercial pet project of mine, for which I need a data feed.

A decent enough subset of this data feed is publicly available from this content provider's main website. However, the full dataset (though I won't need all that) is available through an HTTP GET XML API... For a flat fee of over 500 dollars per year.

What would you do? 1) Roll it yourself in about 20 lines of .NET code (using HttpWebRequest & Regex's) and scrape it; 2) Pay for the API...?

Needless to say, I went for 1)...even for just the fun.



Hack: turn your optical mouse into a scanner

Thu, 12 Jan 2006 18:06:00 GMT

Why? Because it can be done. :-)

"Ever wonder what your desk surface looks like up close? No. No one has. Not even [Sprite_tm], but upon disassembling his optical mouse and discovering its 18x18 CCD he decided to put it to use (well, a different use). The optical chip outputs serial information to the USB chip in the mouse. [Sprite_tm] wired the optical chip to a parallel port and wrote a simple program to interpret the data. Not really useful, but it does generate some interesting pictures. Program provided, natch."

(image)

Via: Hackaday.com

Very cool, indeed.



Tesco's UK - only 3,000 XBOX 360's at launch....!!!

Thu, 01 Dec 2005 23:16:00 GMT

Just been told by a member of staff of Tesco, here in the UK that there's only around 3,000 XBOX 360's in Britain. I'm definitely guessing he meant 3,000 XBOX 360's at launch with Tesco's, which seems like an incredibly small amount for such a big superstore.

I phoned a big Tesco Extra's store in Swansea, Wales. They only had 11 XBOX 360's in! And people had been waiting for them from 6'o clock...

Surely MS must be putting some pressure on the production of these units! Get on with it! If you want to win the battle with Sony's PS3, better increase production! Sounds like the demand is enormous...despite the rumours of crashes and BSOD's etc.



Why don't we see any patches for Visual Studio .NET? (2002, 2003, 2005...)

Fri, 04 Nov 2005 13:36:00 GMT

Frans has mentioned this on numerous occasions I believe, and this topic has reared its ugly head once again. Dan Fernandez' post back in March 2004, doesn't really address the reasoning behind it.

Personally, I really don't see the difficulty for Microsoft in releasing publicly available patches or hotfixes for VS.NET. It happens for the .NET framework, all OS'es and Office products, why not for VS.NET?

At the lowest level, it's only shuffling around a few bits and bytes for the affected binary files. Even with the different VS.NET product versions, they could release a patch for each version if needs be.

Anyone care to comment on the reasoning behind this?



The pollution on the main weblogs.asp.net feed...

Thu, 03 Nov 2005 19:32:00 GMT

When I go through the main feed here on weblogs.asp.net, the last thing I'm looking for is:

- Posts in any other language but English. I'm saying that as a Dutch native speaker.
- Simply regurgitated posts from (wait for it...) weblogs.asp.net!!! Sometimes it even is regurgitation upon regurgitation...
- How many virtual bucks your blog is worth.
- Politics or completely unrelated things like non-technical news items. If I want to read the news, I'll check out the BBC, CNN, MSNBC and other sources, thanks.

What am I looking for? Well:

- Posts with technical content, related to Microsoft or competitive technologies.
- Techical news items, gadgets, technologies, architecture, tools; as long as it hasn't been posted or linked to before on weblogs.asp.net.
- Links to blog posts outside of weblogs.asp.net which contain content similar to the above.

I may have missed out some, please let me know your thoughts. If we all stuck to it (even only 80% of the time), the mainfeed would be much, much cleaner.

I guess having global categories when posting, and the ability to exclude global categories on the mainfeed and for the RSS feeds (personalized setting) would help. Anyone know whether this exists in CS 2.0?



PhotoCritters.com

Fri, 14 Oct 2005 16:50:00 GMT

I've launched the very first stage of my Photography Critiques community website, PhotoCritters.com.

People that are interested can reserve their spot in the initial beta program, which is limited to 1,000 beta users.

If you're interested in photography, please have a look.

Cheers!





Possible Bug : HttpPost and class name conflicts

Sun, 02 Oct 2005 22:33:00 GMT

A colleague and friend of mine run into some very odd web service behaviour on ASP.NET 1.1. Anyone who can shed some light on this, please leave a comment. I have pasted his exact text describing the problem below. -- Included below is a minimal web-service implementation to recreate a problem I've encountered in a web service that has methods returning classes with the same local name (but in different namespaces). If only the SoapHttp protocol is enabled in the web.config, everything works as expected - with the different "Something" classes being serialized in to different XML namespaces as defined by the ResponseNamespace property of the SoapDocumentMethod attributes. However - if HttpPost or HttpPostLocalhost are enabled (the latter being enabled by default), and I browse to the asmx file in IE, I get this error : Types NsProblem.B.Something and NsProblem.A.Something both use the XML type name, Something, from namespace http://example/NsProblem/. Use XML attributes to specify a unique XML name and/or namespace for the type. If I un-comment both of the "XmlRoot" elements I get this error The XML element named 'Something' from namespace 'http://example/NsProblem/' references distinct types NsProblem.A.Something and NsProblem.B.Something. Use XML attributes to specify another XML name or namespace for the element or types. Now for the really strange bit : leave one XmlRoot attribute commented, and the other not, and it works! When it is working, the example responses (on whatever.asmx?op=GetArrayA) don't appear to tbe any difference! (aside: I also tried setting the responses to be different using Xml Serialization attributes, i.e. putting [return: XmlElement(... )] on the methods, but like the SoapDocumentMethod attribute this only seemed to change the response for the Soap method - making no difference to the HTTP POST response) Various workarounds are available  - disable (remove) "HttpPost" and "HttpPostLocalhost" in web.config  - Rename the classes (making the namespaces redundant) but I would prefer to be able to keep the class names as they are, and keep the HttpPostLocalhost enabled for testing / debugging purposes - and I anticipate needing to support 3 or more classes with the same local-name across different namespaces. ---- Minimal test case ---- <%@ WebService Language="c#" Class="NsProblem.XmlTestSvc" %> using System; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Serialization; namespace NsProblem.A { //    [XmlRoot(Namespace="AAAA")]     public class Something { } } namespace NsProblem.B { //    [XmlRoot(Namespace="BBBB")]     public class Something { } } namespace NsProblem {     [WebService(Description="Conflicting name problem example", Namespace="http://example/NsProblem/")]     public class XmlTestSvc : System.Web.Services.WebService     {         [WebMethod]         [SoapDocumentMethod(ResponseNamespace="http://example/NsProblem/A")]         public NsProblem.A.Something[] GetArrayA() { return null; }                 [WebMethod]         [SoapDocumentMethod(ResponseNamespace="http://example/NsProblem/B")]         public NsProblem.B.Something[] GetArrayB() { return null; }     } } [...]



Launch 2005 - where's the UK site?

Fri, 23 Sep 2005 15:47:00 GMT

Some people have been posting the links to the Launch 2005 events for North America.

I'm looking for the equivalent UK registration site...

Anyone who can help me out here? And it it's simply not up there, when will it be?

Cheers!



MSN Search textbox: make the thing wider!

Wed, 07 Sep 2005 15:38:00 GMT

How annoying is that little MSN search input textbox. Especially if you specify a literal string query which contains several words and combine this with some other logical AND or OR search terms.

Just quadruple its width!

Google has had a decent textbox since its inception...

You'd have thought the MSN folks would have learnt something from Google by now.