Galin Iliev's blog

Software Architecture & Development

C# 3.0 and LINQ Tutorial

After speaking with my friend Marto I decided to write a tutorial about forthcoming features in new version of the very popular language C#.

As always there is a lack of development materials in Bulgarian so it is written in Bulgarian and there is no language barieer for bulgarian developers who wants to take a look behind the corner to new version of our favorite C#.

There is posibility to translate the whole tutorial in English (when it si finished) so this could be good starting point for all English speaking devs but this depends on the interest (and my availability).

I have posted first two parts (of total 13 so far): Introduction and Acknowledgment with LINQ and basic capabilities.

I hope I will be able to post next part very soon (projected within next two weeks) and I will announce it here.

In the meantime I will be very grateful for your feedback. Any comments, reccomendations and request for more detailed reviews are welcome. You can post them as comments on the blog or to my emails stated on here.

Thank you

LINQ projects in VS "Orcas"

Yesterday I installed VS "Orcas" January CTP on my machine in order to take deeper look at things that are comming.

I was a bit surprised I could not find VS LINQ project templates and compiler throws compile error on correct linq statement.

This was kind of strange - The VS version that introduces LINQ return compile error on correct LINQ statement ???!?!?!?

The problem was only in referenced  assemblies as this post says.

So to have LINQ syntax in your VS "Orcas" you have to:

  • Add reference to LINQ assemblies located in C:\WINDOWS\Microsoft.NET\Framework\v3.5.*. You can reference them all or only those you need (The important ones are System.Core.dll, System.Data.Entity.dll, System.Data.Linq.dll and System.Xml.Linq.dll
    The core is for the standard linq queries, where Data.Linq and Xml.Linq are what the old DLinq and XLinq were. )
  • Add using clauses at the top of source files.
    using System.Linq;
    using System.Data.DLinq;
    using System.Xml.Linq

Skype and Internet Explorer BHO

Have you seen new Skype 3.0? Although it becomes more colorful it has too many new features.

The new Skype Web Toolbar for Internet Explorer is fascinating.

The Skype Web Toolbar recognizes phone numbers and Skype Names on web pages, so that you can call with one click, through Skype.

But how do they do it?

Is it some ActiveX? Something else? Should I go back to C++ in order to create something similar?

Not really!

This is (simple) HTML and JavaScript. Well... probably not that simple but still not ActiveX.

But why I do not see it when I am viewing Page’s Source?

This is tricky part – you are not able to see this additional code because it is added after browser complete downloading page from the site.

And how I can create something similar?

You don’t have to write it in C++. But still you will have to know how to create COM object that is attached to IE or Browser Helper Object (BHO). Fortunately there are some sites that explain that like:

·         Good Steven M. Cohn's  post  - IE Browser Helper Objects

·         AutoSig: A browser helper object that automatically adds a different signature when you post a message to a CP forum – I deeply suggest you to explore this article and demo code in it.

You will see similar code in articles above:

browser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);

 

With this code you get control when browser completes downloading the page. And in this handler you have access to the page with:

IHTMLDocument2 document = (IHTMLDocument2)webBrowser.Document;

 

And having access to document you are able to modify page’s source. Thus you can put what you want where you want. The limit is your imagination J (and web design skills)

Ooh… I almost forgot: you can add additional script tags and images in web page. This is not big deal as you can reference them in client’s computer (that’s right this is not pure web development).