Rev’s Thought Dump

Took me a few minutes to figure out why some of my functions weren’t firing in the afterFinish callback function from an Effect. Apparently you can’t access global variables in an Effect callback. I haven’t dug too deeply into this but I sort of assumed it would work since I can access globals on an ajax callback.

Just a heads up if you’re banging your head against a wall.

  • 1 Comment
  • Tags:
  • Javascript trim

    This is your friend when you need to trim whitespace in javascript:

    replace(/^\s*|\s*$/g,”)

    Ran into a ticket here at work that had a few people stumped. We were trying to export a report as an Excel file so the user could down load it. This error popped up and long story short I got a ticket to check it out.

    I found the answer on ClearGlass.net. Here’s a quick summary of the solution:

    Solution:

    If you get the above error when you click on an attachment, the attachment is larger than IIS is configured to allow. Change the AspBufferingLimit setting in Metabase.xml to a larger size. The default value is 4194304, which is about 4 MB. Change this to whatever limit is reasonable for the types of files your users will be attaching.

    This change does not require stopping IIS, but to make the Metabase.xml file write-able, you need to go to the IIS control panel, right click the server, select properties, and check off the box that says “allow changes to MetaBase configuration while IIS is running”.

    If you’re setting up your wix install as part of an automated build, with NaNT, here’s a quick way to set the MSI Product Version attribute. In my case I’m having CruiseControl.Net run my builds and so I use this bit of NaNT XML to make sure that the MSI version is the same as the CCNET build version.

    <if test="${property::exists('CCNetLabel')}">
    <xmlpoke file="${build.rootFolder}\Product.wxs" value="${CCNetLabel}" xpath="/wix:Wix/wix:Product/@Version" verbose="true">
    <namespaces>
    <namespace prefix="wix" uri="http://schemas.microsoft.com/wix/2003/01/wi"/>
    </namespaces>
    </xmlpoke>

    Researching the idea I wrote about in the last post about having ClickOnce make sure the System Admin Tool and the Installer are up-to-date - a sort of prepatch - I came across the article “Choosing Between ClickOnce and Windows Installer” where in Michael Sanford suggests using both.

    I can see how it might be handy to have your install package just lay down a link to the ClickOnce app but I can see how you’ll have more to worry about. What if the “application” includes assemblies that need to be GAC’d or (in the case of my MMC 3.0 assembly) needs to have InstallUtil run against it. Or if it’s a service that needs to be registered.

    The other thing I’m concerned about is this post which seems to indicate that we’ll have spring for an Authenticode cert. We already have a VeriSign cert. This is an old blog post so I’ll need to sift through the docs for resolutions or solid facts.

    *UPDATE*: Reading this article (which talks about signing your application manifest), mentions that you can use “…a ‘real’ publisher certificate (that is, a Verisign one, or one that your development organization uses signed by some other trusted root authority)…” So it appears Verisign is going to work. One problem down.

    I think the article does show that ClickOnce is more of tool in the Release Engineers tool box rather than an entire single path solution. And the way I plan to use it will be just to make sure the install media is up-to-date before being run.

    More later

    From Express to Pro

    I’m switching from C# Express to VStudio 2k5 Pro at work. Express has really been great and is certainly really hot when I think back to a time when the cost of “ok” IDEs was completely insane and basically edged out the hobbyist.

    But, my app at work is an MMC Snap-in that is basically a group of .dlls and one of the things missing in Express is the ability to attach to running process to debug. So that leaves me kind of in a lurch as far as a quick debug on an issue goes. I’m sure this would be an even bigger issue if I didn’t write excellent code to begin with. =)

    And we’re also looking at the ClickOnce technology and setting up users so they can keep our application’s custom data updated on their remote server machines. It’s too complex to go into and I probably can’t really talk about it. But suffice it to say it does make sense to use ClickOnce as opposed to SMS or Active Directory.

    So I’m installing VStudio 2k5 Pro… and installing.. and installing.. and installing. Guess it doesn’t help to be installing over the network… on to an image on a VMWare machine. But… *shrug*.

    I’ve realized that my normally terrible handwriting combined with the overall mess of my desk area makes it difficult to jot down notes on bugs I find or things I want to look at a bit later. So Justin got me the link to Stickies a note taking app that basically duplicates the sticky note widget you get in OSX.

    As Justin pointed out it’s Open Source, .Net, and written in C#.

    Finally found a good way to synch the scrolling between to RichTextBoxes for the Diff File dialog I’m working on at work.

    I found the code pasted as a comment to a VB style scrolling RTB article. This guy was credited with having posted the code in the forums elsewhere. Giving credit where it’s due.

    Here’s the .cs file with said example code. Have fun!

    Hello

    Ported my system management software at work over to .Net 2.0 and MMC 3.0 (Microsoft Management Console). I’m using VC# Express until the licensing comes down for VStudio Pro 2k5. Bascially we have to renew our MSDN licenses and there’s some haggling going on as to whether developers actually need tools. *shrug*

    While .Net 2.0 is well documented and the new VStudio is a dream to work with - read: Ultra Mega Coding Crutch - MMC 3.0 has all but nothing for example code and Google search results. All of the documentation in MSDN is “pre-release documentation” and I managed to download some sdk sample code from some place in Indonesia. Apparently the official MMC 3.0 SDK isn’t out yet - or at least it’s in the Vista Platform SDK and is a total pain in the ass to find.

    But I’ve got my tool ported over and eliminated 1 third party assembly outright. I’ll soon be able to nuke my poorly written progress dialogs and wizards as MMC 3.0 has these as part of the class library. Handy.

    So far a few things to note about MMC 3.0:

    It was released for downloads on March 13th 2006 and you can download it for XP, 2k3, and eventually Vista. (and XP 64 and 2k3 64).

    MMC 3.0 let’s you write managed MMC snapins. If you don’t know what they are.. Ummm run MMC in the run bar and check it out. Enterprise Manager for SQL is an MMC snapin. There are a number of others that I fail to remember at the moment.

    “Pre-release” documentation can be found here.

    Now.. you’re off to start coding.. right?

    Well, the first thing that’s going to frustrate you is that you won’t be able to find the Microsoft.ManagementConsole namespace in the GAC. You’ll find it here \system32\microsoft.managementconsole.dll. Reference it and set it to copy locally since it’s not gac’d.

    I’ve yet to see the console display anywhere or in any fashion the messages I pump to Status and AsyncStatus when I’m doing lengthy work on a background thread. Even compiling the SDK sample I had and running it doesn’t show anything. *shrug* So I opted to use the microsoft.managementconsole.advanced.waitdialog This seems to work just fine.

    When using the WaitDlg… if you call UpdateProgress and set both work complete and total work to 0.. i.e.; mywaitdlg.UpdateProgress(0,0,”Doing Something”); You’ll get a bouncing progress bar. So if you’re totally lost about how many steps what you’re doing is going to take.. you can always at least keep something moving on screen.

    Anywho.. I’m in the middle of testing.. so I’ll leave you with this and get back to it.

    Rev

  • 1 Comment
  • Tags:
  • Wrestled with this for a while.. here’s how I got it.

            using System.Management;
    
            ManagementScope mgmtScope;
    
    	if(MachineName != Environment.MachineName)
    	{
    		ConnectionOptions options = new ConnectionOptions();
    		options.Username = AdminUser;
    		options.Password = AdminPass;
    
    		mgmtScope = new ManagementScope(@"\\" + MachineName + @"\root\cimv2",options);
    	}
    	else
    	{
    		mgmtScope = new ManagementScope(@"\\.\root\cimv2");
    	}
    
    	try
    	{
    		mgmtScope.Connect();
    	}
    	catch(Exception ex){...}
    
    	ManagementPath mp = new ManagementPath("Win32_Processor");
    
    	try
    	{
    		ManagementClass mc = new ManagementClass(mgmtScope, mp, null);
    		ManagementObjectCollection procs = mc.GetInstances();
    		foreach(ManagementObject mo in procs)
    		{
    			string DeviceID = "";
    			string Usage = "";
    			foreach(PropertyData pd in mo.Properties)
    			{
    				if(pd.Name == "DeviceID")
    					DeviceID = pd.Value.ToString();
    
    				if(pd.Name == "LoadPercentage")
    					Usage = pd.Value.ToString();
    
    			}
    			Perf_Processors.Add(DeviceID, Usage);//A Hashtable I'm using to store the info
    		}
    	}
    	catch(Exception ex){...}
    

    Open Source .Net Development

    I just picked up Open Source .Net Development today and I’m going to settle down and start reading it as soon as I’m done with this post. So far it looks like it covers most of the tools I have or want to put into use at work. Doesn’t cover WiX or SubVersion.

    I’ll write more with details tomorrow.

    Archives