Thursday, November 20, 2008

DevExpress will support Delphi Prism

Now that Delphi for .NET (now Delphi Prism) has become a Visual Studio plugin it is possible to use all the .NET components out there.

DevExpress, which btw started as a Delphi shop, has a great component set called DXperience for ASP.NET and Winforms development. Until now they only supported the Visual Studio IDE's.
You could use this components also in Delphi for .NET however they were not officialy supported. (No installation and technical support)

According to this blogpost by Julian Bucknall the CTO of DevExpress, it looks like they will support Delphi Prism in the official sense of the word.

The story is that we shall be supporting Delphi Prism with DXperience and we're evaluating what we need to do to make that work. As it happens: not very much -- it installs just fine and, on first blush, seems to work just fine. There are more exhaustive tests to complete, obviously.

Of course this is not an official statement......

We use the DXPerience components daily in our C# projects, and they are just great. We feel that Visual Studio with C#/VB.NET/Delphi Prism + DXPerience gives the developer the same power as Delphi for Win32 as we know it for so long. (For Winforms developement).

In my opinion this is great step for Delphi Prism in the .NET world.

Monday, October 27, 2008

Delphi Prism, some first thoughts

Delphi Prism is announced in this Embarcadero press release. Delphi Prism is based on Oxygene from Remobjects, so I think you could say Delphi Prism is Remobject's Oxygene. Read Remobjects press release here.

Added: Interview with marc hoffman, Chief Architect at Remobjects on Bitwise Magazine.

After five years of several solutions and directions, it looks like Delphi for .NET has finally found a good home.

Although Delphi .NET only exists for only about four years, there have been a lot of changes in the strategy executed by Borland, Borland/CodeGear and now Embarcadero. So let's take a brief look at the Delphi for .NET history:

2004 - Delphi 8 (Borland)
Delphi for .NET is born for the .NET Framework version 1.1. Delphi for .NET is positioned as a first class .NET citizen. It offers .NET 1.1 development for Winforms, ASP.NET and VCL.NET, which is the .NET variant of the VCL, offering a highly compatible framework based on .NET.

2005 - Delphi 2005 (Borland)
Delphi 2005 offers the same as Delphi 8 but Delphi 2005 has a lot improvements in quality.

2006 - Delphi 2006 (Borland)
Delphi 2006 still has support for the .NET Framework 1.1 (Winforms, ASP.NET and VCL.NET) Delphi 2006 offers a stable IDE for this developments. The fact that it does not support .NET 2.0 shows the trouble that Borland had to keep up with Microsoft.

2007 - Delphi 2007 (CodeGear/Borland)
Delphi 2007 finally supports .NET 2.0, but unfortunately the Winforms support is dropped. (Only ASP.NET and VCL.NET is supported)

2008 - Delphi 2008 (Embarcadero)
Delphi 2009 has become a Visual Studio Plugin based on Oxygene (formely known as Chrome) offering support for all available Microsoft .NET technology's (2.0, 3.0, 3.5))
Unfortunately it looks like VCL.NET is dropped.

It is not likely that the Delphi for .NET product strategy will be nominated for best executed product strategy ever.

However this is a very strong sign of the new spirit that Embarcadero is bringing to Delphi. It proofs that the buyout by Embarcadero is the best thing that happened to Delphi (and of course CodeGear) in the last five years.

Back to Delphi Prism:

Delphi Prism the pros
1. Instant support for all Microsoft .NET technologies.
2. The Delphi language is now at same level as C#, VB.NET, so the choice for the Delphi language can be made much easier. (Hack it is the same IDE)
3. Delphi for Win32 can focus on Win32 again, will not be hold back by .NET technologies.

Delphi Prism the cons
1. Less compatibilty with Delphi Win32 technologies, due to pure .NET and languages changes/additions. (Compared to VCL-VCL.NET, VCL-Winforms)
2. After Winforms, now VCL.NET dropped, and that will not please every body.

All with all the pros weigh more than the cons in my opinion.

Why use Delphi Prism?
This question is not answered easily. I think a lot of Delphi developers went for C# in the last four years. For example we decided in 2007 to standarize our .NET development on Visual Studio C# due to the dropping of Winforms in Delphi 2007 (Basicaly due to the mixed/confusing messages by Borland).

Conclusion
Although we don't know all the ins and outs yet (sure will hear a lot more the coming week) this is by far the best thing ever that happened to Delphi for .NET.

Wednesday, October 22, 2008

Exploring anonymous methods

New in Delphi 2009 are anonymous methods. Anonymous methods are methods without a name, which are able to do something on local variables where they are implemented. In fact they are a reference to a method.
Anonymous methods are a bit magic, at least they were to me, and hard to explain.
A nice place to use them is together with generics types. For instance the Sort method of a TList<T> is a natural place to use them:

PersonsList.Sort(TComparer<TPerson>.Construct(
function(const Item1, Item2: TPerson): Integer
begin
Result :
= CompareText(Item1.LastName,
Item2.LastName);
end));

A cool thing about anonymous methods is that it can execute your code (incl. local vars) in another place. This can be another unit or even another thread.

Implementing them in your daily code however is another thing. How to do that? Well here are my first explorations: Let's say we have this simple application that has a TStringList where we want to do some searching on the strings, based on the users input. I came up with this:


//Declaration of the anon reference
//The passed string will be searched on
type
TAnonStrProc
=
reference
to function(s : string) : Integer;

//Implement a method to execute
//1. Ask a string to search
//2. Execute the referenced method "proc"
function TForm4.FindString(proc: TAnonStrProc)
: Integer;
var
SearchStr : string;
begin
Result :
= -1;
if InputQuery('Search', 'Search a string',
SearchStr)
then begin
Result :
= proc(SearchStr);
end;
end;

//Create a string list
procedure TForm4.Button1Click(Sender: TObject);
var
sla : TStrings;
i,j : Integer;
Index, Count : integer;
begin
sla :
= TStringList.Create;
try
sla.Add(
'One');
sla.Add(
'Two');
sla.Add(
'Three');
sla.Add(
'Two');
//Call the FindString method with anon method
//to get the index of string in the list
//Note that it does someting with our local
//variable sla
Index := FindString(function(s : string) : Integer
begin
Result :
= sla.IndexOf(s);
end);
ShowMessage(
'Index: ' + IntToStr(Index));

//Call the FindString method with anon method
//to get the count of a searched string
Count := FindString(function(s : string) : Integer
var
str : string;
i : integer;
begin
Result :
= 0;
for str in sla do begin
if str = s then
Inc(Result);
end;
end);
ShowMessage(
'Count: ' + IntToStr(Count));
finally
sla.Free;
end;
end;

Please note that this example probably won't make it in the daily code, but it shows in a simple manner how they work. Because of the fact that our anonymouse method can take any method as long that it has a string as parameter you can call one method FindString with different implementations by passing different methods.


Well I think anonymous methods are cool. Implement them in your daily code wisely is not that simple. The working however, which seems magic at first, is after some exploring not that hard to follow.

Monday, October 20, 2008

Round the table Podcast@Delphi.org

The 11th Episode on the the podcast @ delphi.org dicusses some interesting things like anonymous methods, Garbage Collection ("To Dispose() or not to Dispose() ) and the speed of the TStringbuilder.

Great stuff! Enjoy!

Monday, October 06, 2008

Speculating on .NET plans #3

Although there are not much details unveiled yet, Nick Hodges made some statements about a new CodeGear product/project/plan called Delphi Prism at the SDN Conference in the Netherlands.
Marco Cantu was the first to blog about this statements, soon followed by Bob Swart, and Tim Anderson.

But no official statement yet! As it looks the official announcement will be made during the PDC Conference by the end of this month. (According to Allen Bauer's blogpost)

What we know now is that Delphi Prism will be a Visual Studio plugin, which I think is great news. As you might know I speculated somewhat over the Delphi .NET (That was the former name of the product) roadmap in previous blogposts, here(#2), here and here. Looks like my speculations were pretty accurate. :-P

I guess this will be the end of the speculation part although there are much questions unanswered, which I am sure will be answered in the near future.

Tuesday, September 30, 2008

A simple Generic Dictionary: TDictionary

A new generic type in Delphi 2009 is TDictionary. TDictionary offers a way to store values based on a key into a list. TDictionary is declared as TDictionary<TKey, TValue>.
TDictionary in fact is what a hashtable is in C#. It allows you to store/structure data based on any key type and any value type.

Suppose we want to track our persons, from the previous blogpost, on their social security number, we could put them in TDictionary like this: (using a very simple social security number....)

procedure TForm4.Button2Click(Sender: TObject);
var
Dic : TDictionary
<Integer,TPerson>;
p : TPerson;
i : integer;
begin
//Create dictionary
Dic := TDictionary<Integer,TPerson>.Create;
Dic.Add(
1, TPerson.Create('Delphi', 'Mr'));
Dic.Add(
2, TPerson.Create('Generic', 'Bill'));
Dic.Add(
3, TPerson.Create('nonymous', 'An'));
try

//Travel the strings
for p in Dic.Values do begin
ShowMessage(p.FullName);
end;

//Travel the keys
for i in Dic.Keys do begin
ShowMessage(IntToStr(i)
+ ': ' +
Dic.Items[i].FullName);
end;

//Find some key
if Dic.TryGetValue(3, p) then begin
ShowMessage(
'Found it!: ' + p.FullName);
end;

finally
for p in Dic.Values do
p.Free;

//Also free Values and KeyCollection
//other wise you have a memoryleak
//Is this a bug?
Dic.Values.Free;
Dic.Keys.Free;

//Free the dictionary
Dic.Free;
end;

I noticed that if you free the Dictionary in above scenario you must also free the Values and Keys collection to avoid a memory leak. This looks like a bug to me. (Will investigate this further)

In this sample I used an integer type as the key value, so this has not much benefit compared to an array. You can however use any type to be the key value!

Because we can store any type, we can take this a step further and put a TList<T> in our Dictionary:

Suppose we want to put our Personlist into a dictionary based on, let's say their gender. You could do that something like this:


type
PersonKind
= (pkMale, pkFemale);

procedure TForm4.Button3Click(Sender: TObject);
var
Dic : TDictionary
<PersonKind,TList<TPerson>>;
MPersonsList : TList
<TPerson>;
FPersonsList : TList
<TPerson>;
pList : TList
<TPerson>;
p : TPerson;

begin
MPersonsList :
= TList<TPerson>.Create;
FPersonsList :
= TList<TPerson>.Create;
Dic :
= TDictionary<PersonKind,TList<TPerson>>.Create;
try
//Fill male list
MPersonsList.Add(TPerson.Create('Delphi','Mr'));
MPersonsList.Add(TPerson.Create(
'Generic','Bill'));
MPersonsList.Add(TPerson.Create(
'Nymous','Ano'));
//Fill female list
FPersonsList.Add(TPerson.Create('Delphi','Mrs'));
FPersonsList.Add(TPerson.Create(
'Nymous','Anna'));
//Add to dictionary
Dic.Add(pkMale, MPersonsList);
Dic.Add(pkFemale, FPersonsList);

//Travel
for p in Dic[pkMale] do begin
ShowMessage(
'This is a man: ' + p.FullName);
end;
for p in Dic[pkFemale] do begin
ShowMessage(
'This is a female: ' + p.FullName);
end;
finally
//Free Persons and Personlist
for p in MPersonsList do p.Free;
for p in FPersonsList do p.Free;
MPersonsList.Free;
FPersonsList.Free;

Dic.Free;
end;
end;

TDatadictionary is a very powerfull, yet in basic easy to use, generic type. It allows you to build simple, but also complex data structures. (What about a TDictionary with TDictionary's in it? ;-) )

Again a very nice language addition to Delphi!

Thursday, September 25, 2008

A simple Generic List: TList<T>

Delphi 2009 has support for generics, and has 'built in' generic types like TList, TArrays etc. If you want to use them you must add Generics.Collections to your uses clause.

Generic List: TList
Suppose we want a list with persons representing the TPerson class:

// Our class TPerson
type
TPerson
= class
FFirstName : string;
FLastName : string;
private
function GetFullName: string;
published
public
constructor Create(ALastName : String;
AFirstName : string);
property FirstName : string read FFirstName
write FFirstName;
property LastName : string read FLastName
write FLastName;
property FullName : string read GetFullName;
end;

//Define the generic list
PersonsList : TList<TPerson>;

//Method to fill the list
procedure TForm4.btnPopulateClick(Sender: TObject);
begin
//Filll the personslist
PersonsList.Add(TPerson.Create('Delphi','James'));
PersonsList.Add(TPerson.Create(
'Generic','Mister'));
PersonsList.Add(TPerson.Create(
'Anon', 'Method'));
//etc.
end;

//Traveling this list to fill a TListBox
procedure TForm4.FillListBox;
var
p : TPerson;
begin
ListBox1.Items.Clear;
for p in PersonsList do begin
ListBox1.Items.Add(p.FullName);
end;
end;

As you can see, no rocking science needed to implement a generic list!

Sorting a generic TList
The next step is to implement a sorting method to sort the list on, for example, the Lastname property.

A TList has a Sort property which has an IComparer interface that can be implemented like this using an anonymous method:

(You will have to add generics.default to your uses clause)
procedure TForm4.btnSortClick(Sender: TObject);
begin
PersonsList.Sort(TComparer
<TPerson>.Construct(
function(const Item1,Item2:TPerson): Integer
begin
Result :
=
CompareText(Item1.LastName, Item2.LastName);
end));
end;

Generics is a great new feature of Delphi 2009. Just as in C# you will use them all the time. In this context, the use of anonymous methods is great.

Besides TList Delphi has more standard generics typs including TArray, TEnumarable and more, so there is always more to explore!

Update 25-09-2008 10:58
As animal commented you must of course create the list first, which I did not include in the code snippets.

PersonsList:= TList.Create;

And you will have to free it also at sometime. (Don't forget to free the TPerson objects as well!)

for p in PersonsList do begin
p.free;
end;
PersonsList.Free;

Monday, September 22, 2008

"Cast on News" episode at Delphi.org

Last Friday I had a really fun experience, because Jim McKeeth invited me to be on the sixth episode on The Podcast at Delphi.org - "Cast on News." 

Also invited were marc hoffman from Remobjects, and Jolyon Smith from the Te Waka o Delphi blog. Together with host Jim McKeeth we talked about the new Delphi 2009 and Delphi in general. It turned out to be a good and fun talk.

'Speaking up' instead of 'Writing up' is a total different experience, I can tell you now ;-).  Make sure you don't miss it, you can 'hear' this podcast on the Delphi.org website.

Sunday, September 21, 2008

Those tiny little details...

It are the tiny little details that makes a new release so interesting.
Take for instance the code completion popup window of Delphi 2009, it now shows deprecated functions and properties in the color dark gray.

Tuesday, September 16, 2008

Delphi 2009 very first impressions

Today the SA announcements finally hit the doorstep. Here are some very first impressions:

1. Installation
Installation improved a lot! Installing Delphi 2009, so not C++ Builder, only took 13 minutes.
The installation of the documentation, which is a separate install took about 17 minutes.

2. First startup
Start up time (cold) is on my machine approx. 10 seconds. A warm start however only takes 6 seconds. (Personally I don't care a lot about startup times, at least as it does not take too long ;-), but is a nice measure point)

My machine: Intel Core 2 duo 1,86 Ghz. 2GB Ram, Windows Vista Business.

So the installation experience is a lot better then before. (remember > 1 hour installations...).
For my real projects I will have to wait for Devexpress, who are now working on Delphi 2009 support, before I can upgrade, but I guess until then there is a lot to explore.....generics, unicode....etc. By the way, Dr Bob has this nice overview with lots of blogpost and resources about Delphi 2009.

Thursday, August 28, 2008

Speculating on .NET plans #2

Jim McKeeth asks himself, and us, in this blogpost what we think about the upcoming .NET roadmap.
Jim quotes, from his podcast with Nick Hodges, which I will quote here again:

Historically one of our strong .NET stories has been close compatibility with the .NET and Win32 compilers.  But as we have evaluated that we have found that doing that is kind of holding both compilers back to a certain degree.  And that compatibility story not as compelling as it necessarily was.  And so what we are looking at instead is a solution that departs or sort of begins to diverge away from that compatibility story.  And starts heading more towards complete support for the .NET framework kind of thing.  And so you’ll be seeing more information about that in the coming weeks.

He wonders if it is huge news? Well I think is! I have speculated somewhat about this plans in this, and this blogpost.

This is what I think!

I could think of a possible scenario:
Disclaimer, this is what I think without any information or whatsoever.

The scenario: Delphi .NET as a Visual Studio plugin
CodeGear splits Delphi into two seperate products, let say "Delphi VCL" and "Delphi .NET".

Delphi VCL
Besides the Win32 part of this product, which is now called Delphi 2009, VCL.NET will be added. Offering a complete Win32/.NET compatible framework called VCL/(VCL.NET). (Let's call this one "RAD Studio VCL")
So Delphi as we know it, since Delphi 1 bundled with a 100% compatible .NET part. So for anyone who took the VCL.NET path as it's .NET path it is business as usual.

Delphi .NET
This product is offered as a Visual Studio plugin, offering Delphi (Pascal) (read the compiler) as fully fledged .NET language. Possible offering VCL.NET compatibility.
(So our old Delphi .NET 1.1 Winforms might have a future!)

The benefits:
Delphi VCL
get's his own roadmap, is not delayed by the next Microsoft technology to be added to the .NET part. However offering VCL.NET as compatible .NET framework it will be a complete Windows development environment. Maybe not offering the 'latest and possible greatest' Microsoft technology but more than enough for 80% (? wild guess ;-) ) of the current Delphi users.

Putting Delphi as a language into Visual Studio has the benefit that it can use the Microsoft designers, so it can always be on the edge of the future developments.

In my humble opinion this is the only way to offer complete support for the .NET framework.

Again what do you think?

Wednesday, August 27, 2008

Delphi 2009 Compatible components

With the announcement and availability of Delphi 2009, it is time to think about your upgrade strategy.
One of the most important issue is the availability of the third-party components that you use for the new compiler.
CodeGear has a list with compatible third party tools and components, which helps a lot.

One company that you may miss on this list is Devexpress. As you can read in this blogpost they are working on it!

However, there is more to this support than meets the eye, so let me expound a little on the subject.

The biggest change, at least as far as we're concerned, is the new support for Unicode in Delphi 2009. I really don't want to go into the issues too deeply here, but will instead state that the Unicode support is pervasive. The default string type is now Unicode and not Ansi as before. Although CodeGear have done a remarkable job in making the porting of normal application code to Delphi 2009 as seamless as possible, it is not the same with some of the code we have in our codebase.

Tuesday, August 19, 2008

Delphi and C++ builder release dates announced

In this e-week article Embarcadero announced the release of Delphi and C++ Builder to be on 25 augustus 2008. No official press release on the CodeGear/Embarcadero website yet.

Embarcadero Technologies, which acquired CodeGear from Borland, plans to deliver new releases of Delphi and C++Builder. Delphi 2009 and C++Builder 2009 for Windows development will ship Aug. 25.

Note that it is not Delphi 2008, but Delphi 2009!

As always this will be the best Delphi ever! ;-)

Thursday, August 14, 2008

Tiburon win32 only, speculating on the .NET plans

Nick Hodges laid out Tiburon in his blogpost Tiburon - All about native code. As it seems Tiburon will only be Win32, so no .NET personality.

Other notes:
- Delphi and C++ Builder will be two seperat products (Don't worry If you have SA you will get both)
- Besides the known Professional and Enterprise edition there will be an Architect edition containing ER/Studio.

The .NET plans
Quote from the post:
"We will be coming out with an updated roadmap for our .Net solution that we believe will be feature rich and very compelling.  It will include up to date support for the latest Microsoft .NET based frameworks and other CLR-based technologies."

I don't know what it is, but there is something strange with this .NET plans.  In July I also blogged about the .NET plans quoting Michael Swindell.
One particular line in that quote:

"So we have been working on a more aggressive .NET approach that focuses less on being a .NET clone of the native Delphi implementation and more of an open approach that will make more frameworks, platforms, and features available and in a more timely manner."

makes me wonder. What would be the plan?

<speculation>
Don't tell me they will be coming up with a Visual Studio plugin! ;-)
</speculation>

Tuesday, August 05, 2008

Tiburon Sneak peek preview videos

Tiburon, the next version of Delphi, is hitting the doorstep. Embarcadero, or CodeGear will publish sneak peek videos in the coming weeks about the new and enhanced features.

What’s new in the VCL for Delphi and C++Builder 2009, is the first issue, which shows some new components that will be available in Tiburon. CodeGear is definitely updating the VCL components. For me this is not that interesting because I decided to use the DevExpress components, as a standard for my GUI work a long time ago, however these are nice improvements.

More videos to come, so subscribe to the page.

Unicode
Marco Cantu has published two videos (#1, #2) on Unicode on his weblog. 

Some more about the Office UI ribbon license

Almost two years ago I blogged about the license that Microsoft has on the Office UI Ribbon, finding it a bit of a silly license. If you want to use the ribbon control you will have to sign a license with Microsoft.

Frans Bouma takes it a bit further down the line with his The evil of the Office UI ribbon license blogpost.

Thursday, July 03, 2008

The return of Winforms in Delphi for .NET, or not?

Marco Cantu, today had an interesting blogpost, where he quotes Michael Swindell, the brand new head of productmanagement at Embarcadero, on his feedback on another post about Delphi for .NET plans.

A quote from Michael's feedback:
"In the beginning with .NET we put most of our energy into compatibility and replicating the Delphi language and VCL intact in a first class way for CLR, with the goal to make moving to .NET seamless for those applications that would be well suited on .NET"
That is correct, the winforms designer was dropped in Delphi 2007 (leaving existing Delphi .NET winforms apps in .NET 1.1).
The motto in that days was pretty much Delphi is VCL.

He continues:
"Today things like supporting more of the .NET framework flavors (Silverlight, WPF, etc) and keeping up with the latest language and framework releases is of much higher importance. So we have been working on a more aggressive .NET approach that focuses less on being a .NET clone of the native Delphi implementation and more of an open approach that will make more frameworks, platforms, and features available and in a more timely manner. "
The quote "less on being a .NET clone of the native Delphi" makes imo the statement Delphi is VCL false. (At least on the .NET side of the fence)

It even gets better:
"So in a nutshell expect less focus on compatibility between native and .NET and more support for performance and rich UI oriented packaged/desktop/workstation features (ie GUI, DB and CPU) in the native tools, and more support for other .NET frameworks beyond just Winforms and ASP.NET ie WPF, Silverlight, Open source and others - in the .NET tools."
All with all this is great news, isn't it?
One could think that even support for a winforms .NET 2.0 designer could be on the radar. Until the .NET roadmap is published this is, of course, pure speculation.

What do you think?

Tuesday, June 10, 2008

Users' Choice IDEs - 2008

Evans Data published their annual 'Users' Choice IDEs' survey.
You can get a free copy of it here.

In this survey IDE users rated several features/functions of their favorite IDE.
So the report shows the satisfaction rate of users about their IDE.

Delphi
From the eight rated EDIs, Delphi holds the sixth place.
Features where Delphi has relative high score are the compiler performance, ease of use, performance resulting applications, debugger, editor and integrated third party tools.
The Delphi compiler performance has the highest rate in the survey.
Among the lowest rated features is the documentation, which will be no suprise.

If you want to read all information/rates, go get the report.

Friday, June 06, 2008

Mixing Forms and Windows authentication in ASP.NET

In ASP.NET it is easy to set the prefered authentication method in the web.config file.
For external websites this is set mostly to Forms authentication through a own Login.aspx. When you use Windows authentication the authentication is handled by Windows, and you will get a Windows logon window automatically if the authentication failed.
In forms authentication users will be logged in based on, for example credentials which are located in the applications database. With windows authentication users are logged in based on their Windows domain account.
How can you mix those two? 
In this situtation a client wanted to enable Windows authentication for the domain users, and Forms authentication for external users.
You can't do this through the web.config file. Let's first look at methods:

Windows authentication
If you choose Windows authentication you can get the user name with the  server variable LOGON_USER.

string user = Request.ServerVariables["LOGON_USER"];


If the user, is not autorized a IIS 401 security error page will appear. The server variable is then an empty string.

Forms authentication
With forms authentication the user will be redirected to given login page. (Mostly likely login.aspx). In this page you can check the user in you database and authenticate it based on that result.

In the mix
If you mix those two you probably want to match the Windows user with the application users. However first you must setup your application to accept both users.

I found a solution here. Basically it drills down to the following:

1. Set Forms authentication in you web.config

2. Create an extra login page, Winlogin.aspx and let that be the forms login page. (in the web.config)

3. In IIS set security on Winlogin.aspx so, that it won't allow anonymous users.

4. In Winlogin.aspx determine if the user is authenticated based on his windows account. If you have the user you can also (if needed) check if he is in your own database, and if OK, redirect from this page:

FormsAuthentication.RedirectFromLoginPage(UserId, false);

5. If the user is not authenticated, the IIS 401 security error will be shown. You can hower redirect to your own HTML page in IIS, by setting the custom error redirect.

6. In your OwnRedirect401.html redirect to the your 'normal' Login.aspx with for example a META redirect, like this:

<meta http-equiv="refresh" content="0;URL=Login.aspx" />

Note that you must exclude login.aspx as a protected page in you web,config. I.o.w allow anonymous users, other wise you will end up again on your Winlog.aspx.
<location path="login.aspx">
  <system.web>
    <authorization>
      <allow users="?"/>
    </authorization>
  </system.web>
</location>
Some references:
Above method described in detail (MSDN article)
A alternate approach to the problem

Thursday, May 08, 2008

EmbarraWhat?, Embarcedar, Embarcadero...

Well, not quite breaking news (anymore after one day), CodeGear is sold to Embarcadero Technologies.

I have mixed feelings with this sell, at one hand it is great that CodeGear finally sails into a safe harbour on the other hand it is sad that the Borland brand link with development now is vanished. Borland, the company that brought us Turbo Pascal, Delphi, (to name a few) and all that other exciting stuff.

Did you know that Embarcadero is a wharf, which appears to be a pier where ships can land? Well if that is not a safe harbour!

Although I don't know the company Embarcadero (still not a very easy name to remember;-) ) it looks like a good deal for both CodeGear and Embarcadero and CodeGear tools users. Time will tell.

Congrats CodeGear!

Friday, April 25, 2008

Linq to SQL

Inside that other Development tool that I use, I found an interesting link to Luca Bolognese's  blogpost about Linq to SQL. You really should watch the video where he shows how it works in C#.

Linq to SQL is about accessing relational data with LINQ. (Language Integrated Query).

I find this really amazing stuff. It looks very easy to map data from a database to objects in your code.

The video gives a good intro on how this new stuff works. If you want to know more about LINQ, like me, you should check out Charlie Calvert's blogpost "Links to Linq" with a whole bunch of links and information.

Thursday, April 24, 2008

Delphi roadmap update

The Delphi and C++ Roadmap has been updated. It contains only updates for the native side of the fence. According to Nick's blogpost a separate update is in the make for .NET.

In short Tiburon is planned for second half 2008, focusing on:

1. Connectivity (Enhanced Datasnap)
2. International development (read Unicode)
3. Delphi language Enhancements

Commodore is planned for mid 2009 and will focus (among other things) on native 64bit compilation and parallelization in the RTL. 

For all the details go checkout the roadmap.

Sunday, April 06, 2008

Blaise Pascal Magazine

There is a new international magazine about Delphi and related languages! The magazine has it's root in the HCC (Hobby Computer Club) from the Netherlands. The Pascal Usergroup (PGG) section of this club offers for many years a magazine in ducth about Delphi languages for beginner, intermediate and expert users.

They now have gone international with an englisch version!

According to their website there will be a printed and a free download version:

The printed version contains 40 pages and entitles you to download all the code free of charge.
You will receive all issues for one year for only € 40,00.
A subscription to the download version is free, but you must pay for each code -or programm with code- download.

I think this is great news for Delphi!
You will find the table of contents of their first issue here.

Go get it here: http://www.blaisepascal.eu/.

Monday, March 24, 2008

Tiburion: A smooth Unicode shift...

Nick Hodges talks about the Unicode Shift in the new coming Delphi release code name Tiburon.
He talks about the (four) steps that were taken to get everything unicode compliant, which resulted in :

1. A new compiler with new inherent UnicodeString type
2. A new RTL using new string type routines (i.e. many new compiler helper functions in System.pas).
3. An updated VCL using the new RTL that allows the string type to easily "float" to the UnicodeString type
4. A fully functional IDE compiling with the new Unicode Compiler, RTL, and VCL.

Looks like it is going to be a smooth shift...
Anyway one of the first things coming out for the new release and an interesting read!

Thursday, March 20, 2008

What is wrong with this code?

unit Unit3;

interface

uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm3
= class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure MyFunction(x : string);
end;

var
Form3: TForm3;

implementation

{$R *.dfm}
procedure TForm3.Button1Click;
begin
MyFunction(
'test')
end;

procedure TForm3.MyFunction;
begin
ShowMessage(x);
end;

end.

Well after using Delphi for more then a decade I would say that this code would not compile because of the fact that both MyFunction and Button1Click misses their parameterlist in the implementation section.


But in fact it is perfect Delphi code as it compiles without a problem!


Never, ever I have seen code like this before, until today in a project that I do maintenance for.


Don't try this at home, because it makes,imo, your code a nightmare to read.

Thursday, March 13, 2008

European Online Webinars

CodeGear Europe, is running (and has been running) a nice serie of Webinars. In april they are running 6 webinars about, among other things, XML, SOA and Webservices with Delphi.
Besides Delphi there are also webinars about Delphi for PHP, Blackfish, C++ Builder, JBuilder and 3rdRail.

On the CodeGear European Event Calendar you will find both, the scheduled events and playback of the recorded webinars.

Tuesday, February 19, 2008

Using Assert

In a project that I herited there is massive use of Assert. Personally I did not use Assert that much, but it has some nice advantages during developing an application. (More info on Assertion in general)

What does it do?
Assert can be used as a debug tool. Assert tests boolean expression, and will halt execution if that expression is not true. If that happens, it will raise an EAssertionFailed exception.

How to use it?
This is an example, how you can use Assert in your code.

procedure TForm3.DoIt(AStringList : TStrings);
begin
Assert(Assigned(AStringList),
'Test ');
ShowMessage(AStringList.Text);
end;

procedure TForm3.Button1Click(Sender: TObject);
begin
DoIt(
nil);
end;

Clicking the button will raise the EAssertionFailed exception:

assert

Generally you don't want that the end users see this message. Therefor you can disable/enable assertion throug the $C directive or your project options dialog. If you disable Assertion, the example code will lead to an Acces violation, so normal exception tracking is needed anyhow.

The Delphi help about Assert:



The $C directive enables or disables the generation of code for assertions in a Delphi source file. {$C+} is the default.



Since assertions are not usually used at runtime in shipping versions of a product, compiler directives that disable the generation of code for assertions are provided. {$C-} will disable assertions.

Monday, January 14, 2008

More on going virtual, more experience

As I told you in this blogpost I was thinking about moving my production environment into a virtual machine. I got some really great feedback on that post, thanks for that!

Executing on that thought, I made two VM's. Here is my experience so far:

My hosting Laptop
My laptop (Dell Inspiron 9300) is two years old with the following specifications:
- Windows XP pro
-Processor: Intel running at 1,86 Ghz (Don't know exact type)
-1,5 GB memory
-Max memory available for VM 512MB
I do most of my development on this laptop.

My hosting PC
-Window Vista Business
-Processor: Intel Duo Core
-2GB memory
-Max memory available for VM 1024MB

My Delphi VM (Windows XP pro)
I made a 'Delphi' VM with Delphi 7 (for older projects), BDS2006 (for Winforms development) and RAD Studio 2007.
Currently I am using Microsoft Virtual PC 2007 to make the virtual machine. Why? Simply because it is free and I am still in an experience state here, just making the big picture on going virtual. I believe VMWare has more options, and, as I found out, Virtual PC is no good for Linux distributions. (Use Virtual box for that).
I installed all that was necessary for Delphi, the IDE, third party components etcetera in the VM.
I use Visual SourceSafe for version control and keep the source files within the VM because I had some trouble keeping the shared folders alive. This was probably a low memory issue. So my source database is on my hosting laptop, which is backed up as usual.
Currently I 'synchronize' the sources through SourceSafe between the VM and the host. (I still develop on the host...)

Performance
On my hosting laptop (512MB) Delphi 7 works fine, but BDS2006 and RAD Studio 2007 are slow. Most annoying in BDS2006 and RAD Studio is the slow typing, which makes it kind of unworkable.
On my hosting PC, with twice the available memory RAD Studio performance is OK.

My Ubuntu VM (Ubuntu 7.1)
Well since we are going virtual it is easy to test some OS from the other side of the fence. Installing Ubuntu into Virtual PC did not work (black screen). So I used Virtual Box instead, as someone suggested in the feedback of the last post.
Installing Ubuntu is amazingly easy, did not expect that so I was suprised.
Kylix 3:
I tried to install Kylix 3, but with no luck so far. This has probably most to do with my (missing) Linux skills. ;-) (Have to investigate this further)
Lazarus:
I managed to install lazarus pretty easy. Cool I can make an application for Linux now. ;-)

Conclusion
At this moment I will not go virtual completely. First I will have to upgrade the internal memory of my laptop upto at least 2 GB. But more memory, of course, would be better. (4GB?)
However it is nice to know that if my laptop, or installation, crashes I now have a complete installed development environment as backup, making the downtime almost zero.
The choice for the right virtual machine software is depending on what you do within the VM. However you could use more than one product. Virtual Box is a great alternative for both Windows and Linux VM's.
Possible future scenario:
Buy a new laptop without a preinstalled Windows (Vista). Install Ubuntu (or another Linux distro) on that laptop and run Windows XP in a VM..........

Use an image as your UIBarButtonItem

Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...