Welcome to Strong Coders Community Sign in | Join | Help

Friday, November 10, 2006 11:35 PM

ASP.NET Moderator

I was recently asked to join the ASP.NET forums moderation team. I accepted - of course - and am looking forward to helping the community.
Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 1 Comments
Tuesday, November 07, 2006 11:19 PM

Windows Media Player 11 RTM

About a week ago (as of November 7 th ) Windows Media Player 11 was finally released. I was excited about it because I couldn't use the Betas, they weren't designed for x64. So when RTM was announced, so was the x64 edition. Sweet. I had seen my roommate's laptop had it installed, and I could have installed it on my laptop, but my laptop is in Russian and I wanted to wait for the MUI editions to come out. So downloaded, installed. Installation went without a hitch. It migrated my library, all seemed to go well. I am dissappointed that even though there is a special x64 download for WMP 11, the large portion of it is still 32-bit running on WOW64. A couple of personal opinions on WMP 11.

Dislikes: I like the Classic Windows Shell. Windows 2000. Windows Media Player 11 has the Vista look, whether you want it or not. I prefer the old fashion way. I'm an ol' fashion person. I don't like that it is always black. Yeah you can change the tint of it - slightly. Oh well. Nothing that effects the performance of it. The UI doesn't respond as quickly as I would like it to if I ask it to do something intensive. I also wish it were pure x64.

Good stuff: I had issues where MP 10 wouldn't recognize my CD burner (though Windows Explorer would). Now it does. Excellent. It also supports Ripping CDs in the Professional Codec.

It also rolled out a new version of the Windows Media Codec: 9.2 and Windows Media Professional 10.

Overall I like it.

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Monday, November 06, 2006 1:03 AM

Delta Airlines Suck

I am an avid flier. I fly all over the world, Belarus and Russia mostly. Those a pretty far away (about 6,500 miles for Belarus) so I rack up Frequent Flier Miles pretty quick. Well I decided to attend Dev Con with Ryan, so I got some airline tickets to Vegas using my FF miles.

So I go to the ticket counter after spending 30 minutes trying to find a parking spot in Long Term Parking. No tickets. No Tickets? no tickets. OK, I so I am delayed a day. I was getting there early, no problem, I will get there on time instead. My Frequent Flier miles are gone, but, no tickets. Time to head home. (Oh and pay my way out of the long term parking that I was in for 15 minutes. Angry

Time to make some calls. I give them my transaction ID, all that jazz, they said:

OK. Since you are using Frequent Flier Miles, it will take a day to process.

Translation : We don't value our top customers and we don't want to give free airplane tickets.

Why did this happen? They sold my seat to a paying customer, even though I have previously spent thousands of dollars flying with them.

So I got my Frequent Flier Miles back. Oh, but I can't get tickets now. They are booked. And I am not in the mood to fork out money for tickets that I deserve as a valued customer.

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Saturday, November 04, 2006 3:49 AM

Microsoft Drops the ball with OneCare and x64

I was surprised when the press release for OneCare came out. Microsoft making an Anti virus Suite? Sounds interesting. And something I would probably be interested in. Microsoft made Windows, so why shouldn't the maker of Windows make good programs for Windows? When RTM was released, I downloaded a trial. But guess what. It wouldn't install. Windows Live OneCare is not x64 compatible.

Ouch.

Microsoft has been trying to push the x64 platform on developers and the program industry, and now they release a software suite that is not x64 compatible? What about when Vista is released? The Windows Vista logo program requires that software be x64 compatible for it to get the "designed to run on Windows Vista" logo on the box. Is Microsoft going to make a software suite that will fail it's own logo program?

I got an e-mail asking if I wanted to participate in the OneCare v1.5 Beta. I checked it out, thinking. "OK, they know the release of Vista is close. It has to be x64 compatible."

Nope. So far, the beta for 1.5 is not x64 compatible. Seems ironic to me.

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 1 Comments
Filed under:
Tuesday, October 31, 2006 4:11 PM

MVP Nomination

I recently found out I am nominated for MVP. I consider just the nomination itself an honor. Thank you Ryan for the support.
Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 3 Comments
Sunday, October 29, 2006 3:48 PM

A Persistent Application State

We all know that an application state lasts while the application is running, but if the AppDomain gets restarted, from something like a change in the web.config file or a recompile. What if we want an Application State that always persists? One that is never lost, even if the entire server is restarted? Well I set off to do exactly that, and here is what I got.

The first thing I had to do when deciding how this would work is how I would store the values for this state. Logically a SQL Server came to mind, so I had to build an underlying way of communicating with a SQL Server, and an HttpModule seemed like the best way to accomplish this. So I was going to use SQL Server for holding my values. The next task is how to store everything in the SQL Server. I came up with 3 fields. The first being the key, the second being the application name (that way if you have two applications using the same key names, they won't conflict) and the 3rd being the value. I decided to go with Binary Serialization for storing values, to the value field is VARBINARY(MAX). This way we can store anything in our Persistent Application State so long as the object is serializable. To keep performance up, it doesn't read and write from the SQL Server exclusively. It caches everything for reading, so when you get a value it is getting it from an underlying dictionary, and during an update it updates the cache and the SQL Server values. The only time a read is done on the SQL Server is when the Init() method is called on the HttpModule. A SQL Script for creating the table is included in the project.

Since we are using an HttpModule, the module must be correctly registered in the web.config file, which would look something like this:

                    
                  

The next thing I had to accomplish was making this thing configurable. The web.config file seemed like the best way to do this, so I made a quick ConfigurationSection class to handle the configuration. The configuration has 2 basic attributes. applicationName and connectionStringName . applicationName should be a string that uniquely identifies the application. The connectionStringName is the name of the connection string that should be used to connect to the SQL Server that is in the section. An example of the web.config is included in the project.

The last thing I had to deal with is how to make this accessable from the Page. To solve this, I created a BasePage that exposes a Dictionary that works exactly like the Application, and hooks into the Module. To use it, derrive all of your pages from the class KGJ.PersistentApplicationState.BasePage and set the web.config file to use that as the base as well. This will expose the Dictionary PersistentApplication. From there on, use it like the Application State, except they will always be there until you delete them. How to use it: Simply put the compiled DLL in your BIN folder.

As far as other Databases, this code is easily adoptable to an Oracle or MySql client. Eventually I will adopt it so that it works like a provider.

Download the source code and projects here: Persistent Application State

Feel free to leave comments and suggestions, there is always room for improvement.

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Filed under:
Wednesday, October 25, 2006 4:55 PM

AJAX Beta 1

It appears that Microsoft has dropped the ball with Beta 1 of AJAX, more over it is riddled with bugs and quirks. Here are some known issues and some work arounds for Beta 1

Web Service Calls Issue
http://forums.asp.net/thread/1441680.aspx

Extenders in Templated Controls Issue
http://forums.asp.net/thread/1441672.aspx

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Filed under:
Thursday, October 19, 2006 10:35 AM

Announcing: IE 7 RTM!

It's finally here. IE7 RTM has finally hit the spot. Download it here:

http://www.microsoft.com/windows/ie/downloads/default.mspx

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Filed under:

A Fun Windows Form Application

Ever play around with the Text-To-Speech in Windows XP? I thought that was fun when XP first came out and I always made it say crazy stuff, especially during computer lab. Later as a developer I wanted to implement this into a Windows Application I was making, just for fun.

The Speech API (SAPI) is a COM library, and it is no secret to .NET Developers that .NET has excellent support for COM libraries. The sapi.dll can usually be found in C:\Program Files\Common Files\Microsoft Shared\Speech. Using the .NET SDK, we can easily make a managed assembly for this using the Type Library Import, tlbimp.exe. You can run it from the SDK Command prompt in the start menu. Using the command prompt we can generate the Managed Version of it, what I called sapi.net.dll using this in the .NET SDK Command Prompt:

C:\Program Files\Microsoft.NET\SDK\v2.0 64bit>tlbimp "C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll" /out:C:\sapi.net.dll

The Type Library Mashaler won't be able to completely marshal it for you, but it will be able to do enough of it for us to get what we want. (Note that in my example I used the 64-bit platform, so your SDK path won't be the same). This will generate the Assembly we need for making a taking application.

So now we can use this assembly in a Windows Form Project, and all we have to do is add a reference for it.

The primary interface and class we will be using is SpVoice and SpVoiceClass, which were made by our type library importer. SpVoiceClass is what we will use to make our application talk. The method "Speak" accepts two arguements, the text to be spoken (as a string) and flags (as an int enumeration). Type Library Importer automatically generated a flag enumeration called SpeechVoiceSpeakFlags. The two I use in this application is SVSFIsNotXML and SVSFlagsAsync. SVSFlagsAsync is important so your thread won't lockup when you start speaking. Optionally, you can use your own worker thread, which is recommended since we don't want to be talking on the UI thread:

private SpVoiceClass voice = new SpVoiceClass ();

SpVoiceClass voice = new SpVoiceClass ();

ThreadPool . QueueUserWorkItem(( delegate ( object arg)
{
voice . Speak( "Hello!" , SpeechVoiceSpeakFlags . SVSFIsNotXML | SpeechVoiceSpeakFlags . SVSFlagsAsync);
}),
null );

this.voice is an instance of the SpVoiceClass class.

Assuming one has Office installed, you have extra voices. I got bored of Microsoft Sam so I wanted to use others voices, for which I created a helper method like this:

static List < DictionaryEntry > AvailableVoices
{
get
{
SpVoiceClass voice = new SpVoiceClass ();
List < DictionaryEntry > voices = new List < DictionaryEntry > ();
for ( int i = 0 ; i < voice . GetVoices( null , null ) . Count; i ++ )
voices
. Add( new System . Collections . DictionaryEntry (voice . GetVoices( null , null ) . Item(i) . GetDescription(System . Globalization . CultureInfo . CurrentCulture . LCID), voice . GetVoices( null , null ) . Item(i)));
return voices;
}
}

The reasoning for using a List filled with DictionaryEntry's is for databinding purposes, since the binding must implement the interface IList. This returns a List of DictionaryEntries, the dictionary key being the voices name, the value being the actual voice itself, which is the interface ISpObjectToken. So now we have a list of the voices installed on the machine.

The SpVoiceClass has a method called SetVoice which accepts an ISpObjectToken for setting the voice.

The SpVoice class can also allow you to save a WAV recording of the voice, just by changing around the output stream. I used a BackgroundWorker class to help me with this so I can do it on another thread.

The stream we will be using for this is SpFileStreamClass, which must exist on the same thread as the SpVoice class, so we need to pass it as an arguement in the RunWorkAsync method.

You can download the full sourcecode and run it for yourself here: Speech

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 1 Comments
Filed under: , ,
Wednesday, September 27, 2006 9:11 PM

Helpers Project

I have decided to make a library of static methods for making coding easier. It is still beta, but I want feedback on features they want added. Here are some of the features that i have in there already:

  • Static Library for working with Arrays. Merging Arrays, Intersecting Arrays, Unioning Arrays, etc.
  • A library of basic Plateform Invoke signatures (not all have been tested).
  • Functions for resizing an image and creating thumbnails (as seen on the ASP.NET Forums)
  • Conversion Helpers, such as converting a Color to an Int32 and IPAddress to a Int64.
  • Mathematical Functions.
  • Serialization Helpers, including fully automated serializing to/from a file, and generics in serialization.

The full project (open source) can get found here: http://blogs.strongcoders.com/files/folders/kevins_code_samples/default.aspx

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Filed under:
Friday, September 15, 2006 9:54 AM

Vista goes RC

On the 15th, Windows Vista Release Candidate 1 was announced. I am looking forward to playing around with it.

Get it here:

http://go.microsoft.com/?linkid=5467423

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Filed under:
Saturday, September 09, 2006 2:26 PM

The Power of the Event Viewer

Often I answer questions like, "Why is my AppDomain restarting?" or "Why am I losing Session States?". Often gone unoticed, there is a very likely place the problem will be specified. The Event Viewer comes to the rescue. In ASP.NET 2.0 it does a considerable amount of logging of errors in there, including AppDomain restarts, possible reasons for Session values being lost, failure to load an assembly, etc.

And, not surprisingly, IIS writes into the log as well, making the Event Viewer an invaluable tool when diagnosing problems with your Server.

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Filed under: ,
Wednesday, September 06, 2006 7:29 AM

Deleting Files in x64 Operating Systems the right way

I first discovered this flaw in the x64 operating systems in Visual Studio. I noticed it wasn't deleting files when I told it to. Those of you that know me might know that I don't use a recycle bin. I have the global recycler set to permanently delete files. When I delete something, I am usually sure of it. If I want to recover it, I pull it out of a tape backup, which I have yet to do.

So let's say I open a 32-bit program, like Visual Studio or Abobe Fireworks. I open the "Open" dialog. I right click a file in there and select delete. It asks me if I want to send it to the recycle bin. That annoyed me. Because I removed the Recycle Bin from my desktop, so I had to regularly check the C:\RECYCLER folder for files that were suppose to be deleted. This may not seem critical, but in Visual Studio it was a problem. Say I open an FTP project, and work with some pages. You will see that VS retrieves the files and caches them locally for working with. Now I close Visual Studio, satisfied that I am done. All of those temp files ended up in my recycle bin.

Now, why does it do that and how can I fix it?

Well those that use the x64 OS know the registry in there is a little different. It works like the System32 and the SYSWOW64 folder. There is a registry key meant just for 32-bit Applications in HKLM\SOFTWARE\Wow6432Node. The operating system's settings fall in the HKLM/SOFTWARE key, so there are two places the recycle bin's settings are stored now. By default, the recycler's settings are stored here:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\BitBucket

and the entry that controls weather a file is permanently deleted or not is a DWORD called NukeOnDelete. When you change the setting in the recycle, it doesn't change it in the SysWow6432Node. However, 32-bit programs like Visual Studio and Fireworks do read from the SysWow6432Node. So the recycler settings are out-of-sync. So if I were to set the entry:

HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\BitBucket@NukeOnDelete="1"

Then the 32-bit programs behave correctly.

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted by Kevin Jones | 0 Comments
Filed under: