WTF Moment - 403 - Forbidden: Access is denied when browsing to Azure role inside Dev Environment

 Problem origin:

Installed a new Azure development platform using Win7, VS2010, SQL 2012 Express.  Installed latest Azure tools, and stopped .NET 4.5 installation midway...

Loaded the Azure project in VS, tried debugging. Debugger wouldn't attach.

Ran without debugger, browser loaded and ... 403.  WTF

Messed around with IIS settings and permission from Management console... didn't work.

Bang head on wall... look around some more... found this...

http://stackoverflow.com/questions/9472490/windows-azure-cant-start-locally

aspnet_regiis -I to the rescue...

Everything started working again :).

 

 

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:

Six Must Have Free Tools for BizTalk Developer

After getting my feet wet doing BizTalk development for about a year now, I found the following free tools quite useful during development / support lifecycle (Not necessarily in order of importance).

 

1. Fiddler

Very very useful to be able to monitor web traffic especially when integrating with WCF / Web Service endpoint.  Also useful when trying to figure out what’s going across the wire when prototyping web service call using a 3rd party web service API i.e. HP Trim, IBM Maximo, SunSystems Connect, etc.  Found it helpful when trying to determine the correct SOAP Action to bind to the port as well.  Used it to debug / monitor messages flying across the wire after deployment (act as a proxy to BizTalk web service / WCF endpoints).

 

2. SoapUI

Got introduced to this tool in the last couple projects.  Basically Fiddler can play this role as well, but I’ve found myself using this to create and save sample SOAP calls and see what’s coming back from web service call without having to manually intercept messages coming and going across the wire ala Fiddler.  If you know what message you want to send across and the endpoint it needs to go to, you can fake outgoing message from one system and send it directly to the next endpoint.  Found it quite useful when the source system is not quite ready yet to be integrated while you have to test the next part of the integration or the inbound system is unable to communicate to BizTalk for whatever reason in a support / testing scenario.

 

3. DanSharp XmlViewer

Quick way to get the right xpath given a sample XML file.  Otherwise you have to go through the XML schema in Visual Studio to figure this out.  Just load the sample XML, click on the node / attribute you are interested in and ouila, instant xpath.  You can test xpath modification as well to see what result you are going to get.  It has saved me a lot of headache trying to debug xml namespacing issue.

 

4. xsltcake

Awesome, I repeat… AWESOME, online tool to create and test XSL transformation ala jsfiddle / jsbin (similar tools for quick prototyping JavaScript and sharing them to the masses).  It even can do Microsoft inline scripting using inline C#, VB, etc. when you set the processor to .NET.  This has become my favorite free tool when I have to do custom XSLT mapping.

 

5. Windows Sysinternals DebugView

What can I say… this is just another awesome tool.  One thing that is a pain to do in BizTalk solution is debugging it, so put a lot.. I mean A LOT of System.Diagnostics.Trace (TraceInfo / TraceError) statements in your expression shapes in the orchestration / custom components and see it light up inside DebugView to see what’s actually going on in your BizTalk application.  LIFESAVER in UAT / production environment!!

 

6. find (Windows built in command line tool)

Hmm… couldn’t find the technet / msdn article on this, but…  This is a tool that you can use to quickly figure out if a particular message goes through a BizTalk “debug/audit” ports.  Trick is to actually save the messages you wish to audit (just subscribe to the port or build it into your orchestration).  Hook it up to File Receive Location and when you need to find a particular message having a certain text in it, fire up command prompt, go to the directory where you store your audit files and launch this. I.e. find /N “<InvoiceID>12934</InvoiceId>” *.xml | more.

 

There you have it…  Did I mention they are all free?  So… just use them and enjoy.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Hello, Windows 8 :)

Decided to try an in-place upgrade from Windows 7 to Windows 8 RTM last night.   Mounted the ISO file and started the installation.  Decided to just migrate my personal files.  After a few reboots that happened probably over 15 minutes it was done.  Everything was in order and all good to go.

Installed some free apps from the Windows Marketplace and from what I've seen so far, I'm happy with the new OS and how it behave on bare metal.  Too bad there isn't any touch capability on the machine that I decided to put it on.  Would love to see how that will behave.

To be honest, I've been frequenting JB-HIFI stores (similar to Best Buy for those who doesn't know what I am talking about) and a bit disappointed that none of the current laptop offerings including the newer thinner notebooks are sporting any touch interface.  I guess I'll just have to wait a bit more time till Surface is out to try this.  At the price point of USD 299 to start (if rumor is right) I think I might just try and get one.

Oh, I'll take back my previous comment on how Win8 was booting slow.  I am quite please to see that when booting off bare metal it IS a lot faster than 7 on my 500 gig spinning metal of death, hehehe.  I guess it was the VHD overhead after all.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:

Booting Windows 8 from Existing VirtualBox VHD from existing Windows 7.

You probably already know that you can boot off VHD from Windows 7.  If you don't, it's about time you learn it.  It's a very neat feature.

You also probably seen blog posts on how to install and boot Windows 8 from VHD (such as this one from @hanselman).

As everyone else that doesn't actually have tons of machines lying around to try Windows 8 and does not want to lose the current OS installation, you probably been playing around with Windows 8 in a virtualized environment such as VirtualBox.  And if you do,you probably know that you can have a virtual hard drive in VHD format when you create your virtual machine.

Hmm...

  • so, Windows 7 can boot VHD...
  • and VirtualBox can create VHD...
  • and I already have a Windows 8 virtual machine that is stored in VHD format in VirtualBox. 

Hey!! Why don't I just boot it up from THAT??!! Big Smile

Well, ... of course you can!

But... what the heck for... you can just create VHD in Windows 7 using diskpart utility and mount it and burn Win8 iso to USB stick and make it bootable (if you can find a large enough one around) or a bootable DVD (who the heck does this nowadays?).

See..

  • I have VirtualBox already (I did mentioned this, right?). 
  • It's easy enough to create VHD and install Win8 (doesn't matter if it is developer or consumer or release preview or ...) from the ISO in VirtualBox. (I always use VHD format since it is portable between multiple VM platforms anyway.)
  • It's probably the first thing that you would do anyway when wanting to try the new and shiny things in any OS (install it in a virtual platform and play around with it).
  • Now that I've done all this... why not reuse the VHD?  No reason not to.

But... what happen to all my device configurations? See... in VirtualBox, my network driver, my sound driver, my display driver, etc. are bound to specific virtualized drivers.  If I boot from that VHD wouldn't Windows 8 be screwed up?

Well, from what I have running so far, it doesn't seem to be.  The first time it booted from the VHD, it looks like Windows 8 reconfigures the devices anyway so when I am booted up, I see my real hardwares from the Device Manager.  So, no worry there.

Neat... so... what do I do know if I want to do this?

You only need 3 steps.

Step 1.  Detach the VHD from VirtualBox and remove it and release it from VirtualBox Virtual Media Manager.  

(You might not need to do this, but this is what I did just to prevent unwanted side effects, just in case).

Remove and release... hmm.. how the heck do I that?

Sigh... Select the Windows 8 VM from inside VirtualBox Manager, bring up the Settings for it, then on Storage, select the VHD from the attached controller, and click the Remove Attachment icon at the bottom of the Storage Tree pane to remove the VHD.

To release the media from VirtualBox, open the Virtual Media Manager by going back to VirtualBox Manager, click Ctrl-D or choose File, Virtual Media Manager from the menu.  From the Hard Disks tab, choose the Windows 8 VHD and click the Release icon near the top.

Step 2. Mount the VHD natively in Windows 7 using Disk Manager and mark it active.

... Don't know how to this too?... Fine...

Open up Computer Management by typing this cryptic string into your Start menu search bar: diskmgmt.msc and press Enter.

Click the Action menu, and choose Attach VHD and choose the Windows 8 VHD that you just released from step 1. DO NOT make it Read only!

(I might be wrong here, but I've read this somewhere and it worked for me.  You might not need to do the following....)

After you've done this, you should see the VHD as a disk in the center lower pane.  I think Windows will also assign specific drive letter to it.  You might have 2 partitions off the same virtual disk... now, this is the tricky part... you need to mark the one w/ the new Windows 8 OS active.  You can do this by judging the size of the partition or a safer way is to browse your new drives and see which one it is.  It should have a Windows folder from the root drive when you open it in Explorer.  Say... you have 2 more new drives after you mount the VHD, say drive D and drive E.  Browse those drives and see which one has Windows directory.  That's the one you want to make active.

To mark the partition as active, just right click on it from the Disk Management lower center pane and choose Mark partition as Active.

But... but... I want to see nice pretty pictures of what I should click...

Bah... no pretty picture for you... I am too lazy to do screen capture this early in the morning, hahaha.  Figure it out.  Frankly, if you don't know how to do this, you shouldn't be doing this anyway.  You might screw up your machine and cry like a baby aferward. Big Smile

Bah... I am l33t enough, I want to do this using diskpart!!

You silly, silly person... why choose command line when there is a simple GUI for it... sigh.  Do what you wish.  There should be enough blog posts out there to explain this.  @hanselman post above is a good starting point. 

Step 3. Add boot entry to the boot loader using bcdboot.

OK... remember what drive you seen the Windows installation before in step 2?  You need to add that to the boot loader.

Getting too lazy to explain, hehehe.  Uhm... just follow the section called Add a Mapped VHD to Your Boot Menu in this blog post.

There... done.  Now you can reboot your machine, the new graphical boot loader should comes up and will let you boot Windows 8 from the attached VHD.  It will take a while the first time you boot into Windows 8 since it will try to reconfigure all the new found hardwares.

Enjoy your new shiny, fast and fluid thing.

Speaking about fast... People in the podcasts I listen to keep saying WOW, look how fast Win8 boot up... uhm... how come I don't see that.   Maybe they are too freaking rich and have SSD for their boot drive... or is it the VHD thing that's making it slow... shrug.  Still take a bit of time for me to boot up Win8 from my spinning metal of death 500 gig laptop hard drive.  Frankly my Win7 installation boot faster but... whatever.  LOL.

Share this post: | | | |

I got Windows 8. Goodbye 3rd party virtualization?

Finally, Hyper-V is coming to Windows client and not just server.  For a long time I have to use 3rd party products such as VirtualBox, which is very nice, or VMWare Workstation, etc. to run my 64 bit VMs or dual boot to Windows Server instance to try out Hyper-V.  Guess it's no longer required since Hyper-V will be built-in to Windows client itself.

Mounting VHD is also easier to do in Win8 (at least from what I've seen in the keynote).

Another cool thing is mounting ISO is also easier now and built-in to the OS.

 Awesome!! :)

Share this post: | | | |

How to call SharePoint Web Service with Specific Credential from Silverlight OOB

 

The Problem

While playing around with SharePoint web service from Silverlight out of browser, I bumped into web service proxy limitation where I am forced to authenticate no matter what I pass to the ClientCredential.UserName property of the web service client proxy.

//This does not work... will get authentication prompt
var request = HttpWebRequest.Create(uri);
request.ClientCredential.UserName.UserName = "DOMAIN\\user1";
request.ClientCredential.UserName.Password = "password";
 

The Authentication Problem Workaround

Luckily, starting from Silverlight 3 up, you can use the ClientHttp object that allows passing specific credential for the web request.

//This now work wonderfully from Out of Browser Silverlight 3 or up
var request = WebRequestCreator.ClientHttp.Create(new Uri("http://localhost/_vti_bin/lists.asmx", UriKind.Absolute));

//This is required, or otherwise you will be prompted for authentication
//It basically said, no don't use the current login, I'll tell you what login to use later.
request.UseDefaultCredential = false

//Pass your credential here...
request.Credentials = new NetworkCredential("user1", "password", "DOMAIN");

Ouila! Authentication problem solved.  Bye bye authentication prompt.  See you later... or not.

What About My Web Service?

Now... for the second problem, without the nicely generated web service proxy, how the heck am I going to call my web service method?

Well, luckily, SharePoint and other web service for that matter, give you a neat example of what to pass in a SOAP message like so:

if you put something like http://localhost/_vti_bin/lists.asmx into your browser Address (URL) field, you'll get this:

image

In this case, I am interested in adding a list item to one of my SharePoint list.  The method (SOAP action) for this is UpdateListItems.  If you don't believe me, see this.

So if you click the UpdateListItems from the nice list above, you'll get this:
image

See that SOAP message example (in particular the top one which is a SOAP 1.1 request message)?
Yeah it's a bit ugly, but trust me underneath the nicely generated web service proxy that you usually get when adding a service reference, you'll see this message somewhere in there if you open up the generated proxy client code in one shape or form. 

<digress>Actually if you look inside the generated proxy inside Reflector or similar tool like ILSpy for those who don't want to pay for Reflector, you'll see the serializable form of this as class and class members which later on will be serialized into
the XML format that you see above. </digress>

Well, like it or not, you will need to create your own web service wrapper around the SOAP message.  The good thing is... it's not that hard.

Below is a bit of code that I whipped out and refactored in about 2 hours to do this (for now only the UpdateListItems is implemented plus the rest of SOAP Web Service infrastructure):

using System;
using System.IO;
using System.Net;
using System.Linq;
using System.Xml.Linq;
using System.Net.Browser;
 
namespace SilverlightApplication9
{
    public class SharePointWebService
    {
        static XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
        static XNamespace xsd = "http://www.w3.org/2001/XMLSchema";
        static XNamespace soap = "http://schemas.xmlsoap.org/soap/envelope/";
        static XNamespace sharepoint = "http://schemas.microsoft.com/sharepoint/soap/";
 
        XElement SoapEnvelopeTemplate;
        Uri WebServiceUri;
        NetworkCredential Credential;
 
        public SharePointWebService(Uri spWebServiceUri, NetworkCredential credential)
        {
            WebServiceUri = spWebServiceUri;
            Credential = credential;
 
            SoapEnvelopeTemplate = new XElement(soap + "Envelope",
            new XAttribute(XNamespace.Xmlns + "xsi", xsi),
            new XAttribute(XNamespace.Xmlns + "xsd", xsd),
            new XAttribute(XNamespace.Xmlns + "soap", soap),
            new XElement(soap + "Body"));
        }
 
        public void UpdateListItemsAsync(string listName, XElement updates, Action<XDocument> callback)
        {
            var message = CreateUpdateListItemsMessage(listName, updates);
 
            SoapActionInvokeAsync(
                "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems",
                message,
                callback);
        }
 
        protected void SoapActionInvokeAsync(string soapAction, XElement soapMessage, Action<XDocument> callback)
        {
            WebRequest request = WebRequestCreator.ClientHttp.Create(WebServiceUri);
 
            if (Credential != null)
            {
                request.UseDefaultCredentials = false;
                request.Credentials = Credential;
            }
 
            request.Headers["SOAPAction"] = "\"" + soapAction + "\"";
            request.ContentType = "text/xml; charset=utf-8";
            request.Method = "POST";
 
            var message = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + soapMessage.ToString();
 
            request.BeginGetRequestStream((ar1) =>
            {
                using (var stream = request.EndGetRequestStream(ar1))
                {
                    using (var writer = new StreamWriter(stream))
                    {
                        writer.Write(message);
                    }
                }
 
                request.BeginGetResponse((ar2) =>
                {
                    XDocument xml = XDocument.Load(
                        request.EndGetResponse(ar2).GetResponseStream());
 
                    callback(xml);
                }, null);
            }, null);
        }
 
        public XElement CreateUpdateListItemsMessage(string listName, XElement updates)
        {
            EnsureSharePointNamespace(updates);
 
            var body = new XElement(sharepoint + "UpdateListItems",
                new XAttribute("xmlns", sharepoint),
                new XElement(sharepoint + "listName", listName),
                new XElement(sharepoint + "updates", updates));
 
            var envelope = XElement.Parse(SoapEnvelopeTemplate.ToString());
            envelope.Descendants(soap + "Body").First().Add(body);
 
            return envelope;
        }
 
        protected XElement EnsureSharePointNamespace(XElement el)
        {
            foreach (var e in el.DescendantsAndSelf())
            {
                e.Name = sharepoint.GetName(e.Name.LocalName);
            }
 
            return el;
        }
    }
}

And here is an example of how to use it from Silverlight:

           var ws = new SharePointWebService(
                new Uri("https://localhost/_vti_bin/lists.asmx", UriKind.Absolute),
                new NetworkCredential("user1", "password", "DOMAIN"));
 
            ws.UpdateListItemsAsync("jtest",
                XElement.Parse(@"<Batch><Method ID=""1"" Cmd=""New""><Field Name=""Title"">New item</Field></Method></Batch>"),
                (doc) =>
                {
                    Dispatcher.BeginInvoke(() =>
                    {
                        textBox1.Text = doc.ToString();
                    });
                });

 

This has been a pretty fun exercise... It would be better if the proxy ClientCredential code can do similar thing, but well... live sucks and that's why you are a coder, right?  

<digress>Some of you might be thinking what the hell the relation between live sucks and being a coder.... Don't worry, I don't know either, LOL.  Guess that's why this blog is called Incoherent Rambling... </digress>

Share this post: | | | |

How to Add a link in SharePoint 2010 that will launch InfoPath form template?

While playing around with SharePoint 2010, I want to add a link to my site home page that will do the same thing when I am in a particular document / form library and click the Add Document link. 

In other word, how can I launch Word or Excel or InfoPath from my own link without having to go inside the library and clicking Add Document?

At first, I couldn't figure out how to do this.  Decided to dive into the HTML source of the Form Library AllItems.aspx view and found a CoreInvoke JS method, like:

CoreInvoke('createNewDocumentWithProgIDEx', 'template source URI', event, 'save location URI', 'SharePoint.OpenXMLDocuments', true);

I plop that inside a link tag and it worked. 

After the fact, I look around the web and finally found someone else that has done this already...

See: http://www.sharepointkings.com/2010/02/create-new-document-link-in-listview.html

The syntax is something like: createNewDocumentWithProgID(templateSourceURI, saveLocation, docType, false);  

In my case, I want to launch an InfoPath form template, and I found the following work just fine:

createNewDocumentWithProgID('http://intranet/spike/FormLib1/Forms/template.xml', 'http://intranet/spike/FormLib1', 'SharePoint.OpenXMLDocuments', false);

 

Share this post: | | | |
Posted by Jimmy Chandra | with no comments

Coolest Feature of IE9 in My Opinion

Just want to link to Scott Hanselmann's blog post on Site Pinning and the cool things that you can do with it.  I think it's the coolest feature in IE9... graphic hardware acceleration, canvas support, improved javascript speed... PHHBTTT... seen it too many times, but this... is awesome ... or maybe not?  Well, I think it is anyhow Big Smile.

 http://www.hanselman.com/blog/IE9SiteSpecificBrowsersAndAddingYourOwnJumpListItemsToPinnedTabs.aspx

Check it out. 

Information that you will find:

  • How to add Jump List that is available from Windows 7 Pinned Site
  • Adding notification to the pinned site icon in the taskbar (Push Overlay)
  • Adding task bar buttons to the pinned site
Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Oh Nirvana... VirtualBox, Hyper-V VHD and Synergy

In my daily work, I am doing a lot of prototyping, testing, etc.  And for this, I lean heavily on virtualization to isolate my workstation versus the prototyping / testing environment and for its ability to quickly rollback to previous snapshot.

Currently, I configured my laptop to be a dual boot system (Windows 7 and Windows Server 2008 R2 w/ Hyper-V, both implemented as 40GB VHD in the actual harddisk).  I utilized Boot from VHD capability of Windows to do this, which is pretty sweet.

But I am getting tired of having to maintain 2 OS on the same box.  I am trying to get rid of W2K8R2 from my system since 99% of the time I am using Windows 7 anyhow.  But one thing kept preventing me from doing this... call it laziness or whatever you wish, but I use Hyper-V to run some precanned VHDs from Microsoft such as SharePoint 2010 demo which already has everything that I need.  I supposed the other reason for this is just to play around with Hyper-V so I understand the technology and can demonstrate them when needed.

The rest of my virtualized environment actually run in Windows 7 using VirtualBox which support 64-bit guest OS.  I like VirtualBox very much for what it can do; Not to mention it is also free.  So one pet peef that I had previously is I couldn't find a way to boot Hyper-V VHD from inside VirtualBox.  Virtual Server / VPC VHD runs just fine, but not Hyper-V one... weird.

Today, I decided to look around the web again, and finally came across this particular blog post... lo and behold... it is actually possible to do this.  The trick is just to not to use SATA to boot up the VHD, but rather to attach it to the IDE controller instead.  Curious, I tried to quickly create a VM inside VirtualBox and connect it to my existing Hyper-V SP2010-7a.vhd.  Boot it up and guess what... it runs :). YAY!!

So now... I need to decide whether to scrap the 40GB W2K8R2 VHD from my hard drive or not ... Hmmm...

Nothing against Hyper-V, but I just wish Hyper-V can run on top of Win7 so I don't have to do the OS switcheroos.  Most of my tools like Office, Outlook pst and ost, etc. are in my Win7 system.  It is such a hassle to maintain 2 different OS (patches, etc.) and the applications when I only use the other one 1% of the time.  And Virtual Server / VPC are not an option on Win7 since they can't run 64-bit guest OS which is needed for SharePoint 2010.

On a totally different thing, at home I like to use my work laptop as my server environment and actually do the work from my home laptop that is attached to a secondary monitor.  So I was thinking... wouldn't it be neat if I can use my home laptop keyboard and mouse to control my work laptop seamlessly... I am not talking about remoting to it since that will actually waste some screen space on my home laptop.  But rather, emulate a 3 screens environmment where my work laptop is the left most screen and my home laptop is the middle screen and the additional LCD for the right most screen.  One screen to browse, one screen to do some works like coding, and another one for other peripheral stuffs like TweetDeck or email or whatever.  It turns out you can do this... Found this piece of open source software (Synergy) that will allow you to do just that.  Cut and paste work just fine across machines and it work across multiple OS too (Windows, MacOS, and Linux).  Awesome.

So, with the new ability to run Hyper-V VHD inside VirtualBox and lots of screen estate and seamless control over my other computer screen using Synergy... I am a happy camper :).

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Finally!! Indonesian Mobile Developers Can Submit WP7 Application to the MarketPlace.

There are/were 2 things that bug me as an Indonesian in regard to Windows Phone 7.

  1.  From Indonesian consumer point of view... The ability to purchase application in Marketplace is basically non existant if you don't have the right credit card.  What I mean by the right credit card is a non Indonesian credit card. (If anyone know different, please let me know.)
  2. From Indonesian mobile developer point of view... The ability to submit WP7 application into the MarketPlace via AppHub was also non existant.  Again... the problem here is related to Indonesian credit card was not supported. (Note that I said... WAS) Big Smile

So, the good news... 

As developer (in Indonesia and other countries), it is now possible to participate in the Marketplace!! Yay!!  A Global Publisher Program was recently announced during TechEd Middle East in Dubai.  So what are you waiting for?  Go to Yalla Apps and register yourself and start making money.  For full news, see this blog post.

But wait... what about if I want to buy from Marketplace as consumer? ... Eh, basically it is still the same situation as before... You need a credit card that is allowed by Marketplace... It's very hard, but it is not entirely impossible.   But hey... at least you can hawk your stuffs online now!  Better 1/2 than nothing, right? Big Smile.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

The Best Deep Dive on jQuery Session

Well, maybe not the best, but it comes very close to it.  For sure, it's the FUNNEST time you can have while trying to understand jQuery internal and at the same time learn about some exotic things about JavaScript and browser DOM.

What I am talking about is the More Things I Learned from the jQuery Source videos by Paul Irish.

Trust me... If you are a JavaScript / jQuery geek, it is definitely worth the time to look at them.

Paul is quite a fun guy to watch and his explanation style kind of remind me of how Head First book series are written.

 Fun, Fun, Fun.

http://paulirish.com/2010/10-things-i-learned-from-the-jquery-source/

 http://paulirish.com/2011/11-more-things-i-learned-from-the-jquery-source/

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Move to the Cloud, Use the Cloud and Be a Cloud

As you might already know, there are 3 general types of cloud offerings out there.

  • Infrastructure as a Service (IaaS)
  • Platform as a Service (PaaS)
  • Software as a Service (SaaS)

Each gives you a different level of control and benefits.  I won't bother you with the detail on each.  It's not what this blog entry is about.  If you like to compare and contrast these offerings, see this.

A different perspective on the cloud offerings has been suggested to me:

  • Move to the cloud
  • Use the cloud
  • Be a cloud

Moving to the Cloud

Moving to the cloud is like outsourcing one more of your services such as e-mail, CRM, portal solution, and even some business productivity tools.  A lot of cloud players are playing in this field including Microsoft Office 365 and other Microsoft Online Services, third party / partner hosted services, Google docs, .and salesforce.com.

The benefits for this is you no longer need to maintain the infrastructure necessary for these "IT commodity" services, instead you can utilize your resources to do more strategic stuffs and let the cloud provider deals with the day-to-day administration.

The disadvantage for this is you might not have the ability to do full customization on top of the solution that you have outsourced since most of the time, the provider will configure the solution to run on multi-tenancy architecture that makes it a bit difficult to customize for a specific tenant.  Maybe, if you are lucky, and depending on your service level with the provider, you might be able to do this, but expect to treat this offerings the same way as shopping for cloths from a department store instead of going to the tailor to make a custom suit / dress.  You have your choices of colors and sizes and that's that.  No addditional pockets, replacing buttons, etc.

Use the Cloud

Think of this as not moving the entire solution to the cloud like in Move to the Cloud above, but rather, you still have something on-premise that is reaching out to the cloud for additional things.  Or your internal solutions are using some cloud services.   Seasonal business activities like internet campaign marketing / promotion can defintely take advantage of the public cloud services such as using Windows Azure or other platform like Google AppEngine as your workhorse during the promotional period by quickly adding the necessary computing power without the need to put down the huge capital cost for hardware up front.  The ability to pay as you go is definitely something to consider when you want to cut down the capital cost.  Once you are done with the seasonal activity, you don't need to worry about what to do with the extra computing capacity that won't be doing anything if you were to implement the solution in house using your own hardware (that you have to purchase up front).

Be a Cloud

A couple of example for this are a hosting business offering elastic computing based on private cloud technology or your company itself decided that you want to keep your data and computing power inside the company but still wants the elasticity that a cloud offering can provide.  A good scenario for considering this kind of solution is when your company or country you operate in has regulation that requires your data to stay within a certain physical boundary or you are considering being a cloud provider for others.  Another good case for this is when you have a cloud solution that you want to sell as a service (SaaS) to others.  With the right VM infrastructure and management solution, it is definitely possible to be a cloud.  An example of this is Microsoft Private Cloud solutions such as Hyper-V Cloud and Windows Azure Platfrom Appliance described here.  Another vendor that is also playing in this area is VMWare.

Things to Consider

Different level of IT maturity is required for operating in the cloud.  Before you can move to the cloud, your IT infrastructure, staff, and procedures must be at a certain level of maturity.  If you are putting out fire most of the time, you are probably not ready to move yet.  How easy you can integrate your internal IT systems such as security & identity with the cloud offering is another thing that you might want to consider before making your move. 

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:

How to Change the Active Printer to Specific Printer in Excel Using .NET and How the Heck Can I Find the Right Printer Name and Port Combination that Excel Wants?

A client of mine was having a problem trying to automate Excel to print to a specific (non default) printer.  They know which printer they want to use, but are having trouble trying to get Excel to understand it.

Excel’s Application.ActivePrinter property is quite picky about what it will accept.  The right pattern to feed to the property is something like PrinterName on PortName:.

For example, if you want to print to Microsoft XPS Document Writer, you need to do something like this:

var excel = new Excel.Application();
var workbook = excel.Workbooks.Open("....");
var worksheet = workbook.ActiveSheet;

excel.ActivePrinter = “Microsoft XPS Document Writer on ne01:”;
worksheet.PrintOut();

excel.Quit();

And this of course assuming that the selected printer (Microsoft XPS Document Writer) is on port ne01.

Getting the right name for the printer is somewhat trivial.  You can poke around the Devices and Printers control panel item on Windows and see their name.

The problem is… the port name information is not so obvious to find.

So, how would you know where to get the port name?

Trying to enumerate the attached printers as described by this StackOverflow question does not gives you the right port name… See the sample code and output below…

The Code:

using System;
using System.Management;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var oquery = new ObjectQuery("SELECT * FROM Win32_Printer");
            var mosearcher = new ManagementObjectSearcher(oquery);
            var moc = mosearcher.Get();            

            foreach (var o in moc)
            {
                var pdc = o.Properties;

                foreach (var p in pdc)
                {
                    if (p.Name == "Name" || p.Name == "PortName")
                    {

                        Console.WriteLine("{0}: {1}", p.Name, o[p.Name]);
                    }
                }
            }
        }
    }
}

The result:

Name: Xerox WorkCentre 3119 Series
PortName: USB001
Name: Send To OneNote 2010
PortName: nul:
Name: Microsoft XPS Document Writer
PortName: XPSPort:
Name: CAMPUS-R101-DC236
PortName: 192.168.100.21
Name: CAMPUS-R217-DC236
PortName: 192.168.100.22
Name: Fax
PortName: SHRFAX:
Name: \\TIGER\Canon Inkjet MP140 series
PortName: USB001

You just have to trust me the port name here is not the port name that Excel wants to use.

So, where else can you get this particular information?

After looking around the web, I found this post that gives some clues on how to do this from VBA that can easily be adapted for .NET.

It turns out that the key to this is to poke around in the registry. in particular HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices.

So I came up with the code below to test it and lo and behold.  It works perfectly.  Basically I enumerate through all the devices in that particular registry location, did some string manipulation on the port (remove the winspool, prefix from the port name) and concatenate the stripped version of the port name with the printer / device name to form the PrinterName on PortName: combination that is required by Excel.

using System;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using Excel = Microsoft.Office.Interop.Excel;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var excelApp = new Excel.Application();
            excelApp.Visible = true;

            var workbook = excelApp.Workbooks.Add();
            var worksheet = workbook.ActiveSheet;

            var key = Registry.CurrentUser;
            var subkey = key.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Devices");

            var printerNames = subkey.GetValueNames();

            //Should be able to complete this loop without throwing an exception
            //if all the names matches to what Excel is expecting.
            foreach (var printerName in printerNames)
            {
                var excelPrinterName = ConvertToExcelPrinterFriendlyName(printerName);
                Console.WriteLine(excelPrinterName);

                excelApp.ActivePrinter = excelPrinterName;
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Marshal.FinalReleaseComObject(worksheet);

            workbook.Close(false);
            Marshal.FinalReleaseComObject(workbook);

            excelApp.Quit();
            Marshal.FinalReleaseComObject(excelApp);
        }

        public static string ConvertToExcelPrinterFriendlyName(string printerName)
        {
            var key = Registry.CurrentUser;
            var subkey = key.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Devices");

            var value = subkey.GetValue(printerName);
            if (value == null) throw new Exception(string.Format("Device not found: {0}", printerName));

            var portName = value.ToString().Substring(9);  //strip away the winspool, 
 
            return string.Format("{0} on {1}", printerName, portName);;
        }
    }
}

Hope this is useful for those who need it… Enjoy.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

How come System.Web.Extensions.dll cannot be found in the Add Reference dialog?

I was perusing stackoverflow.com questions and came upon a question regarding JavaScriptSerializer that I found quite interesting.  I decided to do a quick spike in Visual Studio to find out if I can get answer for the question.  Fired up Visual Studio 2010, created a new Console Application and tried to instantiate a JavaScriptSerializer in my code, but of course, the IDE did not recognize JavaScriptSerializer since I haven't added a reference to the necessary assembly.  In trying to fix that, I launched the Add Reference dialog and chose the .NET tab and scrolled down... and guess what.... no System.Web.Extensions... hmmm...

 Thinking the problem through I know System.Web.Extensions is part of .NET 4 (which was installed when I installed VS 2010), so how come it is not available in the Add Reference dialog?

 After a bit more thinking I came to realize that it's probably because Console Application is targetting the .NET Framework 4 Client Profile which does not include all the web stuffs in it.  Switching the Target framework to .NET Framework 4 (Full profile) from the Project Property, Application tab, solved the problem.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:

"Unable to load client print control" on SQL Server 2008 SP 2 SSRS

Ran into this problem with a client of mine.

Symptom:

Platform:

  • server: SQL Server 2008 Service Pack 2
  • client: Windows XP x86

Causes:

  • Insufficient user permission 
  • Potential bug introduced in SQL Server 2008 SP 2?

Working Remedy:

  • Deploying the RSClientPrint-x86.cab from SQL Server 2008 R2 to the client machine fixed the problem.

References:

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:
More Posts Next page »