Shawn Cicoria - CedarLogic

Perspectives and Observations on Technology

Recent Posts

Sponsors

Tags

General





Community

Email Notifications

Blogs I Read

Archives

Other

Use OpenDNS

December 2006 - Posts

WCF and Sharing Data Contracts

A nice feature of Windows Communication Foundation ("WCF"), and specfically, the svcutil.exe utility for generation of proxy code (it has a few other uses - one other nice feature is the pre-generation of serialization code) is having it share Data Contracts contained in a shared assembly on both the sender and receiver.

The /reference switch provides this capability - below is the /? help from the command line:

/reference: - Reference types in the specified assembly. When generating clients, use this option to specify assemblies that might contain types representing the metadata being imported. (Short Form: /r)

Now, this probably violate some core SOA tenets with regards to WSDL or Schema based contracts, but if you're in an all .NET world, or you've got ownership of both sides of the wire (or service boundary) then this does help a bit.

In ASMX a couple of ways to do it was to hand-code the proxy or use WSDL.exe and then comment out the type you want to share inside of the generated code.  Now, with the /reference switch for svcutil.exe this does the same thing.

 

When a property isn't a property...

I spend about 95% of my time, when coding, in C#.  So, recently rolled onto a project that had built a framework using VB.NET (that's the first indication of trouble).

So, I see something like the following when trolling through the code:

Public Class PoorClass

    Public ReadOnly Property BadProperty(ByVal aParm As String, ByVal bParm As String) As String

        Get

            Return "This isn't really a property anymore"

        End Get

    End Property

I had no idea you could add parameters to a property.  Turns out, it's only possible in VB.NET that I've seen.  You can't do this in C# - and with good reason.

The problem with the above code (other than the total verbosity of VB.NET itselft) is it violates a core concept of what an object is: something described by "state" and "behavior" - or for .NET we can use Properties (and fields) and methods.  So, a property is supposed to be an object's state.  But if we're passing in parameters, it now has become a "method".

From Wikipedia (Object (conputer science))

In the case of most objects, one can access the data members only through the method members, making it easy to guarantee that the data will always remain in a well-defined state (class invariants will be enforced). Some languages do not make distinctions between data members and methods.

Three properties characterize objects:

  1. Identity: the property of an object that distinguishes it from other objects
  2. State: describes the data stored in the object
  3. Behavior: describes the methods in the object's interface by which the object can be used

So, this to me violates the core concepts of objects. 

The Java world has had Javabeans that provide designer support for interpreting method names such as get_, set_, Is_.  Ultimately, they all boild down to methods in the bytecode, and in .NET methods, but it's about "object thinking".  And the framework that I'm looking at violates that principle.  And a misuse of a capability that probably should be prevented in the first place by the compiler - but that's when you get a bunch of VB.NET programmers, with VBA & VB6 as their heritage, building an OO based framework that should be re-usable across any .NET language.

In fact, if I try to consume this from C# it looks more like magled IL, but nonetheless, consumable:

    BadLibrary.PoorClass c = new BadLibrary.PoorClass();

    c.get_BadProperty2( "test" );

 We see the property looks like a method with the "accessor" verb (get_) prefixed.  This is what the IL looks like that's emitted from the VB.NET compiler.

.property string BadProperty {

     .get instance string BadLibrary.PoorClass::get_BadProperty(string, string)

}

So, it's a property.  Just doesn't act like on, nor does it appear as such to C#.  Here's the real method in the IL that's consumed from C#:

.method public specialname instance string get_BadProperty(string aParm, string bParm) cil managed {

   .maxstack 1

   .locals init (

     [0] string text1)

   L_0000: nop

   L_0001: ldstr "This isn\'t really a property anymore"

   L_0006: stloc.0

   L_0007: br.s L_0009

   L_0009: ldloc.0

   L_000a: ret

}

 

This is just a single example of numerous issues that I've seen.  The framework is ripe with magic numbers, hungarian notation, type name abbreviations that are more cryptic than valuable, overly complex nesting of interface implementations.  And that's just the code.

Backup for Vista that Works and Gives you Control

Need a backup tool that let's you take control?  Vista's backup just plain stinks.  Microsoft is supposed to release NTbackup.exe for Vista after public RTM as internally the reasons for dropping it were trashed.  Who knows what they were thinking.

But, this tool works on Vista... 

Link to 2BrightSparks | SyncBackSE | Features

CPU Monitor Updated - 1.3 Posted.

Finally got the "right" bug... Shutdown / Logoff working correctly. 

CPU Temperature Monitor

!!! STILL A MINOR BUG - WILL BE UPDATED TONIGHT - 12/19/2006!!!

Updated 12/18/2006 - fixed issue with not listening for Microsoft.Win32.SystemEvents.SessionEnded event - can't logoff/shutdown issue

Updated 11/24/2006 - added check if system implements the required WMI objects.

Updated 11/30/2006 - fixed GDI memory leak

Given the issues with Toshiba laptops running very hot with Vista Glass Aero enabled, and just in general with XP as well ( Hot enough to burnout motherboards that require replacements from the manufacturer)  I wrote this utility to give me system tray status on the current CPU temperature.  I'm currently adding GPU temperature but that requires distribution of licensed components (dynamic libraries).

Installation Files - a self extracting Exe file that contains the MSI installer - built with WinRar.

Solution Files - only contains projects with no private certificates - you'll need to change some things to get it working.

Basically, it just sits in your system tray showing the current CPU temperature with the following color schemes:

  • Green - Running at below 50% of critical temperature
  • Yellow - Running at > 50% but < 75% of critical temperature
  • Red - Running >= 75% of critical temperature.

These settings are configurable if you modify the TemperatureMonitor.exe.config file, along with the maximum readings.

The first reading shown is the current CPU temperature; the second is the Critical Temperature as reported by WMI. 

The WMI namespace and object is root\WMIMSAcpi_ThermalZoneTemperature

WMI unfortunately requires elevated permissions on Vista.

The task bar icon has 2 menu options;

  • Restore - restores the window as shown below
  • Exits the application

The main window is show below:

  • The first tab just shows a Line Plot of the history of readings
  • Second tab is a list of those readings
  • Third tab is used for diagnostics and has a list of any exceptions.  There's also a file written to the application directory but it only has the last exception
  • The last tab is the about box that also has the "Install Public Certification" action button on it.

The assembly is signed with my sample signing certificate.  If you click on the about box you can install the public certificate but it still requires user action to launch in Vista given UAC restrictions and Windows Defender doesn't recognize the program.

Use at your own risk!!!

 

Some users are reporting issues.  This is dependant upon specific WMI obects being present and implemented on your system.

To Test, put the following into a VBS file, then run the following script from an elevated command prompt as follows:
cscript CpuTemp.vbs
============
''''On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM MSAcpi_ThermalZoneTemperature",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "MSAcpi_ThermalZoneTemperature instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "CurrentTemperature: " & objItem.CurrentTemperature
Wscript.Echo "CurrentTemperature: " & objItem.CriticalTripPoint
Wscript.Echo "CurrentTemperature: " & objItem.ThermalStamp
Next

VMWare to Microsoft VPC converter...

Link courtesy of Greg Duncan...

http://coolthingoftheday.blogspot.com/

Link to Files

Slipstreaming the VS.NET 2005 SP1 Installation

Answers to my prayers - kind of.

Good post on slipstreaming the SP1 patch into a Visual Studio 2005 Fresh Installation.

http://blogs.msdn.com/heaths/archive/2006/12/16/slipstreaming-visual-studio-2005-service-pack-1.aspx

Verizon Triple Play now in NJ

Sorry about the advertisement, but been using Verizion FiOS since August and it's by far the best Internet service I've had.  I live in a fortunate area that was wired, I mean "fibered" early on.

Now, TV is ready - here's the list of towns that are on the initial list which begins this Monday:

http://www22.verizon.com/about/community/nj/nj_pdfs/Deployment_Schedule_Public.pdf

http://www22.verizon.com/about/community/nj/

Who says NJ sucks?  Well, it actually has the highest taxes, most populated, higest car insurance rates, and of course Camden and Newark.  But what the hell, we have FiOS!!!!

Firefox 2.0 Freeze Up on Vista

 I've been running FireFox 2.0 for some time and have noticed way too many Freeze-ups causing me to kill the process somehow.

Funny thing is, when Vista's Crash Analysis comes back it indicates that "Firefox has a new version" - but when I check for new versions from within Firefox it comes back indicating I have the latest.

So, disabling some of the extensions that come with Firefox seems to have done the trick.

Generally, I run Google Toolbar & Google Browser Sync.  I also checked yes on installing both the DOM Inspector and Talkback.

So, I started out with all disabled - No lockups.

Then, just turned back on the 2 Google extensions (can't live without em). Still no lockups.

So, I've disabled Talkback and DOM Inspector and all is good.  You'd think that the core extensions that the Mozilla team distributes with the browser would be the most tested.  My guess is Google's are just becuase of the deeper pockets.

Visual Studio 2005 SP1 - Microsoft Please create a new Clean Install Version!!!! Refresh the New Installation Media

If it takes 30+ minutes and on some machines 1+ hour to install SP1, why not refresh the installation media so that a clean install contains SP1?

Microsoft wake up!!!  Churn is bad enough but many of us wipe machines and restart projects with clean hardware.  If we've now got up to 2 hours just for VS.NET that's a killer.

Heath Stewart's Blog : Save Time and Space for VS 2005 SP1 by Disabling the Patch Cache

Good pointer for those that can't wait :) Sorely needed SP1 is out soon... 

Link to Heath Stewart's Blog : Save Time and Space for VS 2005 SP1 by Disabling the Patch Cache

DevDiv Hotfix Public Availability Pilot Program

This is a great move on Microsoft's part.  Could never understand the hoops general folks need to go through to get Hotfixes.  Especially for Visual Studio.... 

Link to DevDiv Hotfix Public Availability Pilot Program

Excellent Example of Factory Pattern using Generics and Configuration

Just had to bookmark this one...

 

http://www.softinsight.com/bnoyes/PermaLink.aspx?guid=f9834693-e992-4bf1-9408-1ab8d2cb518c

Pro WCF - Index has been created...

The book I particpated on (Pro WCF: Practical Microsoft SOA Implementation) finally has had the index created.  It's getting close to publication date, I'm told January.  This has been a long road, actually inception goes back 2 years.  Timing is good as we're up to RTM on the content & code.

An index is fundamentally how I judge a book. Generally, tech books you pick up, read in the reading room, but refer back to it for concepts starting at the TOC or the Index.

This one's rich...

Profits rise at Microsoft joint venture - Avanade

Nice blurb on how we're doing!!!! 

I like the relation to how we're doing is an indication of the uptake of Microsoft products in general.  1/2 a billion ain't bad for a company that's only 6....

 

Link to Profits rise at Microsoft joint venture

More Posts Next page »