This was such a beautiful picture, I just had to share.

My beautiful Itamar, eating Pitanga on a trampoline.

DSC02907

Posted by RoyOsherove | 5 comment(s)
Filed under:

My book, The Art Of Unit Testing, is now in stock at Amazon. If you’ve read the book, I’d love it if you put in a review on that page.

wow. I didn’t even know these sorts of sites existed!

Isn’t the web great for really small niche markets?

(via Jason)

Posted by RoyOsherove
Filed under:

What are your thoughts on this style of writing?

  • Specifically the “Explicit” way of defining arrange, act and assert scopes.
  • also, given the name of the test, where should the call to “OnApplyTemplate” be (if you’ve never seen the code)?
  • which version makes more sense to you? A, or B?

 

version A:

 

image

 

version B:

image

Coming up in SilverUnit, the true unit testing framework for silverlight controls

image

Posted by RoyOsherove | 1 comment(s)
Filed under: ,

I was recently asked to review a licensing solution – CryptoLicensing for .NET(disclosure – I was paid for my time , the time it took to review it, but had only committed to doing a fair and balanced review). After reading Oren’s post a while ago about how he couldn’t find a decent licensing solution to the point of making his own, I was sure that this one will fall out as well over some technicality.

Typemock also has a home-grown solution for licensing, and while searching the web about a year ago I was hard pressed to find a decent licensing component for .NET that didn’t suck in terms of usability or features.

So, all the signs pointed to the possibility that this would be yet another one of those licensing schemes that are just not good enough, but I was wrong.

It took me less than an hour to feel pretty comfortable with the CryptoLicensing API, and the feature set it contains is pretty powerful, packaged in a very simple API. It does have some small flaws, but they are shadowed by the very big value it provides.

As one discovers pretty quickly when doing their own homegrown licensing solution, a licensing scheme has at least two main parts: THE API you use from within your software, and the Serial Generator (KeyGen) software. Often, the keygen will also have an API that can be used programmatically so that you can then generate licenses on the fly automatically per an automated request (say CRM).

I was happy to discover that CryptoLicensing supports all that out of the box and so much more. but let’s start at the beginning:

The API:

The API is very simple to use. There is only one class you use in your project: CryptoLicense. This class allows you to load a license from the local machine, or save one either to the registry or to the file system. the API can be used in two ways:

the simple way is just to check a status property on the CryptoLicense class one you have tried to “load” it. If it’s anything but Status.Valid then you need to put in a serial number.

The class can then be invoked to show a “Enter Serial” dialog that is built in, which will tell the user what are the current license terms or how much time they have left on the current license. The dialog is fully customizable – it comes with full source code so you can make it your own very simply.

here’s how the eval dialog looks:

image

I do wish that there was a way to set some of the strings in the dialog programmatically, instead of having to create your own version of the dialog, but the guys at SSWare, the maker of this tool assure me this feature is coming in future versions.

Once the dialog is gone you get back a yes\no answer. if it’s a no, the license is still not valid and you can choose to end your program right there. If it’s “yes” you can save the new license details the user entered and continue operations. it’s very simple to use.

The advanced way:

One of the features that many licensing schemes require is the ability to have different features of the software enabled or disabled based on the current license. I was happy to see that this open is built into the CryptoLIcensing API and keygen.

The API has a “IsFeatureEnabled(featureEnum)” function. there are thirty something features available in the enum. more than enough for most if not all licensing schemes. The great thing is that the license code you generate contains all the data you need to determine what feature is enabled. So, once you initialize the CryptoLicense class, you just ask whether feature in enum12 is enabled (enum12 could be mapped to some feature in your application. If that’s true, you allow that feature to run. or you don’t if it’s not. Pretty cool and powerful.

Here’s how the keygen looks (features related part is highlighted)

image

You’ll also note about the keygen that you can set many options for evaluation. and i mean many:

image

Pretty powerful. All of these features will be encapsulated int he Status property of the CryptoLicense API. If the status is not valid, you have special enaus that explain which of these statuses is true.

 

Floating licenses and license server

another powerful feature set enables you to set floating licenses in a company:

image

or lock a serial to a specific machine. The software comes with the source for a simple enough ASP.NET web serivce that ca nbe run on IIs. you install this on a machine that will be declared as your license server, and that server can “activate” software licenses based either on a serial that was provided or the amount of already active licenses for that company. tha tmeans that if you are the issuer of the software, you can have your own license server, but large companies who request floating licenses can have a customized version of the license server running on the local customer server for that specific company.

 

Licenses vs. serials

CryptoLicensing has two notions of keys. a “License” is a longer string that can be used to “activate” a customer’s software without needing outside activation. A “Serial” is issued but cannot be verified without contacting a license server. This is not clear by default in the keygen and I am told they will be making it easier to understand both in the docs and in the keygen window:

image

even now I still get a little confused what each one of those four means. I wish the UI was simpler to use.

embedded license information

One powerful feature is that you can “embed” into a license all the user and company information you need:

image

all this info can be gotten at runtime only from the license key, and allows a very simple way of mapping licenses to customers in your CRM system for example.

Summary

There are many more features that I have not covered(tried). for example, it supports licensing of .NET controls. Since I don’t do custom controls I don’t know how useful that feature is.

I’ve also looked at the obfuscated source of the cryptolicensing package and it looks pretty good. The software itself doest not offer obfuscation abilities and I like that. Focus on one thing and do it well. I’ll obfuscate using other tools, thank you.

overall I’ve found CryptoLicensing for .NET to be a very powerful and easy to use product. I think it’s the only one that I’d feel comfortable to use in a real project for now. The UI has some quirks. the only thing I’m really missing from this is the ability to disallow the same license across the network without needing to install a license server (Resharper has this ability). If that were possible this would be absolutely marvelous. I asked and was told it is coming soon to a version near you.

Posted by RoyOsherove | 4 comment(s)
Filed under: ,

image A friend asked me how I know about so many things that happen in the .NET sphere. the answer is very very simple. All you have to do is follow a few blogs on a daily basis, and you’ll have access to a whole world of new and existing things you didn’t even know existed in .NET.

here are the first three blogs I subscribe to on a daily basis. These are “link blogs”, they only supply links to cool and interesting stuff that happens in .NET land.

*Update: Also found the following:

If you think I’ve missed some good news links blogs in our sphere, feel free to post in the comments. I’ll updated the post as needed.

Having stated to look into silverlight not long ago, I was totally put off by the horridness that is DependencyProperties, and how you implement them:

  • You need to declare a static property that is registered at the type initialization phase
  • you need to have a “regular” property that calls getvalue and setvalue with that property
  • if you want to handle changes you need to registed a specific callback in the dependency declaration
  • the same goes for default value

yuck.

 

So here’s what I came up with. It’s a simple base class you can use in your silverlight projects, and inherit your custom control from. Once you do it, you can write DependencyProperties like this:

image

the things to note here:

  • You inherit from CustomControlBase
  • The On[PropertyName]Changed will be registered automatically based on its name (Convention based work)
  • You call GetDPValue and SetDPValue instead of GetValue and SetValue
  • You set the DefaultValue using an attribute (in System.ComponentModel)
  • You can omit the callback method if you want.
Posted by RoyOsherove | 7 comment(s)
Filed under: ,

Here’s a much better DependencyProperty snipper for Silverlight custom controls that can be used with resharper:

        #region $PROPNAME$ Property
        public $PROPTYPE$ $PROPNAME$
        {
            get { return ($PROPTYPE$) GetValue($PROPNAME$Property); }
            set { SetValue($PROPNAME$Property,value); }
        }

        public static readonly DependencyProperty $PROPNAME$Property =
                                            DependencyProperty.Register(
            "$PROPNAME$", typeof ($PROPTYPE$), typeof ($DECLARING_TYPE$),
            new PropertyMetadata($DEF_VALUE$ , On$PROPNAME$Changed ));

        private static void On$PROPNAME$Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            $DECLARING_TYPE$ $DECLARING_TYPE_var$ = d as $DECLARING_TYPE$;
            $END$
        }
        #endregion

Posted by RoyOsherove | 2 comment(s)
Filed under:

This is an issue that had me stumped for a while. I was getting a “Requested registry access is not allowed.” message from visual studio when trying to create a new silverlight application.

turns out the culprit is a few registry entries that somehow don’t have the correct permissions.

To fix this:

  • Download the “SubInACL” tool from Microsoft and install it
  • create a batch file in its install dir (C:\Program Files\Windows Resource Kits\Tools\)
  • the batch should contain:

subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl /grant=administrators=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl /grant=users=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl /grant=system=f

subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl\CLSID /grant=administrators=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl\CLSID /grant=users=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl\CLSID /grant=system=f

 

subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl.2.0 /grant=administrators=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl.2.0 /grant=users=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl.2.0 /grant=system=f

subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl.3.0 /grant=administrators=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl.3.0 /grant=users=f
subinacl /subkeyreg HKEY_CLASSES_ROOT\AgControl.AgControl.3.0 /grant=system=f

 

run the batch file from a command line as administrator, and that should fix the problem. This problem can also occur on other project types, so you may need to fix it by calling out to different registry keys. like this one for example.

Posted by RoyOsherove | 2 comment(s)
Filed under: ,
More Posts « Previous page - Next page »