I recently installed Microsoft Velocity client on 5 of my dedicated servers and I thought I’d give this distributed caching a try and see how it went. The 5 severs are all running Windows Server 2008 Standard x64 with AD Services. Installing couldn’t have been easier or have gone smoother. So after installing Velocity on my 5 machines I went to the lead machine to start it. Note, at this point I hadn’t setup the cluster yet I was just installing it on the machines.
1: PS C:\Program Files\Microsoft Distributed Cache\V1.0> get-cachehost
2:
3: HostName : CachePort Service Name Service Status
4: -------------------- ------------ --------------
5: VSERVER:22233 DistributedCacheService SERVICE DOWN
So far so good.
Next was to start the individual cache host…
1: PS C:\Program Files\Microsoft Distributed Cache\V1.0> get-cachehost
2:
3: HostName : CachePort Service Name Service Status
4: -------------------- ------------ --------------
5: VSERVER:22233 DistributedCacheService SERVICE DOWN
6:
7:
8: PS C:\Program Files\Microsoft Distributed Cache\V1.0> start-cachecluster
9: Unable to open store PartitionAccessor: System.DllNotFoundException: Unable to l
10: oad DLL 'sqlceme35.dll': The specified module could not be found. (Exception fro
11: m HRESULT: 0x8007007E)
12: at System.Data.SqlServerCe.NativeMethods.DllAddRef()
13: at System.Data.SqlServerCe.SqlCeConnection..ctor()
14: at System.Data.SqlServerCe.SqlCeConnection..ctor(String connectionString)
15: at System.Data.Cas.Main.SqlCeStore.OpenConnection(String connectionString)
16: at System.Data.Cas.Main.SqlStoreProvider.Open(String ownerId)
17:
18: HostName : CachePort Service Name Service Status
19: -------------------- ------------ --------------
20: VSERVER:22233 DistributedCacheService SERVICE DOWN
21: Start-CacheCluster : Unable to load DLL 'sqlceme35.dll': The specified module c
22: ould not be found. (Exception from HRESULT: 0x8007007E)
23: At line:1 char:18
24: + start-cachecluster <<<<
Well –- that didn’t work. You’ll see I used the cmdlet start-cachecluster this just goes down the list and uses start-cachehost on each cluster node.
I later found out that this is a known issue with Velocity and a temporary fix for CTP2 has been found. Just download SQL Server Compact 3.5 SP! x64 and install it on your machine. So after installing that I tried to run start-cachecluster again.
1: PS C:\Windows\System32> start-cachecluster
2:
3: HostName : CachePort Service Name Service Statu
4: -------------------- ------------ -------------
5: VSERVER:22233 DistributedCacheService SERVICE UP
Fixed!
So this is a known issue by the Velocity team and it will be fixed in the next version.
With C# 4.0 actively in development I thought it would only be appropriate to start writing about the new features. The first I’ll be visiting is the new dynamic type.
The dynamic type allows us to easily access an object type without statically knowing the type at code-time. This means we can declare an object as dynamic at code-time without having to know anything about it. This means we get no intellisense, code-time or compile-time feedback. If a member/method is invoked dynamically that does not exist or something along those lines you will get a runtime exception of type RuntimeBinderException stating it could not find the symbol. In order to allow the dynamic invocation of these members/methods it utilizes some things from the DLR (Dynamic Runtime Library) which actually runs as a normal .NET DLL on top of the CLR (Common Language Runtime). Let’s see it in action.
We’ll start with something simple to get us going.
1: static void Main(string[] args)
2: {
3: dynamic dynObj = "Hello dynamic world!";
4: Console.WriteLine(dynObj);
5: Console.ReadLine();
6: }
As you can see this looks pretty straight-forward. We’re just declaring a dynamic type (dynObj) and setting it as a string type. The output is as follows…
Hello dynamic world!
So you can see that we can treat it like a normal .NET object but with no intellisense or statement completion. Time to check it’s actual type.
1: static void Main(string[] args)
2: {
3: dynamic dynObj = "Hello dynamic world!";
4:
5: Type dynObjType = dynObj.GetType();
6: Console.WriteLine(dynObjType.Name);
7:
8: Console.ReadLine();
9: }
Outputs…
String
Exciting, I know. What this tells us is that at run-time it’s being treated as a string whereas at code-time it’s treated like a dynamic type. Something you can also get out of that code snippet is that I’m calling .GetType() on the object. This could lead to some much more complex uses I just wanted to show the basics
I know my examples weren’t all super-exciting however I showed the basic ideas behind using a dynamic type. Currently dynamic types can be used for generic type parameters, method parameters, method return types and so on. They however have a few limitations on them. For example – you cannot use the addition (+) operator on dynamic objects. In the long run however, they give us much easier access to unknown incoming object types. So instead of having to use reflection to crawl the type you could just use dynamic types instead… quite handy indeed.
I've been looking for a place to put my blog for quite a long time. I've always been partial to running it on my own server or at home because I want it to be my area, and mine alone. I later realized I'd rather help and be a part of a community. So with the help of Joe Stagner www.misfitgeek.com I now have a blogging home -- thanks Joe!
So with that I'd like to introduce myself. My name is Chad Moran and I'm a .NET/ASP.NET software developer. I currently have a few private projects going and I'm self-employed. At the time of this posting I'm 23 and writing my code from an apartment in downtown Baltimore, MD. I've been involved with using .NET since Visual Studio was first launched to the public and have even attended a few Microsoft events around the US since then including the {Heroes Happen Here} event in Cary, NC. As of late I haven't been too involved with the .NET community as a whole though I'd really like to start having an online sense in the community.
Anyway, thought I'd give some sort of introduction rather than appearing out of nowhere.
My stuff...
Stackoverflow profile
More Posts
« Previous page