Monday, October 03, 2005

Rude AppDomain unloads

Joe Duffy has a post on avoiding and surviving rude AppDomain unloads. This is a useful post and all, but the highpoints are the following 2 quotes:

... if you piss SQL Server off by taking too long in one of your finally blocks (for example), it will get a tad snippy
and:
It uses a great method RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup located in the System.Runtime.CompilerServices namespace. We call it SRCSRHECWGC—pronounced “shreek shreck woogy-cuck”—for short around here.
Mmmm shreek shreck woogy-cuck.

[Listening to: Eminem - Kids]

Friday, September 23, 2005

Sizing memory for virtual machines appropriately

The Virtual PC Guy doles out some guidelines for appropriately sizing memory of virtual machines

I had always (mistakenly) believed that I should be throwing as much memory at my VPC as possible. I have 1.5GB of which I have 1GB given to VPC. Prior to that I had 512MB with 256MB for VPC which was quite slow. Even with more memory I haven't noticed a huge performance gain. Perhaps I've just been starving out my host system.

Good thing the memory was cheap.

[Listening to: Powerman 5000 - Son of X-51]

Monday, September 12, 2005

Shared Services

From Larry Osterman - a description of
Shared Services and why they're important.

I gotta play with this some day.

Updated: Larry posted a second entry on a clever trick to debug shared services. In a nutshell:

Split a shared service into it's own:
C:\>sc config type= own
And put it back again:
C:\>sc config type= share
[Listening to: Black Sabbath - Trashed]

Wednesday, September 07, 2005

On Threads and WinDBG|SOS

Yun Jin posted a series of articles on Thread, System.Threading.Thread, and !Threads that you can find here:


[Listening to Sister Sledge - He's the Greatest Dancer]

[Ed: 7-Aug-2006 - Finally fixed goofy list formatting]

Tuesday, September 06, 2005

Thank you Scott for getting rid of those #$@#$! binding logs

For months now I kept getting assembly binding info being dumped into my c:\temp directory for every .NET executable on my machine. As I use c:\temp for (surprisingly enough) temporary files it was getting quite aggrevating having to constantly delete all those .exe directories.

I vaguely remember enabling this but I couldn't remember/find what I had done so I could shut it off.

Fortunately, I happened across this blog entry from Scott Hanselman about assembly binding redirects which pointed me to the right place:

Change the registry value HKLM\Software\Microsoft\Fusion\ForceLog to 0.

Soooo much quieter. Ahhh.

[Listening to: Kiss - Cold Gin]

Monday, August 22, 2005

Wednesday, August 17, 2005

Magic Numbers for Debugging Memory troubles

I got tired of searching for this each time I needed to so here it is -- the magic memory values when using the debug heap in Microsoft Visual C++ 6.0, 2003 and presumably 2005.

Culled from here and here.

0xBAADF00D -- Allocated by HeapAlloc, not yet used by malloc
0xCDCDCDCD -- Allocated but uninitialized
0xFDFDFDFD -- No mans land. Surrounds allocated block
0xABABABAB -- 2 words following allocated block's no mans land
0xDDDDDDDD -- In the process of being freed.
0xFEEEFEEE -- Freed

[Listening to: Kittie - Suck (Live)]

Windows Message Hooking in .NET

You just never know when you have to get down to the metal and observe/tweak/ambush the windows messages directly. Ben Wu
shows us how with SpyWindowFinalizer. This also gives us a means to detect controls that are not being properly Dispose'd.

[Listening to: Tripping Daisy - Piranha]

Monday, August 15, 2005

Xml Performance Checklist

Atsushi Eno gives an Xml perf checklist.

Don't know how valid/relevent these all are but I've blogged it here for future reference.

[Listening to: Crazy Town - Only When I'm Drunk]

Wednesday, August 10, 2005

Rico Mariani's Performance Tidbits : LogDump: CLRProfiler Log analysis tool

Performance guru Rico Mariani shares his CLRProfiler log post-processor which produces a very useful summary of perf stats.. In case you want to bypass the article (lazy lazy) you can jump to the source code directly.

[Listening to: Led Zeppelin - What Is And What Should Never Be]

.Net Security Blog : The Simple Sandboxing API

It's been a while since I've scooped referred to a post by Shawn Farkas, but here goes.
The Simple Sandboxing API - A simpler way to set up a sandboxed AppDomain. In a nutshell he is updating his .NET v1.x method which I blogged about here, using a new .NET v2.0 overload of AppDomain.CreateDomain.

[Listening to: Whitesnake - Give Me All Your Love]

Friday, August 05, 2005

[De]Serialization withToByteArray and ToStructure

More snippets... I love snippets.

From eicar (sorry, don't know his/her actual name)
Home-grown [de]serialization: ToByteArray and ToStructure

[Listening to: Janis Joplin - Piece of my Heart]

Omiting the Xml Declaration and the XSD and XSI namespaces

Scott Hanselman of The Ultimate Tools List fame posts together a useful snippet of code to Serialize an object while omiting the Xml Declaration and the XSD and XSI namespaces -- The XmlFragmentWriter.

This snippet was cobbled together from Sairama, a platform engineer at Corillian and Daniel Cazzulino and, I'm sure, Scott too.

I've always kinda' disliked the extra "baggage" but was waaay too lazy to do anything about it.

[Listening to: Stone Temple Pilots - Where the River Goes]

Thursday, August 04, 2005

Simple harness to print exceptions in an app

A nice little example from Mike Stall on building a
simple harness to print exceptions in an app.

Don't know if this will be useful, but it's definitely something I want to remember. So here it is.

[Listening to: Elastica - Love Like Ours]

101 Samples for Visual Studio 2005

A bunch of samples on MSDN for both C# and VB.NET.

Can't remember who I got this from. My apologies.

[Listening to: Led Zeppelin - Rock and Roll]

Wednesday, July 27, 2005

ORACLE: Required permissions for v$mystat

Long time: no post. Busy. Working. Travelling. Excuses. Excuses.

Too many net resources point you to GRANT SELECT ANY DICTIONARY TO {user/role}' but I like a more granulated approach.

If you want to give just enough permissions for a user to v$mystat;

C:\> "sqlplus sys/passwd@tnsname as sysdba"

SQL> GRANT SELECT ON v_$mystat TO {user/role};


[Listening to: Marilyn Manson - Apple of Sodom]

Tuesday, July 05, 2005

Advanced .NET Debugging with PerfMon

Fellow Blogspotter Eran Sandler gives a nice overview on some PerfMon performance counters, what they mean and how to use them to detect some common issues such as leaks, fragmentation and lousy (my word not his) allocation patterns. It's nice having this all in one spot.

[Listening to: Ted Nugent - Free for all]

Wednesday, June 15, 2005

ORACLE: Enabling function-based indices (indexes?)

I was happily using function based indices to provide case insensitivity like so:

CREATE UNIQUE INDEX MyIndexName ON MyTable (
LOWER (SomeColumn) ASC
);

Worked like a charm. The uniques was case insensitive and the normal query like:
SELECT blah, foo, bar
FROM MyTable
WHERE LOWER(SomeColumn) = LOWER (:bindparam);

was happily using the index.

Until one day at (naturally) a client site, one of my fellow engineers found that the above query was performing a full table scan. And, despite what Tom Kite keeps saying, in this case, a full table scan is bad.

Only after some spelunking through Tom's Book Expert One-on-One Oracle did I find the magic. The database needs the following session/system variables in place to actually use the function-based indices:
QUERY_REWRITE_ENABLED=TRUE
QUERY_REWRITE_INTEGRITY=TRUSTED

I'll chock these up to the huge pile of stuff that "Oracle needs to have to work the way it should but is next to impossible to find unless you already know it."

Hopefully this saves someone else some time.

[Listening to: Tripping Daisy - Piranha]

Wednesday, June 08, 2005

Enabling the "Shut Down" option in Windows Server 2003

Once again I spent way too long trying to figure out how to allow my non-administrator user the ability to shutdown windows. Strangely enough Google was of little help. I guess the terms "shutdown", "enable", "user", "dialog" are too vague?

By default a normal user only has log off username in the list of options when you hit shutdown from the start menu. Just so I don't have to search for this again:

Run Administraive Tools/Local Security Settings
Navigate to:
Security Settings/
Local Policies/
User Rights Assignment/

Add the user/group in question to "Shut down the system".

Also, just in case others fall into the same trap, here's some food for the GoogleBots:
"shutdown windows" dialog "log off" enable
"shutdown windows" dialog "log off" allow
"shutdown windows" dialog "only log off"
"shutdown windows" dialog "shut down missing"
"shutdown windows" dialog missing
"shut down windows" dialog missing
"shutdown privilege" "windows 2003"
"shutdown privilege" "windows server 2003"
enable shutdown windows server 2003

Thursday, June 02, 2005

Assert.IsEqualGraph -- Comparing object graphs

Keith Brown over at PluralSight has a useful method to Assert the equality of 2 object graphs: Assert.IsEqualGraph.

I have a couple other quasi-useful Assertion type methods that I'll post here (if I ever get around to using the stupid computer again that is.)

[Listening to: Ozzy Osbourne - Over the Mountain]

Tuesday, May 31, 2005

Dumping XML content while reading it from a stream

Oleg Tkachenko posts a nice nugget on Dumping XML content while reading it from a stream. Since I'm a logging junkie this strikes home.

[Listening to: Marilyn Manson - Apple of Sodom]

Monday, May 30, 2005

ORACLE: displaying initialization parameters

Pulled from here and here.

Thinking I was clever I created a little parms.sql which will pull out all matching initialization parameters from the v$parameter table. Of course I find out that there's a built in way of doing this:

C:\> sqlplus someuser/passwd@tnsname
[snip]
SQL> show parameter spfile

NAME TYPE VALUE
------------ ----------- ------------------------------
spfile string %ORACLE_HOME%\DATABASE\SPFILE%
ORACLE_SID%.ORA

And while we're at it, here's how you get the full set of all parameters in a nice human readable format:
SQL> create pfile='filename' from spfile;
Note1: this creates the file on the server beside the original spfile (see VALUE above.)
Note2: you need to run this as sys as sysdba

[Listening to: Barry White - My First, My Last, My Everything]

Thursday, May 26, 2005

Of Performance and Peanut Butter Sandwiches

Rico Mariani (certainly in my top 5 blogs lists ever,) gives some tips on
Narrowing Down Performance Problems in Managed Code which border on instantly useful recommendations. Cool.

[Listening to: Fleetwood Mac - Silver Springs]

Thursday, May 19, 2005

ORACLE: Permissions for SQL Analyze

To run SQL Analyze, the user requires the SELECT_CATALOG_ROLE:

C:\> sqlplus system/passwd@tnsname
[snip]
SQL> grant SELECT_CATALOG_ROLE to theuser;

Grant succeeded.
If you want to use the index recommendation feature you'll need more privileges. You could grant DBA but I hate doing that, so enable each one independently:
C:\> sqlplus "sys/passwd@tnsname as sysdba"
[snip]
SQL> grant SELECT ON SYS.CDEF$ to theuser;

Grant succeeded.

SQL> grant SELECT ON SYS.CON$ to theuser;

Grant succeeded.

SQL> grant SELECT ON SYS.IND$ to theuser;

Grant succeeded.

SQL> grant SELECT ON SYS.OBJ$ to theuser;

Grant succeeded.

SQL> grant SELECT ON SYS.SEG$ to theuser;

Grant succeeded.

SQL> grant SELECT ON SYS.TAB$ to theuser;

Grant succeeded.

SQL> grant SELECT ON SYS.TS$ to theuser;

Grant succeeded.

SQL> grant SELECT ON SYS.USER$ to theuser;

Grant succeeded.
[Listening to: Stone Temple Pilots - Where the River Goes]

Monday, May 16, 2005

ORACLE: What is the difference between & and &&?

Culled from here.

What is the difference between & and && in a SQL script:

"&" is used to create a temporary substitution variable that will prompt you for a value every time it is referenced. Example:

SQL> SELECT sal FROM emp WHERE ename LIKE '&NAME';
Enter value for name: SCOTT
old 1: SELECT sal FROM emp WHERE ename LIKE '&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'

SAL
----------
3000

SQL> /
Enter value for name: SCOTT
old 1: SELECT sal FROM emp WHERE ename LIKE '&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'

SAL
----------
3000
"&&" is used to create a permanent substitution variable. Once you have entered a value (defined the variable) its value will used every time the variable is referenced. Example:

SQL> SELECT sal FROM emp WHERE ename LIKE '&&NAME';
Enter value for name: SCOTT
old 1: SELECT sal FROM emp WHERE ename LIKE '&&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'

SAL
----------
3000

SQL> /
old 1: SELECT sal FROM emp WHERE ename LIKE '&&NAME'
new 1: SELECT sal FROM emp WHERE ename LIKE 'SCOTT'

SAL
----------
3000

[Listening to: Will Smith - Will 2K]

Fixed typo in subject

Friday, May 13, 2005

What Pre-1985 Video Game Character Am I?

I normally don't post the results of these (although I must admit that I participate in every one) but I just couldn't resist:


What Video Game Character Are You? I am an Asteroid.I am an Asteroid.


I am a drifter. I go where life leads, which makes me usually a very calm and content sort of person. That or thoroughly apathetic. Usually I keep on doing whatever I'm doing, and it takes something special to make me change my mind. What Video Game Character Are You?

I'm not sure which part I like best: being summed up by a classic video game; being summed up by one of my favourite games from back in the day; or being summed up by a rock. In any case: sweeet.

Tuesday, May 10, 2005

ORACLE: Creating tablespaces

Scooped from here:

Normal a.k.a. Permanent a.k.a. Data

create tablespace {TABLESPACE-NAME}
logging
datafile 'C:\path\relative\to\oracle\server.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;

Temporary
create temporary tablespace {TABLESPACE-NAME}
tempfile 'C:\path\relative\to\oracle\server.dbf'
size 32m
autoextend on
next 32m
maxsize 2048m
extent management local;


[Listening to: Disturbed - Stupify]

Monday, May 09, 2005

RSS Bandit 1.3 - Recovering disappearing menus and toolbars

I'm using RSS Bandit 1.3.0.29 (although I've seen this problem in earlier versions of 1.3 as well.) Occasionally all the menus and toolbars just disappear on me. The Feed Subscriptions tab, Search Tab and Feed Details Tab are still there but nothing else.

The bigger problem seems to be the fact that I can't find anywhere to right click to bring up the toolbar customization dialog to make them visible again.

Here's what you need to do to get them back:

Navigate to the AppSettings folder for RSS Bandit (C:\Documents and Settings\dmontgomery\Application Data\RssBandit on my machine) and edit the file .settings.xml

Look for a line like this (note that you're looking for "&lt;Toolbar", not "<Toolbar":

   &lt;Toolbar Guid="c95feca6-b21e-4660-ad20-8e8e5b9fe26c" DockLine="15" DockOffset="2" Visible="False" Container="f7942d78-c06c-44f8-943e-b0f68611be66"&gt;

Change Visible="False" to Visible="True"

Start up RSS Bandit again. This should make the "Main Tools" toolbar visible. Now you can right click to enable the rest.

Occasionally I need to change the DockLine setting too, but I can't remember what the "bad" value was.

I figure it's probably something to do with switching between a dual monitor setup to a single monitor or vice versa, but I'm not sure.

[Listening to: Guns N' Roses - Bad Apples]

Thursday, May 05, 2005

Give your DLL a dedicated config file - level 300

Jeffrey Palermo has some sample code on how to give your DLL a dedicated config file. This is just as useful as a sample of how to throw together an app domain.

[Listening to: Down - Stone the Crow]

Tuesday, May 03, 2005

XML Documentation

Alan Dean is posting a series on using XML Documentation:

  • Part 1: The Overview
  • Part 2: The Detail
  • Part 3: Complex Tables.

  • I've always been a fan of XML Documentation, but the coolest bit for me are the undocumented tags (like <event>) and the undocumented switches in a cref attribute in <see>.

    Nice job Alan.

    [Listening to: Jethro Tull - Broadsword]

    Update: Change title to reflect the series, not just the first article. I've gotten lazy with the "BlogThis" button.

    Monday, May 02, 2005

    ORACLE: Using ROWNUM or SORT with UNION

    [Pulled from dbforums]

    If you want to use ROWNUM or SORT across the results of a UNION:

    SELECT *
    FROM (
        SELECT employee_id, last_name, first_name
        FROM   EMPLOYEES
        UNION
        SELECT department_id, 'DEPT', department_name
        FROM   DEPARTMENTS
    )
    WHERE ROWNUM < 100
    ORDER BY last_name;


    * I realize this is a brutaly contrived example, but hey, whaddaya expect?
    ** I have no idea how this performs.

    ORACLE: Tidbits

    I'm starting to read up on Oracle and figure the beast out. Naturally the first thing I do is to subscribe to the I Hate Oracle Club (IHOC). I'm still trying to figure out a way to order the mug or T-Shirt.

    I figure I'll post whatever little tidbits I come across that I found useful. Mostly so I don't have to remember them myself.

    [Listening to: Static-X - Cold]

    Encrypting app.config configuration sections in Whidbey

    Pulled from That Indigo Book: A nice easy way to encrypt an app.config (or web.config) configuration section. It's the little things.

    [Listening to: Lisa Loeb - Dance with the Angels]

    Catching up

    It's long past time I started making my way through the "To Blog" queue. Here goes nothing...

    Friday, April 01, 2005

    Setting up a Development Environment with Virtual PC / Virtual Server

    Armand du Plessis rebuilds his development environment using Virtual PC/Virtual Server. It sounds useful enough to blog here to trigger my failing memory when I might be tempted to do the same.

    [Listening to: Nickelback - Where do I Hide?]

    Primer to ConnectionStringBuilder in ADO.Net v2.0

    Sushil Chordia puts together on the new ADO.NET 2.0 ConnectionStringBuilder class. Definitely a time saver (and maybe a trial-and-error eliminator.) Primer to ConnectionStringBuilder in ADO.Net v2.0 [Sushil Chordia]

    [Listening to: Rage Against the Machine - Guerilla Radio]

    Wednesday, March 30, 2005

    Keep your Main simple

    Jason Clark, over at Wintellect has a nice post on why you should keep your Main entry point nice and simple. Even better, he gives you a juicy boilerplate to use.

    [Listening to: Oysterhead - Owner of the World]

    Tuesday, March 15, 2005

    Book: Customizing the Microsoft .NET Framework Common Language Runtime

    Just found a reference to a potentially very useful book from Chris Sells here: Customizing the Microsoft .NET Framework Common Language Runtime by Steven Pratscher. This sounds like just the stuff I'd be looking for (at least once I got off my butt and did something.)

    [Listening to: Flybanger - When are you? (Gonna Die)]

    Thursday, February 24, 2005

    Access Control List Editing in .NET

    From the March 2005 issue of MSDN Magazine, Keith Brown gives us a UI to
    Edit Access Control Lists .NET. Boy, just for the sake of displaying ACLs this thing rocks.

    [Listening to: Godsmack - Forgive me]

    XSLTO -- XSLT's in C#

    This is cool enough to break me out of my non-blogging-funk: XSLTO -- XSLT-like processing using C#. That definitely seems neat. Found via Craig Andera.

    [Listening to: Sarah McLachlan - Witness]

    Monday, January 17, 2005

    Throwing, catching, and a little bit of paranoia

    Joe Duffy is paranoid. And by the looks of his blog entry Throwing, catching, and a little bit of paranoia I might be a little more paranoid too, especially around security sensitive code.

    In a nutshell, despite your best intentions a perfectly valid .NET app can get code between an exception in your method and your finally block. Yikes!

    [Listening to: Eminem - Til Hell Freezes Over]

    Accessibility Domains and you

    Jeff Key of SnippetCompiler fame posts a nice overview of Accessibility Domains. I.e. just what code can has access to a given class/method/member given it's accessibility modifiers (private/internal/public).

    [Listening to: Placebo - Black-Eyed]

    Limiting Profiling to particular blocks of code

    Richard Wurdack (a.k.a Angry Richard) gives a quick intro to the profiler api and the Microsoft.VisualStudio.Profiler namespace to help Limit the Data Crunch from Trace Profiling.

    This might help to prevent drowning in trace data.

    [Listening to: Limp Bizkit - Outro]

    Friday, January 14, 2005

    One hand washing the other - Clarke Scott

    You never know when you're going to need a favour, so here goes nothing...

    Clarke Scott is asking for help to market his CRM software application for SME businesses by increasing his Google rating.

    More power to you.

    [Listening to: Natalie Imbruglia - One More Addiction]

    Thursday, January 13, 2005

    Customizing Quickwatch in VS.NET debugger for custom classes

    I know, I know, it's been a while. I could spout off about being too busy or on vacation but basically I'm just too lazy. Anyhow, in the laziness vein, here's a post that I want to keep around in case I'm looking for it later:

    Customizing Quickwatch in VS.NET debugger for custom classes. I remember this sort of feature from VS6 but since I could never remember what the file was...

    [Listening to: Whitesnake - Still of the Night]