The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for the ‘.NET’ Category

Stephen Forte`s Blog – Silverlight is Dead, Long Live XAML

Posted by jpluimers on 2011/09/10

Interesting, when you compare this with FireMonkey: native versus managed, and both good UIs.

Interesting times ahead.

In retrospect: storing the form in a DFM wasn’t such a bad idea after all :)

–jeroen

Via: Stephen Forte`s Blog – Silverlight is Dead, Long Live XAML.

Posted in .NET, Delphi, Development, FireMonkey, Software Development, XAML | 6 Comments »

Cleanup: IntelliTrace Log ( .iTrace ) files and Visual Studio 2010 SP 1

Posted by jpluimers on 2011/09/08

While cleaning up my system, I found a while bunch of .iTrace files in “C:\Documents and Settings\All Users\Application Data\Microsoft Visual Studio\10.0\TraceDebugging” on a Windows XP system at a client that yet has to upgrade to newer Windows versions that store them under “C:\Users\All Users\Microsoft Visual Studio\10.0\TraceDebugging”.

Contrary to what IntelliTrace iTrace files and IntelliTrace Log ( .iTrace ) files and Visual Studio 2010 SP 1– Some Hidden Stuff « Abhijit’s World of .NET explains, these files are not always automatically removed.

And they are big, since Visual Studio 2010 Ultimate will automatically generate them.

So it is important to once in a while cleanup the “C:\Documents and Settings\All Users\Application Data\Microsoft Visual Studio\10.0\TraceDebugging” directory manually.

–jeroen

Posted in .NET, Development, Software Development, Visual Studio 2010, Visual Studio and tools | Leave a Comment »

Entity Framework: simple solution for cryptic error message “System.NotSupportedException: Unable to create a constant value of type ‘System.Object'”

Posted by jpluimers on 2011/09/06

The drawback of using ORM layers is that often the error messages are very cryptic, and it takes some getting used to in order to find the (often deceptively) simple solution.

This case was an Entity Framework wrapper around a SQL Server database where the primary and foreign keys were all GUIDs, and some of the foreign keys were optional.

So the generated model has a mixed use of Guid? and Guid data types.

Below is the full stack trace, but here is the exception class and message:

System.NotSupportedException: Unable to create a constant value of type ‘System.Object’. Only primitive types (‘such as Int32, String, and Guid’) are supported in this context.

The exception is caused by a piece of code like this:

        public static long CountChildren(ParentEntity parentEntity)
        {
            using (EntitiesObjectContext objectContext = new EntitiesObjectContext())
            {
                Guid? parentId = parentEntity.ID;

                if (null == parentId)
                    throw new ArgumentNullException("parentEntity.Id");

                IQueryable<ChildEntity> ChildEntitys =
                    from content in objectContext.ChildEntity
                    where content.ParentID.Equals(parentId)
                    select content;

                long result = ChildEntitys.Count(); // BOOM!

                return result;
            }
        }

The stack trace at the end of this post contains a truckload of ExpressionConverter lines. Since the LINQ expression contained only one WHERE clause, the mentioning of the list of primitive types in the message (Int32, String, and Guid) made me change the code into the one below.

Read the rest of this entry »

Posted in .NET, .NET ORM, C#, Development, EF Entity Framework, Software Development | 5 Comments »

.NET SecureString – storing/retreiving passwords and other sensitive data

Posted by jpluimers on 2011/08/31

Let me start that you should store as little sensitive information as possible. But if you do, you should store it in a secure way. That’s why the .NET 2.0 introduced the SecureString class.

I won’t go into detail here, as the links below and the demo source do that much better than I can:

One warning: be very cautious when you convert a SecureString in a regular unsecure array of characters, string, or compare the unsecured content. To quote Fabio Pintos, everytime you do, a little village bursts on fire. When you access it in an insecure way, make sure it is pinned, clear and release the insecure memory as soon as possible.

The problem with a garbage collected environment like .NET is that strings live on the heap, and you can’t deterministically eliminate a string from memory like you could in deterministic environment like Delphi or C/C++.

Have fun with it!

–jeroen

Posted in .NET, C#, Development, Software Development | 2 Comments »

TypedReference Structure (System)

Posted by jpluimers on 2011/08/22

Somehow this landed on my research list: TypedReference Structure (System) (together with __arglist, __makeref, __reftype and __refvalue)

Probably because of two reasons:

A few interesting links:

–jeroen

Posted in .NET, C#, Development, Software Development | Leave a Comment »

some reflections on #Delphi #FireMonkey support for #iOS based on the #FPC compiler that caused quite a surprise

Posted by jpluimers on 2011/08/17

When looking over a few forums, it seems that the way Delphi XE2 will support FireMonkey on iOS (by using FPC aka the FreePascal Compiler) was very surprising, even for the FPC dev team.

Actually, Embarcadero’s Michael Swindell posted some very interesting reactions on the Lazarus forum and his series of comments on Jon Lennart Aasenden blog entry discussing Delphi XE2 and iOS.

Recommended reading!

A lot of pieces of the puzzle fall into place now: Embarcadero aquiring KSDev (that made DXScene/VXScene), and the support in FPC 2.5.1 for a more Delphi Language compatible syntax, and Objective Pascal binding to Objective C as indicated by Phil Hess. VGScene already supported iOS using FPC in Delphi Mode, as this thread on the embarcadero forums also indicates, so it is logical that FireMonkey does too.

Embarcadero, FreePascal and RemObjects are in parallel (and sometimes cooperation) working on cross platform compiler development.
For the Mobile world, ARM (for iOS) and Java (Android, BlackBerry) are very important.

Clearly, Borland was far ahead of its time when they demonstrated their dcc32j Delphi to Java bytecode compiler proof of concept at BorCon conferences back when their opening evenents had great videos (I think it was both at BorCon 1998 and BorCon 1997), and not so great shifts (the Inprise identity crisis).

The same holds for the Sun’s slogan “the network is the computer” (actually by John Gage): basically that was about predecessors of Cloud computing.

Things from the past come back, sometimes presented as “new”, a few (partially from this Evolution of Pascal programmers.stackexchange.com thread):

All of those are (partial repetitions) of technologies that help you build systems. The trick is how to be able to quickly learn and apply those technologies (as opposed to add a bunch of TLAs or FLABs wich are about the only thing that most modern “recruiters” use to match résumés/CVs to positions).

Some of the things above have died, or are not in wide use any more.
That is OK: Life can’t have ups without having downs, and without some form of long wavelength repetitions: that’s what makes the journey so interesting (just think about the financial markets, there will be good times…).

Using FPC for iOS opens the road to develop applications using a very productive environment consisting of the Delphi IDE and the FPC compiler in a short while from now.

–jeroen

PS: two more events that I will be attending and/or speaking:

PS2: Now it probably is more clear why I bought and installed my Mac Mini Server last year :)

Posted in .NET, C#, Delphi, Development, Java, Software Development | 6 Comments »

Revisited: .NET/C# – TEE filter that also runs on Windows (XP) Embedded « The Wiert Corner – irregular stream of Wiert stuff

Posted by jpluimers on 2011/08/16

More than a year ago, I wrote about .NET/C# – TEE filter that also runs on Windows (XP) Embedded.

Since then, I have made two changes to the code (which is below and in this CodePlex changeset):

  1. using file modes FileAccess.Write and FileShare.Read, which allows you to load the output files with tools opening them in a read-only, deny none mode
  2. optional flush of the files every CRLF pair, or every 4096 bytes

Read the rest of this entry »

Posted in .NET, C#, Development, Software Development | 2 Comments »

Windows Azure Toolkit for Social Games

Posted by jpluimers on 2011/08/03

On my research list: Windows Azure Toolkit for Social Games.

–jeroen

Posted in .NET, Development, Software Development | Leave a Comment »

Text displayed in some core fonts appears blurred in Internet Explorer 9 on a computer that is running Windows Vista, Windows Server 2008, Windows 7, or Windows Server 2008 R2

Posted by jpluimers on 2011/08/02

Right now there are so many ways to display text, that – depending on your physical display (CRT, LCD, etc) – all behave differently.

Even Microsoft has released a patch (see the below quote from KB 2545698 that got released last month).

This issue occurs because of a design change to how Internet Explorer 9 renders text. By default, Internet Explorer 9 uses sub-pixel positioned ClearType to render text by using DirectWrite, whereas Internet Explorer 8 uses whole-pixel positioned ClearType to render text by using the Microsoft Windows graphics device interface (GDI).

I’m wondering if there is a way to make it work ‘right’ on every type of display combination.

Do you know any?

–jeroen

via Text displayed in some core fonts appears blurred in Internet Explorer 9 on a computer that is running Windows Vista, Windows Server 2008, Windows 7, or Windows Server 2008 R2.

Posted in .NET, Delphi, Development, Font, Power User, Software Development | 5 Comments »

Excel XML Spreadsheet: Date.Type is mandatory :)

Posted by jpluimers on 2011/07/28

When you generate Excel XML Spreadsheets, and you load it in Excel, it will report some errors in your Temporary Internet Files directory.

For instance, when you forget to fill the Data.Type attribute, then you get a log file with a message like this:

XML ERROR in Table
REASON:	Missing Tag
FILE:	V:\export.xml
GROUP:	Cell
TAG:	Data
ATTRIB:	Type

Note that some errors won’t be reported. For instance if you forget to put your Data in a Cell.Data (and put it in Cell); then Excel just show empty worksheet.

There seems to be no XSD for the XML Spreadsheet format, so you have to get yourself familiar with the XML in Excel and the Spreadsheet Component documentation on MSDN.

You can view where to put your stuff in the XML Spreadsheet Tag Hierarchy. That list doesn’t have individual links to the tags, you need the XML Spreadsheet Reference for that.

To make things more practical for myself, I perfomed these steps:

  1. created a spreadsheet with all of the data variations I expected
  2. saved this spreadsheet as XML
  3. generated the XSD from that XML
  4. imported the XSD to generate wrapper classes and interfaces

Even with that, you will need to accommodate for many peculiarities.

Hopefully I will find some time to write more those down soon.

The first is ss:Data:

  • It contains the actual data of a cell
  • It has a required ss:Type attribute, which is an enumeration of Number, DateTime, Boolean, String, and Error.
  • When it is String, then x:Ticked should be 1 (meaning True) when the string can be parsed as non-String type (and you would type the value into excel starting with a Tick mark (‘ aka single quote or apostrophe)

–jeroen

Posted in .NET, Development, Software Development, XML, XML/XSD, XSD | 3 Comments »