Marshaling between Managed and Unmanaged Code: PInvoke Interop Assistant

I recently saw this useful tool mentioned on StackOverflow by JaredPar (it seems I need to catch up on the MSDN magazines that are starting to pile up!): the PInvoke Interop Assistant hosted on CodePlex and first described in this MSDN article, Marshaling between Managed and Unmanaged Code:

.NET Framework interop opens a channel between managed and unmanaged code, and marshaling plays a very important role in that connection in that it allows for data exchange between the two. There are many factors that affect the way the CLR marshals data between the unmanaged and managed worlds, including attributes such as [MarshalAs], [StructLayout], [InAttribute], and [OutAttribute] as well as language keywords such as out and ref in C#.

Understanding and remembering all the attributes and rules (described in the MSDN article) may seem a bit daunting. After all, most developers of managed code just need to be able to quickly figure out the P/Invoke signature for a Win32® API function, paste it in their code, and be done with it. That’s where the P/Invoke Interop Assistant can help. This tool can efficiently assist with conversions from C++ to managed P/Invoke signatures as well as those in the opposite direction. It even comes with a database of Win32 functions, data types, and constants, so the common task of adding a Win32 P/Invoke to your C# or Visual Basic source file is made very easy. The tool package includes two command-line tools, SigImp and SigExp, which can be used for batch file processing. A GUI tool is also found in the package, which includes the functionalities of both tools.

IE8 does not support the Windows Vista product registration process

If you have just built a new PC with Vista 64 bit and are planning on installing IE8 (64 bit, but possibly 32 but as well) and you haven’t yet registered your copy of Vista. STOP!

Register it first using IE7, because if you try using IE8 you will get a friendly message informing you that:

“The browser version you’re currently running does not support the Windows Vista product registration process.”

It then helpfully suggests you install IE7. Can I find IE7 for Vista 64 bit on the MS site. Nope!

Perth .NET User Group: A Great Start to the Year

I’ve been remiss by not blogging about the 2 user group meetings we have had so far this year.

We don’t run a meeting in January due to the holidays, so February’s well attended meeting was the first and good start to the year. Ola Karlsson stepped up to the task of presenting on Silverlight and what it’s good for. He blogged about it here (with links from the presentation). And special thanks to Ola for giving both halves of what was originally planned to be a 2 speaker event.

If you wanted an indication of the level of interest in testing and Test Driven Development (and Design) (TDD), then you needed to look no further than our March meeting when Rhys Campbell presented on Real World TDD. We had the highest attendance of any meeting in the group’s history; it was standing room only! (I lost count at 62 people). He posted a follow-up here.

Thanks to both presenters.

Our next presentation will be James Miles on Flexible UI Composition with WPF. Don’t miss it!

IE8 Goes Live

On Thursday, Microsoft released Internet Explorer 8. The release is publicly available here.

The new IE 8 runs on Windows Vista and Windows XP operating systems, as well as Windows Server editions from 2003 and beyond. Windows 7 Beta testers should use the version of IE 8 that came with the beta, as Microsoft customized that browser to work specifically with Windows 7 features.

Collections

If you ever find yourself in need of a data structure that is not present in the .NET Framework you should check out these free collections that contain C# implementations of trees, heaps and many other data structures:

  • The C5 Generic Collection Library for C# and CLI is a library of generic collection classes for C# and other CLI languages (.Net 2.0 and later, and Mono 1.2 and later). There is a freely downloadable book about C5.
  • Wintellect’s Power Collections for .NET: The goal of the project is to provide generic collection classes that are not available in the .NET framework. Some of the collections included are the Deque, MultiDictionary, Bag, OrderedBag, OrderedDictionary, Set, OrderedSet, and OrderedMultiDictionary.

Performance Analysis of Logs (PAL) Tool

OK, you have a server with a suspected performance problem. What do you do? You collect performance counters, right? But which ones? And what do you do to make sense of the reams of data once collected?

The free PAL (Performance Analysis of Logs) application hosted on Codeplex is an easy to use tool that collects and reads in a performance counter log and analyzes it using known thresholds (provided). The tool generates an HTML based report which graphically charts important performance counters and highlights alerts when thresholds are exceeded. The thresholds were originally defined by the Microsoft product teams and members of Microsoft support, but continue to be expanded by this ongoing project. It currently contains threshold files for IIS, MOSS, SQL Server, BizTalk, Exchange, and Active Directory.

This tool is not a replacement for traditional performance analysis, but it automates the analysis of performance counter logs enough to save you time and narrow your search. Written and maintained by Clint Huffman, the PAL tool has been around for some time but it’s not as well known as it should be, given how useful and easy it is to use.

If you want to have a look at a sample report, download and install PAL and then click this link.

Prerequisites
The optional GUI portion of PAL requires the Microsoft .NET Framework v2.0. PAL uses the Log Parser tool to query performance counter logs, and requires the Office Web Components 2003 in order to create charts. Both are freely downloadable.

[This MSDN page gives a detailed description of all the performance counters used when monitoring BizTalk.]

SQL Server 2008 Express Edition

Did you know that the free SQL Server 2008 Express with Advanced Services can run SQL Server Reporting Services reports on data on the local instance? You can use all the report definition features that you find in other editions of Reporting Services. For example, you can create drill-through reports, sub-reports, and parameterized reports that include charts, tables, matrices, and lists.

There are a few differences when compared to the full version of Reporting Services:

  • All server components must be installed on a single server. You cannot use a remote server for the report server database.
  • All report data sources must be from SQL Server databases that are installed on the local SQL Server instance.
  • All reports are processed on demand. Scheduled and unattended report processing is not supported.
  • Data source connection strings and Reporting Services URLs have different default values in a SQL Server Express installation. SQL Server Express always installs as a named instance. Any URLs or connection strings must include the instance name.
  • It’s free!

Whereas SQL Server 2005 Express Edition had a downloadable Toolkit containing Business Intelligence Development Studio (BIDS), which was required for creating reports for SQL Server Reporting Services, SQL Server Express 2008 with Advanced Services contains BIDS as part of its install. (Note: The Feb 2009 version of Books Online still states that it is a separate install). For more information, see the section “Reporting Services in SQL Server Express with Advanced Services” in Books Online.

The official SQL Server Express installation guide is here. The pre-requisite list is here: Hardware and Software Requirements for Installing SQL Server 2008

For ongoing SQL Express announcements, check out the SQL Express blog.

If you only have the vanilla version of SQL Express installed, there is also an express version of SQL Server Management Studio available for download.