.NET     Console.WriteLine( "All Things .NET" );
.NET Nerd Blog Home
3.23.2011

 
Resharper Exceptoin when Debugging Unit Test
Get an exception when debugging a VS unit test through the R# unit test window (debug selected tests).

System.ArgumentException: The directory name C:\Program Files\JetBrains\ReSharper\v5.1\Bin\PrivateAssemblies\DataCollectors is invalid.

Looks like the fix is to create a empty PrivateAssemblies and DataCollectors folders to make the directory structure above.

Weird error when running unit tests :: JetBrains Developer Community


12.15.2008

 
Sync v. Mesh v. SkyDrive
Ugh - Microsoft is making a mess out of all these terms and confusing us all along the way. Based on a little help from this post, here's the lineup:
  • Live Sync (formerly FolderShare). sync folders amongst machines. Currently PC only I think (FolderShare used to have Mac support). Used internally by Mesh to do sync
  • Live Mesh - part of the Azure Services Platform. Contains the "Live Desktop" element along with machines (devices) and users to all sync amongst themselves.
  • SkyDrive - just a hard drive in the sky (as of now, 25 GB storage, 50 MB per file). Web based access to items in various folders. Set access perms per folder.


10.03.2008

 
highlight.js
Whenever I get around to posting code, this highlighting helper Javascript will come in handy.

highlight.js


6.22.2008

 
VS 2008 - XAML Intellisense Broken
After another machine rebuild due to thinking that I had hosed up my VS install, I finally found this documented problem. I was missing two things in the VS 2008 XAML editor: (a) Intellisense, and (b) +/- collapsable regions automagically created for all XML nodes.

Turns out they're both fixed by the same issue: Running Windows SDK 6.1 for .NET 3.5 AFTER VS 2008 breaks it.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2892404&SiteID=1

Bottom line:
regsvr32 C:\Program Files\Common Files\Microsoft Shared\MSEnv\TextMgrP.dll


3.11.2008

 
Installing Win SDK after VS2008 breaks XAML Intellisense
Just as it says, after installing the Windows SDK for .NET 3.5, intellisense in VS 2008 stops working.

I followed the steps for the manual re-reg of TextMgrP.dll and things seem to work ok.

Microsoft Windows SDK Blog : Workaround: Installing Win SDK after VS2008 breaks XAML Intellisense


3.10.2008

 
MCTS exam for WPF
There is some chatter these days about the WPF (and other .NET 3.5 techs) test for MCTS - I guess so far in beta. Here's the info on the WPF test.

Preparation Guide for Exam 70-502: TS: Microsoft .NET Framework 3.5 - Windows Presentation Foundation


9.15.2007

 
INotifyPropertyChanged in base class
Thanks to Josh Smith for pointing out a couple of good thoughts on supporting INotifyPropertyChanged in a base class.
  • Cache PropertyChangedEventArgs so there's only one per property name
  • Verify property name (in debug mode) since it's just a string - in case dev fat fingered the name (of course dev should be using code snippets to create the property, right?)
  • Do some setter post processing

A base class which implements INotifyPropertyChanged � Josh Smith on WPF


6.26.2007

 
Debugging WPF Apps
The thing I have the biggest trouble with in WPF is debugging - when it comes to Bindings, ControlTemplates, generic.xaml, etc. it's sometimes difficult to figure out what the underlying WPF engine is doing "for you".

Below are some good tips. The overview:
  • Look at InnerException (or set the debugger to break on all exceptions)
  • Use the various TraceSources - I have the full config file in my local wiki.
  • Create a dummy ValueConverter that does nothing, but let's you set a breakpoint to see what's happening in the binding.
  • Use GetValueSource method to see where a value is coming from.

Tips on how to debug and learn about WPF � Josh Smith on WPF

Thanks Josh!


5.30.2007

 
WPF Custom Control - generic.xaml
I was writing a custom control today - started by using the VS 2005 "Add New Item..." dialog. After providing the filename, it barfed with a message "Value does not fall within the expected range". Obviously the new item wizard doesn't like something about my project. It actually created the code-behind file successfully, but nothing else, so I was left to setup the themes\generic.xaml file myself. Easy enough, right?

Created a simple folder in the project, called it "themes", then created a simple generic.xaml file, which contained a ResourceDictionary. Now when using the custom control from some window, I would get nothing. argh. Looked at the compile settings for generic.xaml, Build Action "Page", "Do not copy" ... looks good. Struggled around for a bit, then finally compared to another VS 2005 project started from scratch, where the add new item works.

The answer: AssemblyInfo.cs needs a ThemeInfo attribute.
Mine looks like this (sans comments), and it all seems to work now...

[assembly: ThemeInfo(
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly )]


5.17.2007

 
Merging Code
Another from the "not necessarily related to .NET proper" category ...

I'm doing quite a bit of manual merging of source code files lately, and am trying to come up with the best process and toolset to do so. In order of age, there's WinDiff (ancient Win32 days), then the SourceSafe diff tool, and TFS. There are a ton more, but those are what are in my current arsenal.

I know that TFS is extensible in terms of the diff and merge tools, allowing you to point it at whatever tool you want. Turns out, their default tool is a standalone tool: DIFFMERGE.EXE Since we're not using TFS for these source files I'm merging, I played with using that as a stand-alone tool. The highlights:
  • You have to provide file path information on the command-line, which is a bit painful
  • Can't compare directories - it's one file at a time
  • Merge results are immediately saved in the 3rd pane to a given file (pretty cool)
Knowing that TFS allows this extensibility to plugin other tools, I searched for the diffmerge tool. Found this post from James Manning about the various tools that are out there.

WinMerge - merge can disregard whitespace, can't automatically edit the resulting file. Looks like you have to copy/paste into the 3rd window.

KDiff3 - UI looks very non-Windows-ish, but feature set rocks. Commands to take content from file1 or 2 and shove it in the right spot in the merge results file. Save the merge results at the end.

So as of now - the winner is KDiff3. I'll be using it for my next merge operation.


5.15.2007

 
Visual Studio Orcas
I've been experimenting with Visual Studio Orcas (beta 1) lately, to see if it's any better, particularly in 2 places where I'm having pain writing WPF apps in VS 2005:
  1. Showing XAML files in design view, if they contain UserControls, or represent a custom class that derives from a WPF control type.
  2. Describing the ACTUAL error when there's a problem loading a XAML file. (the dreaded "Cannot create instance of XYZ defined in assembly ABC... blah.xaml, line 2, position 5". Of course, that location in the file is nowhere near the code causing error (it's usually the first namespace declaration for the outermost element in the XAML file).
I'm happy to report, that with Orcas, both problems are fixed (at least to some extent)!
  1. After wading through seemingly tighter, more picky error reporting by the Orcas designer, I have been able to view my UserControl and custom class derived XAML files in deisgner mode!!
  2. I just ran into the error in XAML file exception in VS05, loaded up the same solution in Orcas, and the exception there pinpointed the line (and character!) where the problem was (still a little funny - the error was in the code-behind for a custom class, failing on a DependencyProperty.Register method [bad parameter type FrameworkPropertyMetadata instead of UIPropertyMetadata?] -- so the error shows up in the XAML file that contains that failing class).


5.07.2007

 
Top Rules for the Windows Vista User Experience
Now that I'm in full swing WPF development, there's definitely a tendency by the customers to do whacky things in the UI.

Here's a list of UI guidelines / rules to adhere to.

MSDN: Top Rules for the Windows Vista User Experience


4.03.2007

 
ASP.NET Ajax (Atlas) - JavaScript Hijacking
I don't know much about this, but the paper is short and an interesting read. For me, it pointed out the issues to take care of when using an AJAX-like technology. So, if you use XmlHttpRequest, read this.

Why is it .NET related? Well, as of the writing, supposedly many "AJAX frameworks" can be "hijacked", including Atlas.

http://www.fortifysoftware.com/servlet/downloads/public/JavaScript_Hijacking.pdf


3.29.2007

 
WPF, how to hit the ground running
I'll be increasing a few PageRanks by doing this, but here's how I started.

First, go here:
Building a WPF Workstation

It's actually a little dated, but still works if you want to go the VS C# express route. The November CTP of WPF seems to be the very last that isn't integrated into "Orcas". And going "Orcas" means getting Virtual Server and billions of bits. I don't know I want that.

Then, go here:
Five Day Course For Hitting the WPF Curve/Cliff

I'm stuck on Day 2 only because I decided to buy/read and study Charles Petzold's book. I have learned most of my Windows programming basics from Mr. Petzold, including programming for Win16, Win32, Winforms, and now WPF.

I will warn you... EVERYONE else in the world will teach you WPF by throwing you at XAML. Petzold has decided to go the other way. Like me, I think he hates things that work by magic. So he shows you in part 1 of the book that nothing is magic... underneath it's all code.

That's what I liked about WinForms. The magic of resource files was replaced by 100% code. You made a label in the designer? There it is in the code. While .NET 2.0 changed this slightly in ASPX, it still made sense. I could go find code that matched my designing.

Anyways, after you read through part 1 of the book, you understand WPF is a nice framework with a nice shortcut declarative programming method using XAML.

Trust me, get the book. Then you won't be confused by Routed Events, Dependency Properties, and the other ideas that are a departure from traditional windows programming.

Now that turns Day 2 into month 2... so I'll let you know when I get some real apps up for demonstration.


3.22.2007

 
Url Rewriting with ASP.NET
I'm always hearing from my buddy Intern Joe about UrlRewriting. Someday I better read this post by ScottGu so I can discuss the technology from an ASP.NET point of view.

ScottGu's Blog : Tip/Trick: Url Rewriting with ASP.NET


3.07.2007

 
Training Videos
Thanks to ScottGu for pointing out these free training videos.

Free SQL Server Training Videos (and other good data tutorial pointers)

Free ASP.NET AJAX "How Do I?" Videos

keywords: SQL Server SQLServer AJAX Atlas asp.net


3.01.2007

 
HOWTO: Use Virtual PC's Differencing Disks to your Advantage
We use VPCs all the time around the company to experiment with beta bits. Today I'm running into a problem trying to install the Orcas CTP on a VPC (running in virtual server) that has a dynamic disk.

How can a dynamic disk run out of space? -- isn't it supposed to grow as needed? (I converted this one to dynamic from fixed, not sure yet if that has something to do with it.)

Anyway - when poking around, found the article below, mostly about using differencing disks. We just saw this techinque used recently for some BizTalk work. The idea is cool - create a single VHD with the base OS and core software for all VPCs, then use differencing disks for everything you ADD after that.

(Article also has some links to other good VPC tips sites)

HOWTO: Use Virtual PC's Differencing Disks to your Advantage


2.21.2007

 
Localizing WPF Applications using Locbaml
I am familiar with localizing WinForms and ASP.NET apps, but now that we're getting into WPF, here is a decent article on getting started. Looks like a lot of the concepts are carried over from WinForms...

Localizing WPF Applications using Locbaml - The Code Project - Windows Presentation Foundation


2.20.2007

 
Beginning SQL Server 2005 Reporting Services
When it's time to ramp up on Reporting Services, I should probably start here. This looks like a pretty decent 4-part writeup on SQL Server 2005 Reporting Services.

Beginning SQL Server 2005 Reporting Services (Part 1)


1.31.2007

 
TFS Registry Settings
I am digging around today looking for some TFS info, and found these reg hacks, which would have helped a ton when working for our last client. I wouldn't always be connected through their VPN, so when firing up VS2005 it would take a long time to timeout on the TFS server connection.

Rants of a Hippie Coder : A couple helpful Team Foundation registry settings

perma-info:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\TeamFoundation
DWORD "AutoLoadServer" (Zero means do not reconnect automatically. )


1.24.2007

 
WinForms - DataBinding to Nullable Types
Over on my IK blog, I posted a quick note on WinForms: DataBinding a DateTimePicker control (with ShowCheckBox=true) to a Nullable .


12.25.2006

 
VS 2005 SP1
Some things to think about and do before installing Visual Studio 2005 SP1.

First off, a requirement:
  • If you have installed the Web Application Project type from the MS downloads, you must uninstall it before installing the service pack. (Apparently the pack includes it)
Post is here - talks about the following:
  • disable patch cache (save 1.3 GB of disk space and lots of I/O time during install)
  • uninstall c++ if you're not using it
  • will have to reinstall after upgrade to Vista


12.12.2006

 
DataSet.Merge - Failed to Enable Constraints
I've been working on an integration project for our client where we are wrapping some legacy data with a web service layer, and pointing an existing WinForms app at it. There is a bunch of client side code that calls DataSet.Merge and fails with the error Failed to enable constraints.

Many times, the problem is what the error is trying to tell you - you have a relationship defined in the dataset that is not satisfied when trying to merge the data - a child row in a relationship perhaps doesn't have a corresponding foreign key in the parent table...

Tonight I was getting this error, and double checked all relationships (spit out the relationships to the debug window), checked for null values and duplicate primary keys (again spewing to the debug window) -- where is my uber DataSet visualizer that I've been wanting to write? (more on that in another post)

Finally I google'd and found this thread. Sanjay explains the best way to find what is causing the error:


foreach ( DataTable dt in mergingSet.Tables )
{
if ( dt.HasErrors )
{
foreach ( DataRow dr in dt.GetErrors() )
{
Debug.WriteLine( dr.RowError );
}
}
}

That'll do it - so simple, huh? The big question - why couldn't the MS devs have just put this info in the exception text itself?

Additional note: HasErrors and GetErrors may not be available/set until AFTER you have attempted the Merge operation (depends on if it's a FK, PK, or unique constraint issue)


12.03.2006

 
Install IE6 and IE7 on the Same Machine
Well, after I realized this is using VirtualPC to run one of the versions, I was not as impressed. Given that, why are there 19 steps to this process?

Anyway - some decent info about various settings, etc.


 
Top 30 Windows Freeware Apps
via LifeHacker, here is a decent list of the top 30 Windows freeware apps. Things such as:
  • Virus scan
  • Photo editing
  • RSS reader
  • Media player
  • Note taking
  • IM client(s)


11.03.2006

 
Script Multiple Objects in SQL 2005
This was not obvious, and I'll probably forget, so here it is ...

To generate scripts for multiple objects (say, Stored Procs) in SQL 2005:
  • Select the folder such as "Stored Procedures"
  • Hit F7, brings up the summary window
  • Now here you can multi-select, right click, Script as ...
Nice of them to bury that gem in this version.


10.17.2006

 
What causes ASP.NET App Restart
Here's a good definitive list of which events cause an ASP.NET AppDomain restart. These are important since and AppDomain restart will cause you to lose any inProc session you have for a given user.

Things like adding, modifying, deleting assemblies from the bin folder, changing source code files in app_code dir, changing web.config, etc.

ASP.NET Forums


10.01.2006

 
Web Application Builds in VS2005
Tips/Tricks from ScottGu about optimizing builds within VS2005 for Web Site & Application projects. Includes a discussion about which builds faster under which circumstances, and a list of things to look at for each type of project that can hinder the build times.

Web site projects:
  • Dueling assembly references
  • Keeping app_code small
  • Enable on-demand compilation
Web application projects:
  • Split large projects into multiple sub-projects
  • Look at using Web Deployment projects


9.26.2006

 
TFS Dogfood Statistics
Interesting TFS statistics - the volume of files Microsoft is shoving at TFS.

bharry's WebLog : September TFS DevDiv Dogfood Statistics

55 Million files, 295 GB of compressed file data, 14.6 million Get operations, ...


9.20.2006

 
TFS and Team Build Fun
I'm getting acquainted with TFS and Team Build for the first time. The first couple issues I've noticed, which brought up questions (and sometimes answers):

Where are the labels in the history?
bharry's WebLog : Why TFS labels aren't like SourceSafe labels
Finding the changes between 2 labels in TFS

Why is Team Build labeling AFTER the GetLatest step?
Here is an explanation of the labeling system. Basically the labeling system much more elaborate in TFS than in VSS (see above). You can label based on Latest Version, Changeset, Date, Label (why label based on another label?), and most importantly, Workspace Version. The latter labels the tree in TFS based on the collection of files that you have in your workspace! This means that during a Team Build, the latest files are retrieved from TFS, then those files are labeled. We tried a test here at work and proved that a check-in after the GET but BEFORE the label is NOT included in the label. We were unable to verify this ourselves by looking at the Label task in TeamBuild, but the assumption here is that the default for the label task is to label by "Workspace Version".

Does branching work any better in TFS than in VSS?
Preliminary accounts say yes. In VSS, branching gets hosed up because there is a tendency to share/link files across projects. In TFS, you can't share files. I tried a branch this afternoon and it worked great. You can branch based on the same things you can label on (Changeset, date, label, latest version, workspace version). You create the branch in the location of your choice. The real question is: how is the support for merging a branch back into the main line?

How do you build a specific label?
Override CoreGet task and use one or more Get commands. examples here.

How can I build solutions from / share code across multiple Team Projects?
The layout for this is much like I've done at a recent client. You have dependent/common assemblies in a separate team project. Those have a post-build step to copy their output to known/fixed directory. Referencing projects refer to this common code by their known / fixed directory relative to their location.

If the fixed references location is in another TFS project, you have to adjust the Team Build project file to get more than just the TFS project for the solution you're building. Here is a post that shows how to override the BeforeGet task.

Team Project with Shared Code


Where are all the default task elements (from the import file)?
\msbuild\Microsoft\VisualStudio\v8.0\TeamBuild

How do you "undo checkout" for another user?
use tf lock ... from command line. examples here.
tf status /user:* /server:tfs.myserver.com $/SomeProject/SomeFile.cs

How do you find files checked out by any user?
tf status /recursive /workspace:* /format:detailed /server:tfs.myserver.com $/SomeProject/SomeFile.cs

How do you pass login credentials on the command line?
... /login:user,password (login can contain domain\user)

More general Team System info at Vertigo's Team System blog. (we have actually partnered with these guys a few times on some projects)

Team Foundation Server FAQ

MSBuild Tutorials and Resources
  • Web Deployment Projects and MSBuild
  • Customizing msbuild
  • Reference, team blog, hands-on-lab
  • msbuildtasks home (suite of custom tasks, including IIS appPool mgmt, NDoc, NUnit, SqlServer exec, VSS support, xml/xslt, zip)
  • MSBuild wiki on Channel9





9.18.2006

 
Writing Your First Avalon Program
Whenever I get around to cutting some WPF code, here's a decent writeup of what I'll need, where to get it, and what code I'll need.

Sam Gentile : Writing Your First Avalon Program on Windows Vista RC1



Powered by Blogger