Windows Portable Devices

The Windows Portable Devices API is to talking to media devices what DirectX is to gaming. It is an attempt to make a secure, standard method of communicating with devices ranging from Media Players to cameras to temperature sensors…

There are things I like about it and things I really, really don’t like. For an MP3 player manufacturer one big reason to use this API instead of making the device work like a USB drive is DRM.

But, it looks at this point like DRM (Digital Rights Management) for music files is a dying beast. The recording industry seems to be accepting the fact that their customers HATE DRM. There are now several ways to LEGALLY purchase songs in unencumbered MP3 format. Arguably the only people inconvenienced by DRM were the legal users. The pirates never had a problem circumventing the so called protection.

What does this mean to you (and me)? Well, when I work with my son’s Transcend player (which could never play DRM music), it looks just like a USB drive. Easy, peasy. When I work with my Creative Zen or my daughter’s Creative Zen V, I have to use the Windows Portable Devices API.

The lack of a .Net version of the API is a bummer, but not insurmountable. You get to take a fun and exciting trip through the world of ILDASM and ILASM, then you get to read the C++ examples and do a bit of mental gymnastics, but you can get there.

So far I have gotten as far as enumerating the connected devices, getting their friendly names, descriptions and manufacturer info. Next I’ll be diving into how to get the file info and move files around. Not as straightforward as working with the file system, but always remember, “No matter where you go, there you are.”

Here are some links that are helpful with working with the Windows Portable Devices API.

API documentation in MSDN

Windows Portable Device Team Blog

The team put up an example of using the API to talk to a temperature sensor using c#:

Darene Lewis’ Blog

I’m not really sure exactly who Drene is, but I’m guessing Microsoft Employee based on the blog address…

In any event there is much good info here regarding the Windows Portable Device API and how to use it with .Net.


ASP.NET and Godaddy, part 3

Sweet! Got everything working.

As I mentioned in the last post, I dropped back to square one and rebuilt the app one piece at a time to see where the problem was.

I got the login and register pages working first, then went to the data entry page.

Once I built my Linq objects, but before I referenced them, I uploaded everything one more time. I did a diff on the old and new web.config files to see what had changed. There were only two changes: 1) added new connection string and 2) added assembly info for Linq.

A quick check that everything worked well, then I added the code-behind to use the Linq objects to write the data to the database.

Once everything was deployed, I hit the page and… 500 Internal Server Error.

This time I thought about the new App_Code directory where the Linq objects live. Since I did a website instead of a webapp, everything has to compile on the fly when it runs the first time… hmm. Think maybe that directory needs write permissions?

Added write permissions and, hey presto! Now the Linq data entry page works!

It was literally five more minutes to get the data view page working using a Grid View that uses a Linq object as its source.

One thing I did differently this time was change the name of the Linq datasource to something other than the default.

Now I move on to making things pretty. I’ll also write up a more detailed set of instructions and post them.


GoDaddy and ASP.NET apps

OK, so I’m finally working on some projects.

For several years now I’ve been working primarily on backend systems that do important work with NO visible interface… When we talk about our apps and people ask which part I did, I have to grimace and say, “The parts you can’t see…” Without my part nothing would work, but people are only impressed by what they can SEE.

Any way, I’m working my way through the ASP.NET user management controls and made a simple app for tracking your health stats. I used Linq for the database access, and it seems pretty cool. I’ll write in another post about what I think so far about Linq.

Got everything working well locally and uploaded it to No go. I got the database populated with the roles, etc. But so far all I get is a big ole 500 Internal Server Error. Since I’m working in a hosted environment, I can’t a huge amount of info about what’s happening.

I’m going to blog my efforts here and when I’m finished I’ll write up a detailed set of directions.

For now I’m going back to step one and create a page with nothing but a login.

Film at 11.


ASP.NET and Godaddy, part 2

Well that worked.

I dropped back to a blank sheet and worked my way up one step at a time. Only way to eliminate variables that could be causing problems.

Here are the step by step directions to get to a bare page with functional login and registration pages:

  1. Create local SQL Server database (Express will do)

  2. Dig through C:WINDOWSMicrosoft.NETFrameworkv2.0.50727 and run aspnet_regsql.exe. This will create all the aspnet tables, views, and stored procedures.

  3. Fire up Visual Studio 2008 and create a web site.

  4. Go to menubar: Website: ASP.NET Configuration. This will start a local web server and spawn a web page in the browser.

  5. Modify web.config and put the connection string for the database you created in the connectionStrings section for the name “LocalSqlServer”.

  6. Close the web project and then reopen it. I didn’t verify that this is a required step, but I did it anyway…

  7. Re-launch the ASP.Net Configuation like you did in step 4.

  8. Enable Roles management.

  9. Create a few roles. I made admin and user.

  10. Create a user.

  11. Go back to Visual Studio and add your database under the Server Explorer tab.

  12. Check the aspnet_Users table to be sure your user showed up.

  13. Right click on the database and pick Publish To Provider.

  14. Only export the table data.
    Now we get to the GoDaddy portion of the operation. These steps will require some patience since you have to wait for them complete each step.

  15. Log in to your account and create a SQL Server 2005 database.

  16. Make sure you select to Create ASP Schema for the database.

  17. Log in to your new database.

  18. Use Query Analyzer to run the file you created back in step 13: Publish To Provider. This will ERASE any existing table data, so use caution on your SECOND AND SUBSEQUENT webapp! For those you will want to only append data, not delete first. You have been warned!

  19. Use Godaddy’s File Manager to create a new directory and upload your app to it.

  20. Using their File Manager’s Edit utility, modify your web.config so that the connection string points to the database you created there, not your local database.

  21. Use their IIS Settings tool to create a new virtual directory/app. Be sure to select Set Application Root.

  22. You should now be able to hit your page.
    That was the hard part. Now for the easier stuff.
    I’m not going to include these in the step by step instructions, just summarize them.

  23. Create a Register.aspx page.

  24. Add a CreateUserWizard from the Login section of the tool box.

  25. In properties, set the ContinueDestinationPageURL to the “~/Default.aspx”.

  26. Add a LoginView control to the Default.aspx page. In the Logged In Template, write something like “You are logged in”.

  27. In the Anonymous Template add a Login control.

  28. Set the Login control’s DestinationURL to “~/Default.aspx” .

  29. Set the Login control’s CreateUserURL to “~/Register.aspx” or whatever you named that page.

  30. Test things locally to make sure they work.

  31. Upload to Godaddy everything.

  32. Make sure you change the connection string in the web.config file like you did in step 20.

At this point it works for me. I can add users and log in.

The key here is to step back, simplify what you are trying to do and build up one step at a time.

In Agile programming you try to break things into chunks that can be delivered early. In this case I tried to do too much with my first attempt. It didn’t seem like much until something broke. Now that I have gone back and started much smaller, I have a working system that can register and authenticate users instead of a bigger system that can’t do anything…

More details later.