Friday, March 30, 2007

Move Windows system disk to New PC Home

Here is a trick I picked up in my amateur computer repairing (Every geek needs one of those "No, I will not fix you computer!" shirts, no?).

You have PC A running windows XP/Pro/(Vista?) and you want to keep all your Windows settings, program installs, etc. and use them on your new, shiny PC B. Maybe you have even assembled PC B yourself and didn't order a new hard drive in anticipation of using your old system disk. Well, chances are that if you just rip your hard drive out of PC A and stick it in PC B, Windows won't boot. You'll get a blue screen of death STOP ERROR or maybe it'll get to the splash screen but then freeze up. Certain drivers for your motherboard and chipset are sort of "embedded" in your windows install so deeply that it can't adjust for the new hardware of PC B.

The Solution? Grab your Windows install disk and boot from that. When prompted, select "Install windows" or whatever, and accept the EULA. Eventually, the installer should say that it is scanning your system for previously installed versions of Windows. It should detect your working windows XP installation and ask you if you would like to repair this installation. Hit 'R' or whatever it says will repair the installation. Thirty minutes or so later, you should be up and running your old installation on your new PC. Certain things might need some fixing afterward (for instance, depending on your instal CD version, you might need to install service packs and hot fixes again) but it may save a lot of time compared to starting from scatch.

I know Microsoft has some kind of "Transfer Files and Settings" application that is supposed to do something like this, but I doubt it works so smoothly, and it requires multiple hard drives (one for the new install, one to keep the old install).

Thursday, March 15, 2007

Authoring your own XP Embedded Components with Files

From the very beginning of working with XP Embedded, one of my goals was to be able to make our custom client application the "shell" for our run-time image, like this. Also, I thought it would be cool to import the .inf files from the mainboard drivers we needed to install -- the Network Adapter and the Video Adapter drivers. I had seen Mike Hall or someone at Microsoft do this by launching the File -> Import... command from Component Designer. Well, I ran through all the steps for these processes, and imported the components into the Database ( Tools -> Component Database Manager -> Click "Import .SLD" ), but when I added my new custom components I got error messages about not being able to find all of the Files associated with the component - one error message for each file.

After some experimentation, and perusing a few forums, I determined that I needed to make my own Repository for the Components I was making, and then set the Repository in the Component Details page (it is "Unknown Repository" by default). You can find detailed information on how to do this here.

I did something slight different though in order to have a single repository for all of my custom components, and have that repository listed in the Component Database Manager, as well as in the "C:\Windows Embedded Data\Repositories" directory.
  1. Create a new .sld in Component designer
  2. Right click the Repository tree node and click Add Repository
  3. Name your repository something appropriate (e.g. "MyRepo" or "ZipCo Custom Components") and set the source to a (pre-created) directory of your choice. The directory should have a text file or something in it marking it as your repository, since it will be given a long, hard to remember GUID for a directory name after step 4.
  4. Save the .sld and import it into your Component Database. Note: In the import .sld dialog make sure you have the "Copy Repository to root" checkbox checked.
Now you have your own repository in the database, and in the repositories root directory (probably "C:\Windows Embedded Data\Repositories"). Whenever you make a Custom Component of your own that has one or more files, set the Repository in the Component Details page to your custom repository (it should be listed along with the main XPe repos) and copy all of the files you use into the repositories physical folder.

PS - If you see error messages importing your .inf driver file, read this before you assume something went terribly wrong. :-)

Monday, March 12, 2007

ASP.NET Forms Authentication strange behaviors

After I got ASP.NET Forms Authentication up and running on the web application I'm developing, I started having a few problems -- it took me awhile to figure out that they were caused by having Forms Authentication enabled.

The first issue I had was that the site would redirect to login.aspx like it was supposed to, but the login.aspx page would be missing all of the style information from our CSS style sheet. I looked in the Firefox error console (Firefox Web Developer Extension ) and noticed an entry about the site being unable to grab the style sheet because it was the wrong MIME type: it was text/html, when it expected CSS files to be text/css. After banging my head against the MIME type error message for awhile, I had the idea that maybe the type was text/html because it was getting a 404 response when asking for the style sheet. Sure enough, it wasn't too long then before I figured out that Forms Authentication and my Web.config settings were preventing unauthorized users from grabbing my style sheet. Solution - made a second Web.config and placed it in my App_Themes directory where my style sheet lives.

<system.web>
<authorization>
<allow users="*">
</allow>
</authorization>
</system.web>

The solution to my next problem was now pretty obvious. Any javascript file I embedded in my login.aspx page would return a syntax error on line 2 or line 3. It even did this if the .js file was completely empty! I quickly realized it was the same problem, just a very different symptom. Soulution - place another Web.config in your "scripts" directory, or make a "public_scripts" directory if you need to protect some scripts from unauthorized users and place your Web.config there.

Friday, March 02, 2007

XP Embedded Tricks

I recently posted on the microsoft.public.windowsxp.embedded newsgroup a couple of questions I had about XP Embedded related to work. The short version of the questions:

1. Is there a way to determine which service inside a svchost.exe process is causing the problem when presented with a "svchost.exe - Applicaton Error" ?

2. Is there a way in XPe to suppress displaying error messages?

The short answers (thanks to KM in the same newsgroup!):

1. Sysinternals (now Wininternals) Process Explorer can give you just such info. It's like Task Manager on steroids! (I had used it before, but didn't put two and two together :-)
http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.mspx

2. Yes! A simple registry change can suppress many error from being presented to the user on XP embedded.
http://msdn2.microsoft.com/en-us/embedded/aa731206.aspx

Disqus for A Nofsinger's Blog