Archive

Posts Tagged ‘Code’

From Express to Pro

June 15th, 2006 Rev No comments

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#.

Tags:

Synchronized RichTextBox Scrolling!

April 17th, 2006 Rev No comments

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!

Tags:

Hello

April 15th, 2006 Rev 1 comment

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

Tags:

CPU load percentage in C# and .Net

January 27th, 2006 Rev 2 comments

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){...}
Tags:

Open Source .Net Development

December 7th, 2005 Rev No comments

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.

Tags: ,

Interesting demonstration of new .Net 2.0 features

November 15th, 2005 Rev No comments

I saw Heroic Adventure on Jason Olson’s site – I knew there was a reason I kept that link. Looks like he’s blogging again.

This is a rogue like game that shows off the curses like functionality in the new framework. He mentions that with the release of Mono 1.2 it should play across platforms as well. Cool.

I would say we can now port handy linux apps to window’s console. But then again.. you can’t shell in and I wouldn’t want to add any value to windows.

Tags:

Putting SQLExpress into mixed-mode

November 12th, 2005 Rev No comments

UPDATE: I’m not so sure about these instructions. I’m having a hell of a time with SQLExpress now. But then again.

Found these steps on this site:

NOTE: You can enable mixed – mode authentication in the Registry by changing the LoginMode value from 1 to “2″, here:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer

LoginMode =2

Of course, since you still don’t know the strongly named “sa” password from when it was installed, you can still add a new user in SQLCMD and make them a sysadmin with:

SQLCMD -S.\SQLEXPRESS -E

sp_addLogin ‘username’, ‘pass’
GO
sp_addsrvrolemember ‘username’, ’sysadmin’
GO

Don’t forget to give yourself a gold star for remembering to stop and restart the SQLEXPRESS service to get that registry change to take.

Tags: ,

NUnit 2.2 & .Net 2.0

November 12th, 2005 Rev No comments

If you want to use NUnit 2.2 with projects written in the newly release .Net 2.0 include the following tag in the nunit-gui.exe.config and nunit-console.exe.config under configuration/startup

supportedruntime version=”v2.0.50727″

You are writing Unit Tests, aren’t you?

Tags: ,

Follow up to VStudio Sticker Shock

October 1st, 2005 Rev No comments

I saw Zac’s latest entry at Monologue and I had to post the picture. Obviously I’m not the only one a little overwhelmed by the pricing:

So funny!

Tags: ,

More Click Once Info

September 21st, 2005 Rev No comments

So, looks like I can get the Click Once stuff hosted on a Linux/Apache server. But Firefox doesn’t like to run it properly.. I think partly it has to do with where Firefox is caching it’s files. We’ll see if I can find a work around.

I found a more detailed site on Click Once – Well it was the link at the bottom of the autogenerated page. A FAQ and more information can be found here.

More later.

Update from the site:

“Using “ClickOnce” requires that the target client already have the .NET Framework 2.0 installed. Visual Studio has made packaging and deploying the .NET Framework simpler than ever. Simply select what pre-requisites your application may have (ex. the .NET Framework 2.0 & MDAC 9.0) and Visual Studio will generate a bootstrapper file that will automatically install all of the specified pre- requisites when run. On the server side, “ClickOnce” needs only an HTTP 1.1 server or alternatively a file server.”

Tags: ,