In my previous post, I was sort of happy to see an update for WebProfile for use in VS08. The thing is, I really dislike the error you get in the build with this approach, I just can't use that in a production environment. So... I did some more digging and came across this solution by Jon Galloway. You should read his article for a full explanation of what is going on.
His samples are in C# which is great, but there are some caveats to doing it in VB.
Here is the same code in VB:
Public Class UserProfile
Inherits ProfileBase
Public Shared Function GetUserProfile(ByVal username As String) As UserProfile
Return CType(Create(username), ProfileBase)
End Function
Public Shared Function GetUserProfile() As UserProfile
Return CType(Create(Membership.GetUser().UserName), ProfileBase)
End Function
<SettingsAllowAnonymous(False)> _
Public Property Description() As String
Get
Return TryCast(MyBase.GetPropertyValue("Description"), String)
End Get
Set(ByVal value As String)
MyBase.SetPropertyValue("Description", value)
End Set
End Property
<SettingsAllowAnonymous(False)> _
Public Property Location() As String
Get
Return TryCast(MyBase.GetPropertyValue("Location"), String)
End Get
Set(ByVal value As String)
MyBase.SetPropertyValue("Location", value)
End Set
End Property
<SettingsAllowAnonymous(False)> _
Public Property FavoriteMovie() As Integer
Get
Return CInt(MyBase.GetPropertyValue("FavoriteMovie"))
End Get
Set(ByVal value As Integer)
MyBase.SetPropertyValue("FavoriteMovie", value)
End Set
End Property
End Class
When using this approach in VB, I still get some occasional errors in the designer when using SplitView, a recompile makes these go away and the code does indeed run fine. It seems to be something in the background compiler... I wish Microsoft would fix this silly 4 year old bug.
Anyway, I really like this approach MUCH better than placing the profile data in web.config. If you are relying on the code and some genius decides to add a field or change the name it will cause any dependent code to go haywire anyway when the CodeSpit is regenerated.
When I am controlling the Fields in Code (where it should be anyway...) That is not a major concern since we know what we are doing when the code changes and its not in an editable file by someone not actually Testing the code.
Therefore, all the other methods have many problems that just aren't worth dealing with when this is simple, elegant, effective and safe.
I also find it much easier to just use an instance rather than some other suggestions of using a Property in a BasePage.
i.e
Dim prof = UserProfile.GetUserProfile()
or
Dim prof = UserProfile.GetUserProfile(username)
I also found that turning off Automatic updates seems to help with the errors for some reason, with it turned off, I don't seem to get them any more and thus you need to do your saves with an instance or you will have to perform a save after changing any item since getuserprofile will overwrite any unwritten changes to the object because it is creating a new instance every time.
So my resulting web.config looks like this:
<profile automaticSaveEnabled="false"
enabled="true"
inherits="ProfileUtility.UserProfile">
This is for the Default Provider, if you use Custom Provider as well, use the following:
<profile defaultProvider="<YourProviderName>"
automaticSaveEnabled="false"
enabled="true"
inherits="ProfileUtility.UserProfile">
Joe Wrobel fills an important hole for people developing web applications in VS08
Files can be downloaded from the Web Profile Builder project page.
If you use Web Application Projects, you have probably run into the issue of not being
able to access the Profile at design time.
Web Profile Builder for Web Application Projects - Joe Wrobel
This was a critical missing piece for some work I was doing, now the mouse wheel works as expected, Thanks Scott.
I have been checking out Deep Zoom in Silverlight 2, but I thought it was a bummer that there wasn't (yet) a "Hello DeepZoom World!" example that includes panning, zooming (mouse wheel) support out of the box. The Vertigo example behaves exactly as I'd want my stuff to behave.
Deep Zoom (Seadragon) Silverlight 2 MultiScaleImage Mouse Wheel Zooming and Panning Edition
If you are working with the Silverlight 2.0 Beta you will most likely need this.
This version is compatible with the new Object Model of Silverlight 2.0.
Microsoft® Expression Blend™ 2 is the professional design tool used to create engaging Web-connected experiences for Microsoft® Windows®. The Expression Blend 2.5 March 2008 Preview allows you to create Microsoft® Silverlight™ 2-based applications.
Download details: Microsoft Expression Blend 2.5 March 2008 Preview
For everyone following the Seadragon aka MultiscaleImage stuff. I really see this as a giant leap forward web image delivery.
If you have followed the Silverlight 2 Beta 1 announcements, Silverlight 2 includes support for the Deep Zoom technology to allow you to quickly and smoothly zoom in on really large images. If you want to see an amazing implementation of the Deep Zoom technology, check out the Hard Rock Memorabilia site: http://memorabilia.hardrock.com/
And the apparently good name change to become part of the expression suite.
Expression Blend and Design : Download the Preview of the Deep Zoom Composer
When installing Silverlight 2.0 beta 1 I encountered the following error:
An Error Has Occurred:
Silverlight Tools cannot be installed because one or more of the following conditions is true:
1. Visual Studio 2008 RTM is not installed.
2. The Web Authoring feature of Visual Studio is not installed.
3. A previous version of the Silverlight Runtime is installed.
4. A previous version of the Silverlight SDK is installed.
5. The Visual Studio Update KB949325 is installed.
6. A previous version of Silverlight Tools is installed.
To continue, please install or uninstall the appropriate products and run this installer again.
First of all... This is ridiculous, the installer knows EXACTLY what is missing... so what is it? Why do I need to hunt down one of 6 possible problems? Just tell me EXACTLY what is wrong, or better yet, FIX IT! If I need to uninstall something, then DO IT, obviously that is what I WANT to do to make this work. If I need to Install something, then go get it and install it (unless of course it is VS08 which would make me a complete idiot for trying to install this without that) or point to the Trial Version with a darned link already.
I know that VS08 and the Web Authoring feature are installed...
I already uninstalled the previous Silverlight stuff I have...
I looked in Installed Updates and don't see the referenced KB Update...
I already uninstalled the previous SDK Tools and Rebooted...
So, this "error" is of course, NO HELP.
If companies want to make tools and have them get widespread adoption, then they need to be smart and helpful, not say:
Uhhhh, something bad happened and I can't help you, later dude.
So, where is the log of the installer so I can manually go track down an error that the installer should be intelligently informing me about...
UPDATE:
Apparently the Registry Entry “HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\ToolboxPages\Silverlight Components” must not exist or the installer fails. After simply removing this entry, the install worked without a hitch. This must not get removed correctly by some versions of the Silverlight Tools.
More information for resolving problems can be found here.
In case you missed it this morning... Silverlight 2.0 is NOW AVAILABLE... WOOHOO!
Look ahead to the next generation of Silverlight 2 controls: Charts, Image Sliders and more. You will be able to create apps having:
- Richly compelling experiences.
- Real relevance for business.
- Interop with ASP.NET and AJAX.
Now I can finally talk about some of the stuff I am doing with work in SL2. Stay tuned for a few demos and announcements about what I am doing. The first one you can see Live March 11 when I will be demoing a Silverlight 2.0 App at the AZGroups Scott Guthrie event.
Copyright © 2003-2004 H. Steele Price, IV -
All opinions are my own, not necessarily those of my employer, your mother, or any government agency.