NET Caching Library Help
ThrowExceptions Property
Example 




KellermanSoftware.NetCachingLibrary Namespace > SmartCache Class : ThrowExceptions Property
Throw exceptions when there is a problem loading or saving from the cache. The default is true. Exceptions may be logged.
Syntax
'Declaration
 
Public Property ThrowExceptions As System.Boolean
'Usage
 
Dim instance As SmartCache
Dim value As System.Boolean
 
instance.ThrowExceptions = value
 
value = instance.ThrowExceptions
public System.bool ThrowExceptions {get; set;}
public: __property System.bool get_ThrowExceptions();
public: __property void set_ThrowExceptions( 
   System.bool value
);
public:
property System.bool ThrowExceptions {
   System.bool get();
   void set (    System.bool value);
}

Property Value

true if [throw exceptions]; otherwise, false.
Example
//Create a Primary Memory Cache with a backing File Cache
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests");
SmartConfig config = new SmartConfig(new MemoryCacheProvider(), new FileCacheProvider(directory));
            
//Specify UserName and LicenseKey for Licensed Mode
//config.UserName = "my user name";
//config.LicenseKey = "my license key";
            
//Instantiate the cache
SmartCache cache = new SmartCache(config);
            
//Turn on throwing exceptions (the default is true)
cache.ThrowExceptions = true;
            
//Save it as a string
cache.Set<string>("Key", "This is a test");
            
//Loading it as an integer will throw an exception
try
{
	var result = cache.Get<int>("Key");
}
catch (Exception ex)
{
	Console.WriteLine(ex);
}
'Create a Primary Memory Cache with a backing File Cache
Dim directory As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "KellermanSoftware", "NetCachingLibrary", "Tests")
Dim config As New SmartConfig(New MemoryCacheProvider(), New FileCacheProvider(directory))
            
'Specify UserName and LicenseKey for Licensed Mode
'config.UserName = "my user name";
'config.LicenseKey = "my license key";
            
'Instantiate the cache
Dim cache As New SmartCache(config)
            
'Turn on throwing exceptions (the default is true)
cache.ThrowExceptions = True
            
'Save it as a string
cache.Set(Of String)("Key", "This is a test")
            
'Loading it as an integer will throw an exception
Try
	Dim result = cache.Get(Of Integer)("Key")
Catch ex As Exception
	Console.WriteLine(ex)
End Try
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SmartCache Class
SmartCache Members