I use the following code to get metadata with Microsoft.Web.Administration.ServerManager:
var manager = new ServerManager();
var site = manager.Sites["siteName"];
var metadata = site.GetMetadata("metaKey");
Now, if "metaKey" is not there, the GetMetadata will throw a System.Runtime.InteropServices.COMException exception with the message "The request is not supported". If I first set a metadata value like this
site.SetMetadata("metaKey", "hello")
the GetMetadata("metaKey") won't throw an error but instead kindly return the value "hello". How do I check if a key exists before I attempt to retreieve it? I want to avoid a try catch if it's possible.