Archive for April, 2009

Calculate the Color at a specific point on a 2 color gradient

Thursday, April 16th, 2009

Recently I started a project where I needed to use colors to represent classes gradiated between two colors.  While the colorblend and blend objects in .NET is great if you want to display color gradients, its not so usefull if you want to know what the color is at 70% between two colors.  Thus the color at a percentage of a gradient color.  The code to do this below where color1 and color2 is the start and end colors and color1Perc is the percentage betweeen the two colors (with 0 being equal to color1 and 100 equal to color2).  Please note the error checking is very basic an may need improvement.

Public Function colorMix(ByVal color1 As Color, _
ByVal color2 As Color, ByVal color1Perc As Double) As Color
Dim r As Integer, g As Integer, b As Integer
Dim ra As Double, ga As Double, ba As Double
Dim col As Color

Try
color1Perc = (color1Perc) / 100
ra = CDbl(color1.R) + ((CDbl(color2.R) - CInt(color1.R)) _
* color1Perc)
r = CInt(Math.Min(ra, 255))
ga = CDbl(color1.G) + ((CDbl(color2.G) - CInt(color1.G)) _
* color1Perc)
g = CInt(Math.Min(ga, 255))
ba = CDbl(color1.B) + ((CDbl(color2.B) - CInt(color1.B)) _
* color1Perc)
b = CInt(Math.Min(ba, 255))

col = Color.FromArgb(CByte(r), CByte(g), CByte(b))
Catch ex As Exception
col = color1
End Try

Return col
End Function

MOSS: An error occurred while enabling Enterprise features

Friday, April 3rd, 2009

Recently the evaluation version of MOSS 2007 on our development server timed out.  Whoever installed it did not have the Enterprise key and installed the trial version.  After needing to do some demo screen shots for a presentation I was the one that discovered it! Of course nobody else was around to fix it for me.  So I contacted our IT department and got the key from them (my company is an Microsoft Gold Partner). Armed with the key and full of confidence I tried to activate the enterprise features (Central Administration>Operations>Upgrade and Migration>Enable Enterprise Features) and got this beauty:

“An error occurred while enabling Enterprise features…”

Scratching around on the internet a bit, it seems this is (unsurprisingly) uncommon occurence! Eventually I found the resolution buried in the n-th comment reply to somebody’s question on the same error.  It seems the Windows SharePoint Services Timer service needs to be run under an account with administrative priveledges in order to complete the job that gets created when you upgrade to Enterprise features.  In our case the service was running on the Network Services account which did not seem to have enough priviledges.

Once you changed the account logon, remember to restart the service and delete any existing enterprise activation job (Central Administration>Global Configuration>Timer job definitions) before you retry the feature activation.

After enabling the Enterprise features you may also want to restart IIS and remember to enable the enterprise features on all the relevant sites!