woensdag, december 27, 2006

The basic principles and usage of NHibernate by Maarten Balliauw

Maarten Balliauw wrote an article (written in Dutch) on the basic principles and usage of NHibernate, an ORM-mapper for the .NET platform. You have to readhis article!

Checkout his blog post about his article: here

maandag, december 04, 2006

Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation) RTM BUILD

Needed when developing Workflows with VS 2005 for Sharepoint 2007 RTM:

Download Visual Studio 2005 Extensions for Windows Workflow Foundation (EN).exe

You can still use the ECM Starter Kit for B2TR, download here

zaterdag, november 25, 2006

Using CAML to filter a infopath published boolean field (from a sharepoint list)

In a infopath form we have a boolean field called Draft, we publish the form to a sharepoint list, and we want to filter that list using Caml queries:
Which value should the BOOLEANVALUE have to succeed the query?
False/True ? Yes/No ? 0/1 ?
What I noticed is, when I published the infopath form the boolean type in intopath will be a Yes/No Type in the sharepoint list.....

So the Caml query will not work with BOOLEANVALUE = False/True Or Yes/No , you have to use 0 or 1...

Implement the CAML query into code:

StringBuilder camlBuilder = new StringBuilder();

string queryText = camlBuilder.ToString();

SPWeb site = SPContext.Current.Web;
SPList list = site.Lists["Mail"];
SPQuery query = new SPQuery();
string queryText =""
query.Query = queryText;

results = list.GetItems(query);
foreach (SPListItem item in results)

If you put the query Tag as root tag into the query text, you will receive all items, zo don't put it there, some stupid guy I know very good did that ;-)

Also check this out:
U2U CAML Query Builder and Execution Tool (+download)

SPListItem looses Property data type when publishing Infopath form to a sharepoint list (MOSS 2007 beta2TR)

When you publish a Infopath Form to a sharepoint list, the Infopath form contains some fields (text and date(time) data types). These fields are copied to a sharepoint list when you publish the form to it.

You should think sharepoint keeps the data types like in the infopath form, but this isn't, I noticed that the date(time) data type is just a string/text field in the sharepoint list!

The strange thing is that when you add a column in the published list manualy (for example a datetime field), it will keep the data type and not change it to a string.

I noticed it when a wanted to perform an update an a field called ApprovalDate (Date Datatype) in a Web Part:

SPSite site = new SPSite("http://......");
SPListItemCollection results = site.Lists["InfopathPublishedList"].Items;
foreach (SPListItem item in results)
item.Properties["ApprovalDate"] = DateTime.Today;//DateTime.Today.ToString();

This code failed when I did this on the datetime field published by infopath:

Error:Specified data type does not match the current data type of the property. at Microsoft.SharePoint.Utilities.SPUtility.UpdateArrayFromHashtable(Object& o, Hashtable ht) at Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object&
objAttachmentNames, Object& objAttachmentContents, Int32& parentFolderId) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration,
Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) at Microsoft.SharePoint.SPListItem.Update()

This doesn't happen if the ApprovalDate is added by create column in the list.

So watch out, and as you notice in the picture below: It ain't what it look like........

dinsdag, november 21, 2006

System.Web.UI.WebControls.WebControl doesn't fire all events

During the development of a ServerControl for a masterpage in a Sharepoint site, I added some eventhandlers in the CreateChildControls(): DayRender, VisibleMonthChanged and SelectionChanged.

After debugging, I noticed that only the DayRender event worked. I googled sites and newsgroups to find a solution, but I didn't find an answer....
After sending this problem to a colleague(thanks to: Sam), he answered this:

If you inherit controls from the WebControl class, you will get problems with events and state. So if you need dynamic controls, let them inherit from the CompositeControl class, this class is special made for controls that contains other controls.

At the CompositeControl MSDN page I found this:
The CompositeControl class is an abstract class that provides naming container and control designer functionality for custom controls that encompass child controls in their entirety or use the functionality (STATE AND EVENT HANDLING?!!?) of other controls.

Below some code of a custom Calendar that inherit from CompositeControl :

public class MailCalendar : System.Web.UI.WebControls.CompositeControl

private System.Web.UI.WebControls.Calendar ctlCalendar;

protected override void Render(HtmlTextWriter writer)

protected override void CreateChildControls()
this.ctlCalendar = new System.Web.UI.WebControls.Calendar();
ctlCalendar.VisibleDate = DateTime.Today; this.ctlCalendar.DayRender _
+= new DayRenderEventHandler(ctlCalendar_DayRender);

this.ctlCalendar.VisibleMonthChanged _
+= new MonthChangedEventHandler(ctlCalendar_VisibleMonthChanged);

this.ctlCalendar.SelectionChanged _
+= new EventHandler(ctlCalendar_SelectionChanged); this.Controls.Add(ctlCalendar);

void ctlCalendar_SelectionChanged(object sender, EventArgs e)

void ctlCalendar_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
ctlCalendar.VisibleDate = e.NewDate;

void ctlCalendar_DayRender(object sender, DayRenderEventArgs e)
// Set date to bold if its today
Style boldStyle = new Style();
boldStyle.Font.Bold = true;

if (e.Day.Date == DateTime.Today)
{ e.Cell.ApplyStyle(boldStyle); }

More info: Webblog ScottGu

dinsdag, oktober 17, 2006

Writing Custom Web Parts for SharePoint 2007

On Scott Guthrie's Blog you can find a post with lots of info about "Writing Custom Web Parts for SharePoint 2007"

donderdag, oktober 12, 2006

Error loading snippets in feature.xml and workflow.xml file

If the code snippets are not showing up in Visual Studio, go to Tools -> Code Snippets Manager, change the language to XML, and add "C:\Program Files\Microsoft Visual Studio 8\Xml\1033\Snippets\SharePoint Server Workflow" to your snippets.

If you don't see the Code Snippets Manager in VS 2005: JOPX will explain how you add that! link

woensdag, september 27, 2006

Microsoft Visual Source Safe Client: No more waiting for Checked out files

On The CodeProject there is a new article about how to create a MS VSS Client that notify when a checkout file that you want is checked in again. So you don't have to contact people asking again and again: "Hey dude I need the file, please check it in!"

You can find code and stuff for this on The CodeProject: link

donderdag, augustus 17, 2006

Atlas Showcase

“Atlas” is a free framework for building a new generation of richer, more interactive, highly personalized cross-browser web applications.
thus http://atlas.asp.net

In a Microsoft newsletter I found a nice video about using Atlas on ASP.NET 2.0 pages: Video - Developing ASP.NET 2.0 Applications using "Atlas" by Scott Guthrie, General Manager, .NET Development Platform : download here

dinsdag, juli 25, 2006

Virtual PC Is Now Free

From the "TechNet Belux Flash & Events - July 25, 2006"
Whether Microsoft virtualization technology is an important component of your existing infrastructure or you're just a Virtual PC enthusiast, you can now download Virtual PC 2004 Service Pack 1 (full-version software) absolutely free. Virtual PC 2007 will be available for free in 2007, with support for Microsoft Windows Vista.


dinsdag, juni 13, 2006

Yeah! The new .NET Framework 3.0 ?!?

WTF, the new WinFX will be no more, it will be renamed to .NET Framework 3.0. The .NET name is loved by many so they want to keep using it

So the framework stays the same,
just another name!

More info about te decision to rename the WinFX to .NET 3.0, read it here:
Somasegar's WebLog

dinsdag, juni 06, 2006

Ubuntu, free alternative for Windows

Ubuntu, a free OS? Yes! I will try to install this and bring on some comment later on....

Ubuntu on the net

woensdag, mei 31, 2006

Using XPath to Extract Data From XML...

At http://www.dotnetjohn.com/ I found a very usefull article about Xpath:

Using XPath to Extract Data From XML

Check it out

donderdag, mei 18, 2006

Bullshit Bingo - How to stay awake in meetings

From Guy Bursteins blog, seen on JopX blog

Do you keep falling asleep in meetings and seminars? What about those long and boring conference calls? Here's a way to change all of that. 1. Before (or during) your next meeting, seminar, or conference call, prepare yourself by drawing a square. I find that 5" x 5" is a good size. Divide the card into columns - five across and five down. That will give you 25 one-inch blocks. 2. Write one of the following words/phrases in each block:

strategic fit
core competences
best practice
bottom line
to tell you the truth (or "the truth is")
out of the loop
think outside the box
fast track
empower (or empowerment)
knowledge base
at the end of the day
touch base
client focus(ed)
game plan

Check off the appropriate block when you hear one of those words/phrases. 4. When you get five blocks horizontally, vertically, or diagonally, stand up and shout "BULLSHIT!" Testimonials from satisfied "Bullshit Bingo" players: "I had been in the meeting for only five minutes when I won." - Adam, Atlanta "My attention span at meetings has improved dramatically." - David, Florida "What a gas! Meetings will never be the same for me after my first win." - Dan, New York City "The atmosphere was tense in the last process meeting as 14 of us waited for the fifth box." - Ben, Denver "The speaker was stunned as eight of us screamed 'BULLSHIT!' for the third time in two hours." - Paul, Cleveland

Enjoy your meetings!

vrijdag, april 28, 2006

Convert byte[] to an Image/bitmap: why the System.ArgumentException: Invalid parameter used arises.....

I need images saved by an old vb6 program and convert them to a new db of a new prog. The old programma saved the images data into a image field of a SQL2000 DB. First I justed copy the image from V1 (db of the old programma) to V2 (the db (also SQL2000) used in the new program).

Problem: the data in the image field is corrupt! When I try to convert that data into a bitmap or jpg it gives me a Invalid parameter Exception when I do this code:

MemoryStream ImageDataStream = new MemoryStream();
// byte[] ImageData, filled with the image field of db
Image img = Image.FromStream(ImageDataStream); //Invalid parameter Exception thrown

This is because the byte data of ImageData is corrupt due a Unicode encoding done by the old VB6 programma before/while saving it to db. Below some byte code (hex style) so that you can see the the good data vs the corrupt/wrong data:

A bitmap header starts with BM, so there you see that the is a doubling of the data: from 42 4D to 42 00 4D 00 => convertion to Unicode. You can't simply remove the 00 because unicoding is not just a 00 extend. For example 75 87 95 59 (see above in picture) will be converted to 75 00 21 20 22 20 59 00 and not just 75 00 87 00 95 00 59 00 !!

So what you have to do is convert the data back to the current ANSI code page (Encoding.Default):

So the code below will do the good convertion......
MemoryStream ImageDataStream = new MemoryStream();
Image img = Image.FromStream(ImageDataStream);

Not every "Invalid parameter used" exception will be fixed like that, sometimes you need an other Convertion with other Encoder parameters or the image can have a added header (like the 78 long ole-header,..... => the code will be like ImageDataStream.Write(ImageData,78,ImageData.Length-78); )

Good luck!

donderdag, april 27, 2006

Messed up bitmap data ? FIXED (SEE ABOVE!)

On http://www.lierse.be/VB6bitmap.zip is a dat file (from an image field in SQL2000), it is a bitmap file, in an old VB6 programma that image is used and visible. So it is valid data. Problem: no code of vb6 of that prog is available.

My question: What is wrong with the bitmap data? does vb6 add some rubbish to it? I can't load it into image object in C# because a invalid argument exception (because somethings is wrong in the header or ...). I tried every offset (some people say use 78 as offset, because there will be a OLE header), and every offset gives the same error. I get an invalid argument when i do this:
ImageDataStream.Write(ImageData,i,ImageData.Length-i); // ok, tried every value of i
Image img = Image.FromStream(ImageDataStream); // the invalid argument error rises here

I'm trying now to rip the pixeldata and put the pixeldata in a own created bitmapfile with correct header/colormap... But still something is wrong, the pixeldata contains good data and then a piece of FF 00 FF 00 of the same length and that a few times....

Anybody knows what vb6 does to the imagedata when saving it to SQL2000 ? any tips are welcome.......

Internal Compiler Error: stage 'COMPILE' or 'BEGIN' errors

It happens sometimes, stupid bug in VS 2003? Most of the times it is one function that has a type error that for some kind of reason is not seen by the compiler (like DataRow myDataRow = new DataRRow();). Simply restart VS and look through your code and fix the mistyped stuff in the function......

donderdag, januari 19, 2006

Object reference not set to an instance of an object: System.NullReferenceException

When you receive this error, stop searching for a solution, first try to restart IIS (if that doesn't work: restart your pc) and check if the error is still there.... It worked with me, after searching an hour for a solution....

I also noticed that the vs 2003 debugger went very slow when the error occures

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.UI.Control.OnBubbleEvent(Object source, EventArgs args)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)