Tuesday, March 29, 2011

Setting up a role with execute permissions using SSMS

I have always created roles with the execute permissions only through SQL scripts and the reason for this is that I could never figure out how to do it via Sql Management Studio. Well today I figured it out and so here are the here are the steps for setting up a role with execute permissions using Sql Server Management Studio (SSMS).

Why? If you want to control what permissions your users have to the database and want to control it through roles. I used it for defining a separate role that would be used if users needed to have execute permissions on all the stored procs in the database (instead of – per stored proc).

  1. Right click on the roles node under security for your database and select Add New Database Role.
  2. Setup the General properties page
    image
  3. On the securables page, select Search and select all objects of type and click OK
    image
  4. In the next window, select databases and click OK
    image
  5. Back on the securables page, select the database row that just got added and in the Permissions for {DatabaseName}, select grant for the Execute permission.
    image

When you click ok, your role will be created and the steps will be similar to the following script.

USE [databaseName]
GO
CREATE ROLE [db_execute_role] AUTHORIZATION [dbo]
GO
use [databaseName]
GO
GRANT EXECUTE TO [db_execute_role]
GO

Note: this may not be the most secure for your purposes, but the steps can easily be modified to reduce the level at which the execute permissions are provided. (these steps define it at the database level).

Silverlight–Detecting design mode

When you need to detect if your view or view-model is being instantiated during design time or runtime, the easiest method is to check the IsInDesignTool static property of the DesignerProperties class.

Even better implement it in your ViewModel’s base.

protected bool IsDesignTime()
{   return DesignerProperties.IsInDesignTool;
}
Note: You don’t need to cache the IsInDesignTool property value as calling it doesn’t result in any methods being called.
FYI, the following code didn’t work when the View was opened in Visual Studio (found them via Google).
DesignerProperties.GetIsInDesignMode(Application.Current.RootVisual)
DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue

Monday, March 28, 2011

Javascript not working in IE

I recently came across a situation where javascript was not working on my machine.

I made sure that scripting was enabled in IE:

clip_image001[4]

But still Javascript would not work on the machine.

BTW, this page is a great place to test for Javascript support in your browser:
http://www.virtualjournals.org/jhtml/testbrow.jsp

If javaScript is enabled you should see the following page when you hit the above website:
clip_image001[6]

After much googling, I found the following fix: and it was to re-register the jscript.dll file using the following command (Start->Run):

regsvr32 jscript.dll

Friday, March 25, 2011

IIS 7 Error: Cannot read configuration file due to insufficient permissions

If you get the error: Cannot read configuration file due to insufficient permissions

You need to provide the IIS_IUSRS group access to the folder where your website is stored.

mRemote–a great app to manage multiple remote desktop connections

The sysadmins at work showed me this app and its awesome and its free.

http://www.mremote.org/wiki/MainPage.ashx

“mRemote is a full-featured, multi-tab remote connections manager.
It allows you to store all your remote connections in a simple yet powerful interface.”
mRemote Website

I love it!

Sunday, March 20, 2011

Speed of execution

“A good plan violently executed now is better than a perfect plan next week.”

General George Patton

Are we in the era of Dot Com Bubble 2.0?

Came across this excellent presentation by Steve Blank (shown at the SxSW 2011 conference)

This blog post by Steve Blank provides more background on the deck above: http://steveblank.com/2011/03/18/new-rules-for-the-new-bubble/

An interesting quote by the author:

2001 – 2010 – The Era of the Lean Startup:
- Customer Development, Agile Engineering and the Lean methodology enforced a process of incremental and iterative development. Startups could now get a first version of a product out to customers in weeks/months rather than months/years

Startups began to recognize that they weren’t merely a smaller version of a large company. Rather they understood that a startup is a temporary organization designed to search for a repeatable and scalable business model.

Friday, March 11, 2011

VS2010, TFS 2008 and Unit Tests

For the last couple of days I have been battling with TFS2008 and getting our build server to run the unit tests defined in a Visual Studio 2010 solution.

Previously we installed .Net 4.0 and updated the MsBuild path in the tfsbuild.proj file so our VS2010 solutions were building without a problem on the TFS2008 based build server. But the minute I tried to get the build server to run the unit tests in my solution, the build would partially fail and if looked in the BuildLog.txt file, this is the error I got:

Task "TestToolsTask"
MSBUILD : warning : Visual Studio Team System for Software Testers or Visual Studio Team System for Software Developers is required to run tests as part of a Team Build.  [Path\TFSBuild.proj]
  The previous error was converted to a warning because the task was called with ContinueOnError=true.
  Build continuing because "ContinueOnError" on the task "TestToolsTask" is set to "true".

Googling the error and you find out that you need Visual Studio 2010 Premium or Ultimate edition to be able to run unit tests as part of your build. So I went ahead and installed VS2010 ultimate and I still got the same damn error shown above.

It turns out that in addition to VS2010 (premium or ultimate) you also need VS2008 Development edition on the build machine. (In addition is the operative word here – you need both!). It turns out that the TestToolsTask is looking for VS2008 dev edition before running even a VS2010 based solution (and I am not sure if this for some required dlls or for licensing purposes – either ways – it sucks) (Obviously the reason I had to battle with this issue was that the build machine was never previously setup to run MsTests – even with Vs2008, else someone would have figured out that they needed VS2008 dev edition on that box).

Once I got VS2008 dev edition on that machine I was able to get the build a little further. HOORAY!

Some other things to note:

Once you get both VS2008 dev and VS2010 premium on that machine, you should delete the workspace used by the TFS service on the build machine (the easiest way to do this is to use the TFS SideKicks tool and search for all the workspaces on that machine and then delete the one that is being used for your build). This allows TFS to rebuild the workspace and all the files, but this time with MsBuild 4.0.

Now that I got one problem fixed, TFS decides to throw another one at me and the error that I get is as follows:

Task "TestToolsTask"
  Command:
  d:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe /nologo /searchpathroot:"path\Binaries" /resultsfileroot:"path\TestResults" /testcontainer:"path\Binaries\\\\Tests.dll" /publish:"TFSURL" /publishbuild:"vstfs:///Build/Build/26026" /teamproject:"Project" 
  The "TestToolsTask" task is using "MSTest.exe" from "d:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe".
  No platform specified for publish operation.
  For switch syntax, type "MSTest /help"
MSBUILD : warning MSB6006: "MSTest.exe" exited with code 1. [path\TFSBuild.proj]
  The previous error was converted to a warning because the task was called with ContinueOnError=true.
  Build continuing because "ContinueOnError" on the task "TestToolsTask" is set to "true".
Done executing task "TestToolsTask" -- FAILED.

[Update 3/14/2010]

The problem with MsTest is that it always use the generic error code of 1 when it fails. So it makes it extremely hard to figure out what is going on when it fails. I looked through a long list of online articles that had me doing a whole bunch of things and at the end the following is what fixed it for me:

  1. Need to Microsoft.TeamFoundation.Build.targets file to use the VS2010 dll instead of the VS2008 dll for the testToolsTask
    In the folder: “C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\” on the build machine you will find the file “Microsoft.TeamFoundation.Build.targets”. Edit the following lines:
    Comment out the original line for the TesToolsTask:
  2. <UsingTask TaskName="TestToolsTask"
                 AssemblyFile="$(MSTestRefPath)\Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll"
                 Condition=" '$(ProjectFileVersion)' == '2' "/>

    Insert the following line right after it

    <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.TestToolsTask"
                 AssemblyFile="c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
                 Condition=" '$(ProjectFileVersion)' == '2' "/>

    Make sure that the path to “Microsoft.TeamFoundation.Build.ProcessComponents.dll” is correct
  3. Next make sure that you have specified the platform in your TfsBuild.proj file:

    This is how it looks like in my TfsBuild.proj:

    <ItemGroup>
        <SolutionToBuild Include="$(SolutionRoot)/mySolution.sln" >
          <Targets></Targets>
          <Properties>Configuration=Release;Platform=Mixed Platforms</Properties>
        </SolutionToBuild>
      </ItemGroup>
      <ItemGroup>
            <ConfigurationToBuild Include="Release|Any CPU">
                <FlavorToBuild>Release</FlavorToBuild>
                <PlatformToBuild>Any CPU</PlatformToBuild>
            </ConfigurationToBuild>
      </ItemGroup>

    If the PlatformToBuild is not specified the “No platform specified for publish operation” error can occur.

With the above 2 fixes in place, the final thing that I needed to specify were which tests should be executed. This is done using one of the following 2 methods:

Specify the VSMDI file using the metadataFile node as follows:

<MetaDataFile Include="$(SolutionRoot)/mySolution.vsmdi">
            <TestList>TestListToExecute</TestList>
</MetaDataFile>

Or use the following node to define a wildcard to select the files that contain the tests:

<TestContainer Include="$(OutDir)\Tests.dll"/>

With that your TeamBuild should be executing all your unit tests.

Code-Coverage:

The only thing that I havent been able to get going is Code-Coverage on my solution. Here is what I have tried:

I have setup the VSMDI to use a testConfiguration for the unit tests. As part of the test-configuration, Code-Coverage is enabled and I have selected the dlls on which code-coverage should be run. With the above settings, some files (like data.coverage) get created in the drop folder, but TFS reports that code-coverage was not run.

After spending quite some time on this problem, I am just about ready to give up (especially because this post seems to state that code-coverage is not possible using TFS 2008 and VS2010 and .Net 4 built modules - http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/39aaaf43-0e3a-41c7-8b72-c1cabc9438e1/).

Thursday, March 10, 2011

"The sooner you fall behind, the more time you will have to catch up."

Conference room wall – Shuttle Software Development Group

"The sooner you fall behind, the more time you will have to catch up."

.Net Reflector v7 is out and I am not happy with Red Gate

Its been known for a while that .Net Reflector v7 was supposed to be a paid version and although I was saddened by that decision by RedGate, I was ok with it.

But what I was not ok with was that when I started up my trusty old copy of v6.1 of .Net Reflector today, it told me that I needed to upgrade to the latest version. But I didn’t want to pay for it so I responded no to the prompt and RedGate promptly went and deleted my reflector.exe file!!!! NOT COOL RED-GATE, Not Cool!

This is the first time I have ever come across a software that doesn’t allow you to run an older version of the software for which we obviously had a license. And definitely it’s the first time I have come across a software that goes to the extent of deleting its file without even asking the user.

Unhappy! unhappy! unhappy!

I hope Red-Gate reviews its policy – as there is no reason why they should cripple their previous free versions of .Net Reflector.

Monday, March 07, 2011

Software Project Management speak

via http://blogs.msdn.com/b/willy-peter_schaub/archive/2011/03/07/project-management-lingo-funny-but-true.aspx

Commonly heard phrases in software project meetings and what is actually being said:

When this is said … This is actually meant …
The schedule is aggressive We are toast
We will makeup the slippage in the next few iterations We are still toast
Executive summary Cartoon version
High-Level Not for real
Work continues We are clueless
Time will tell We are clueless and we admit it
Code complete Not tested
The code has become unmaintainable I would have designed it differently
Best practice Invented by people who do not work here and therefore infinitely superior to anything we do

Sunday, March 06, 2011

40 free hand-written fonts

image

A nice collection of 40 free handwritten fonts: http://www.hongkiat.com/blog/40-free-high-quality-hand-drawn-fonts/

Jailbreaking iPhone 3G (iOS 4.2.1)

I have a 3 year old iPhone 3G and for the past couple of months kept trying to jail-break it so that I could use the phone on any cell-phone network and was always having trouble.

I had tried limera1n and greenpois0n and both didn’t work on my 3G iPhone.

I finally tried Redsn0w today and managed to successfully jailbreak the phone.

Here are the instructions:

  1. Download iOS 4.2.1 package (IPSW) for your iPhone 3G from Apple’s website
    http://appldnld.apple.com/iPhone4/061-9853.20101122.Vfgt5/iPhone1,2_4.2.1_8C148_Restore.ipsw
    For a comprehensive list of packages for other iPhone devices check out the following site:
    http://www.iclarified.com/entry/index.php?enid=750
    Note: You can use the above downloaded package to reinstall a fresh copy of the iOS 4.2.1 firmware to your phone. To do this you need to run iTunes and while your phone is connected, click on the update button while pressing shift. (This will let you browse to the IPSW file which you downloaded above).
  2. Next you need the RedSn0w executable. Get it from the following link:
    Windows: http://cdn.nspwn.com/redsn0w_win_0.9.6b4.zip
  3. Extract the files in the archive that you downloaded.
  4. Right click on the redSn0w.exe file and open the Properties window. Select UNBLOCK.
  5. Before running RedSn0w turn off any anti-virus you may have running temporarily (first scan the Redsn0w package before turning of auto-protection).
  6. Run RedSn0w in administrator mode (Right click on RedSn0w.exe and select run as Administrator).
  7. The first screen will have a browse button. Click on it and select the IPSW file that you downloaded in step 1.
    RedSn0w will process the IPSW file for less than 1 minute after which the Next button will be enabled.
  8. Clicking on Next will process the file.
  9. The only 2 options that you need are “Install Cydia” and “Enable Battery Percentage” (These are the default options).
  10. Click Next.
  11. Now before you hit Next on this screen read the instructions carefully. You need to prepare the device for unlocking
    1. First make sure that your phone is on.
    2. Connect it to your computer
    3. Now hold the power button down until you get the Slide to power off screen
    4. Slide the power off button and power down your phone (remember all this is done while your phone is connected to your computer).
  12. Before clicking next here is what you need to know.
    1. As soon as you click Next you will be asked to hold down the power button for 3 seconds
    2. Next you will be asked to press the Home button without letting go off the power button for another 10 seconds.
    3. Finally you will let go off the the Power button, but continue holding down on the Home button for 15 more seconds.
  13. Now that you know what is going to happen next, click the Next button and follow the instructions (which will be similar to what I described in 12).
  14. If everything worked correctly, RedSn0w will begin loading the modified firmware onto your phone and then reboot it.
  15. After that the jailbreak process will continue on your phone.

To verify that you managed to Jailbreak your phone all you need to do is check the battery meter (top right corner and it should have a % value next to it. In addition you should see the Cydia app on the phone).

That’s it. Your phone should be jailBroken and you should be able to use it with other cell phone carrier’s sim card (like Sprint)

And if you are worried that Jailbreaking your iPhone maybe illegal in the US, don’t worry, Federal agencies have concluded that Jailbreaking your phone is legal. See: http://abcnews.go.com/Technology/us-government-jailbreaking-iphone-legal/story?id=11254253

Friday, March 04, 2011

Show deleted files in Team Explorer’s Source Control view

The option is hidden (i.e, not available from the Source Control explorer view) which makes me always forget how to turn on the ability to view deleted files in TFS’s Source-Control view.

It is under the Options dialog of Visual Studio (Tools—> Options)

image