Posts
23
Comments
10
Trackbacks
0
Tuesday, June 30, 2009
Request for the permission of type 'System.Data.SqlClient.SqlClientPermission failed Error

After some time working on another SQL CLR I am getting an error

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=' failed.

This procedure needed to access a stored procedure on a remote server. Running that stored procedure within SQL Server Management Studio completed successfully. It just would not execute from my SQL CLR !

Doing online research did not lead to a solution.

Nearly completely tired I dropped by my DBA with this issue who decided to add SQL Account of the target SQL Server to the SQL Server box I was running this stored procedure on and bum no more issue !

posted @ Tuesday, June 30, 2009 3:09 PM | Feedback (0)
CREATE ASSEMBLY Failed Error

I was doing some new CLR Stored Procedures in SQL Server 2005 and at a certain point received error:

CREATE ASSEMBLY failed because method 'MyMethod' on type 'StoredProcedures'
in safe assembly 'MyAssembly' is storing to a static field. Storing to a static field is not allowed in safe assemblies.

Interestingly, despite all the procedures inside SQL CLR stored procedures have to be declared as static, no static fields are allowed outside them. So in my case declaring a static variable outside SqlProcedure.

[Microsoft.SqlServer.Server.SqlProcedure]

attribute caused this error.

So if you really want to share state outside stored procedures using SQL Server 2005 you will need to be creative.

In SQL Server 2008 this can be done using table variables.

posted @ Tuesday, June 30, 2009 2:59 PM | Feedback (0)
Monday, May 04, 2009
Developing With Velocity CTP3

Developing With Velocity - Phase II

In my limited testing environment I have decided to try only the basic sample of MS Velocity found in CTP2 Samples, and what I thought would be the most often used properties of Velocity.

By default, the Velocity's DistributedCache service after the installation is not running and is set to manual start, so to begin working with it you will need to launch it. This can be done using the admin PowerShell applet or by starting the Microsoft project code named “Velocity” Windows Service. I opted for using the PowerShell Administration tool. To use it double-click the icon of the admin tool and type in Start-CacheCluster. You must see a success message in the following form:

Velocity Start

The service status column displaying word UP means the DistributedCache is running. If you have changed the default port then it is time to memorize it now before starting coding.

At this point one may want to review the settings of the Distributed Cache. To do so issue a Get-CacheConfig command and a window will populate with the basic configuration settings:

If you wondered what High/Low Watermark parameter means, it is a memory consumption threshold. This has to do with the eviction process of cached objects. Let's leave it out for now, but this is an interesting item to explore.

Now let's get our feet wet! To code against the DistributedCache one needs VS2008 and .NET 3.5 installed. Well, I would like to tell you right here that the CTP2 samples are not running out of the box with MS Velocity CTP3.

But do not get disappointed, I needed about 30 minutes to skim through the code and apply all the necessary changes to make the sample working. Besides, I can share my updated version of the SampleTest on demand with whoever does not wish spend time editing the code sample. The important thing that the help file accompanying CTP3 outlines all the changes between the two CTPs. This file is also very helpful in understanding the concepts behind and the base model of MS Velocity.

I guess any typical client app will require some preparations, so is in the sample, the first step is to configure the client.

We do it by defining the Cache Server Endpoint 

DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];

//  Parameter 1 = host name
//  Parameter 2 = cache port number
//  Parameter 3 = cache service name
servers[0] = new DataCacheServerEndpoint("localhost", +
             22233, "DistributedCacheService");

and create the cache factory

//Pass configuration settings to cacheFactory constructor
myCacheFactory = new DataCacheFactory(servers,false, true);

False is used here to specify that it is not a routing client and true is for using local cache.

The last step is to add the reference to the cache like that:

//Get reference to named cache called "NamedCache1"
myDefaultCache = myCacheFactory.GetCache("default");

Hooray, we are ready to run our sample tests!

The SampleTest CTP2 is a console application, but it is enough to provide one with enough information on the capabilities and get the sense of power the MS Velocity has to offer.

There is a number of tests that will be executed in a manner as displayed at the very top image. The code for the very first test looks like this:

I hope I encouraged you to explore Velocity further and do your own experiments.

posted @ Monday, May 04, 2009 3:27 PM | Feedback (0)
Friday, May 01, 2009
Velocity - Installation Phase

Velocity - Installation Phase

Today I have proceeded with the installation of the MS Velocity CTP3.

I would like to mention that first one needs to verify one's system for prerequisites. Basically the most up to date components as a Service Pack of the Windows OS and the latest .Net Framework are needed, also PowerShell 1.0 is a required component because the administration can be later done using PowerShell applets.

I also recommend reading the velocity_help.chm file that can be downloaded separately. It includes very valuable information on the ways of installing the product. It helped me to understand the concepts of the implementation and make decisions about how I want Velocity configured in my environment.

Because my goal was to experiment with Velocity and because it was a CTP I have decided to install it and its shared cache on my computer locally using the Folder Share mode. By the way it is a very acceptable scenario for a production system too.

I have made a folder of my choice shared accepting the defaults and without doing any special security settings. Need to note here that the setup will add the Network Service to it allowing change and read operations.

The actual download was actually small so in a few seconds I was presented with the setup screen and asked to fill in the basic info as the project installation location.

Overall, the installation tool is very intuitive, so one should feel comfortable about the whole setup process.

Next, I was asked by the Windows Firewall if to allow communicating with the Velocity instance and I agreed.

Then, while the main installation window continued running, a Cache Host Configuration screen (above) popped up that contained initial set up information parameters. I have changed the settings to reflect my choice. One small side note I would like to mention: if you are installing on a local machine to a shared folder you will need to type the path to it in as UNC path.

Next I was able to test the settings and name my cluster instance. At this stage I saw two MS SQL Server Compact databases named ClusterConfig.sdf and ConfigStore.sdf created in the shared folder.

I was able to see the final success message on the installer tool and a shortcut put onto the Desktop leading to the PowesShell based Administration tool for Microsoft Distributed Cache.

That's it, I am ready to test the waters!


posted @ Friday, May 01, 2009 10:55 AM | Feedback (0)
Thursday, April 30, 2009
MS Project Code Named "Velocity"

Here at work we have recently came to a need to share lots of data between a large amount of data consumers.

The data share had to be highly available, reliable, yet fast and simple to access.

Without thinking twice creating a database looked like an option. However, given the complexity it adds to maintain yet another database and the costs associated we rushed ourselves to a quest of seeking for alternatives.

While some were poking around the Web I reached out to Scott Hanselman who instantly suggested we use Velocity and who also had a Podcast on it back in June 2008. Besides, since then the Microsoft's project has advanced to CTP3 stage and seems like it is nearing the RTM.

As per the MSDN, Velocity is an implementation of a "highly scalable in-memory application cache for all kinds of data".

At first I murmured to myself, why another if we already have the in-memory caching capabilities with .Net Enterprise Library Caching Block?

Well, nothing is all that simple, it turned out, Velocity has a number of superior features. To me most notable are:

  • Auto-balancing
  • Access to cache is simple, any CLR object can be used to put inside it
  • Can be part of a database (clustered) or in a folder share or even in embedded mode
  • Can work with ASP.NET
  • Concurency model includes pessimistic or optimistic conflict resolution
  • Nearly any programming language can be used to develop with Velocity
  • Can be implemented probably on several dozen servers, thus providing enormous redundancy and scalability

This array (besides, it is only a subset) of features looks very impressive to me and wet my appetite to try the product out.

For most recent news or changes I suggest you refer to the team's blog at http://blogs.msdn.com/velocity/

The product has an active forum at http://social.msdn.microsoft.com/forums/en-US/velocity/threads/

I would recommend architects or lead developers to get yourself familiar with the forthcoming product.

I would download the latest CTP to try to experiment with it, time permits, and report back to you how does it feel like working with Velocity.

 

 

posted @ Thursday, April 30, 2009 2:59 PM | Feedback (1)
Sunday, April 26, 2009
Toronto Code Camp 2009 - Was There
Code Camp 2009

Toronto Code Camp 2009

It was my second attendance of the Toronto Code Camp and it is another success.

As you can see on the left we also had lots of fun, on the picture Joey deVilla who's blog I am reading regularly came to cheer the audience up, he was singing Britney's "One more time" with his accordion!

This event is always free and never happens during work week, lunch is also provided which makes it a great opportunity to spend some time and get some "fresh [development] air".

I have especially enjoyed the presentation by Kristina Mandekic on ADO.NET Data Services, I am looking forward to implementing this technology at work.

For those who did not attend or missed a presentation - stay tuned and visit the Toronto Code Camp's website some time later to get the video-casts of the material presented.

posted @ Sunday, April 26, 2009 4:04 PM | Feedback (0)
Thursday, April 23, 2009
Let's Jaiku!

Everyone knows what Twitter is today. Has anybody heard of Jaiku? Well, me neither, until today!

Apparently Twitter got competition. My cursory look revealed that Jaiku is more feature reach and options laden than Twitter.

Jaiku is operated by Google, so if you already have GMail getting in contact with your friends is a breeze. Additionally, anyone can operate its engine (JaikuEngine) and it is Open Source (sweet)! Go to http://tinyurl.com/awkpcf for more info.

Just go and explore it or join me on Jaiku http://arthurz.jaiku.com/

 

Cheers!

posted @ Thursday, April 23, 2009 11:56 PM | Feedback (0)
Thursday, March 26, 2009
The Adorable HippoEdit

The Adorable HippoEdit

Not so long time ago, just out of my curiosity, I downloaded off Giveaway of the Day an new editor called HippoEdit for me to experiment.

Besides, I am always on the look for new tools and utilities, and it will be needless to say I like all kind of software especially that gives me a fresh, new look at the old things. Some stay with me forever and some I let go sooner or later. But I feel every program or application contributed something, at times it could be good design I may recall about when implementing something for my job.

Frankly, I was mostly driven by desire to replace one or more of my old friends - editors I was not satisfied with any more, and believe me, a have accumulated more than a few. So my criteria were very tough to pass.

To my astonishment HippoEdit was sharp from the day its cute smiley icon appeared on my desktop!

Well, my first and the strongest impression to date - it is the smartest, most extendible and fun to use editor.

Here I will tell you why:

Despite its icon's jolly image and look do not let yourself be fooled - HippoEdit is extremely powerful.

Its main target audience is software developers and database administrators with support to most modern and even rare programming languages, to name a few, and I think I have not seen any editor for MS Windows with support for ABAP, Pascal, Cobol, etc. I am no talking about code folding, project support, a very neat syntax highlighting, custom code templates, colored file tabs, 2 way bookmarking system, RegEx searches, seamless web browsing, external tools support, a powerful search engine, support for various encoding and lots more, all in all, to me, it blows most free and many other commercial editors.

Here is how HippoEdit editing session looks like on my laptop:

I would encourage you to take it for a test drive!

The HippoEdit has an active forum where anyone can contribute to the Editor or ask a question.

The moderators are very knowledgeable, polite and always reply in nearly no time .

I have several suggestions to the creators and strongly believe features as Spell Checker and a Macro Engine are a must for today's Editor and they will appear soon.

posted @ Thursday, March 26, 2009 2:58 PM | Feedback (0)
Sunday, February 22, 2009
Launching an Arbitrary VBScript From Within MSI Package

Recently I was given a task of building an MSI package that among other things needed to include a VBScript in it. The VBScript would run at the end of the installation process.
Because I used to build install packages on and off in the past that also included various VBScripts I did not think twice, simply rolled up my sleeves and started a new Setup project in Visual Studio.
While doing an initial build I noticed that it is not so easy to incorporate some advanced features into the project as chaining other MSI packages, starting and stopping services, creating environmental variables, etc.
Finally, to my disappointment, I could not get the VBScript executed at the end of my installation package!
An error about VBScript not being able to run popped up.
What a surprise, I was tempted to blame the Visual Studio for that failure and simply decided to switch to another install tool to try.
Although this time I wanted the luxury of having a tool easy to work with that would have the features I needed and also flexible enough. After some digging into the Internet I was able to find an excellent alternative from wItem Installer2Go.
Alas, after building an MSI package this time five times as fast with it I received the same result. The script would not run!
I started to suspect something is wrong with my script and did the installation with logging turned on via command line.
Well, the error was there it was can’t create object: WScript.Shell Hmm, I puzzled for a moment and scratched my head, I was sure I had successfully deployed several MSIs with a VBScript in them before.
After some research the issue became evident: You cannot use the WScript object in scripts that are called by MSIExec.
An excellent article is this at SpinnerSoftware or a discussion thread on the Microsoft's Communities website.
This does make sense to me, one cannot have a handle to WSH from MSI.
Well, the only positive outcome is I now have a very nice Installer at hand I will be using.

Update: Justed used another approach and it works. You can instead create an executable off the same, slightly modified VBScript (only a Sub Main procedure needs to be added), the tool I used is a freeware ScriptPad.

posted @ Sunday, February 22, 2009 7:11 PM | Feedback (0)
Tuesday, February 17, 2009
Forcing MSI Installation Into a Specific Directory
Yesterday I was doing an upgrade to a product and I needed to install it into the path where the old version used to be. I only needed to figure out what install option I need.
 
I knew MS Installer supports a vast number of command line options, I hoped that it will be easy to find the correct one, but looking into the MSDN’s help did not help finding the necessary Public Property right away, it simply was not immediately obvious.
So I tried one property then another and finally in frustration decided to turn on the logging to see what the MSI package is doing when I change the default destination path.
Examining the produced file immediately yielded results – bingo, the right property was very evident, buried in the middle of my install log - TARGETDIR. The rest was easy:
I created a custom command line install directive
msiexec /passive TARGETDIR="C:\MyTagretDirectory" /i MyProject.msi
And was able to get the desired path pre-populated!
 Install Path
In my case I did not want the user to interact with the installer and therefore added the /passive option which reduces the MS Installer GUI to merely a progress bar.
posted @ Tuesday, February 17, 2009 1:31 PM | Feedback (1)
News
Did you know you can create your own search engine with Google?