Sony Arouje

a programmer's log

Proxy generation tool for Silverlight (SLSvcUtil.exe) and modify VS Command prompt Path variables

with 2 comments

In this blog I am going to explain how to generate web service proxy for silverlight and how to add a new Path to VS 2010 Command Prompt (it might be similar for other version of VS, you all can try it out).

In my Silverlight project I wanted to create a proxy of my wcf service, as usual I asked svcutil to create the proxy for me. To my surprise after adding the generated proxy, my silverlight app is not compiling and started throwing errors like IExtensibleDataObject is not exist in System.Runtime.Serialization……. I couldn’t proceed further and at last prayed to google (to developers google is like a god 🙂 ). Bingo got one post mentioning about a util called SLSvcUtil.exe, available from SL3 onwards, poor me I was not aware of this new guy. I got what I wanted. I could locate SLSvcUtil.exe in C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools. I used this new tool and every thing worked well. I am relaxed.

After some time another issue started annoying me was VS 2010 command prompt was not recognizing slsvcutil.exe as a command. I added the SL tools path to the windows environment variable and restarted the machine but no use. My new path is not accepting automatically, The only way to add my path is the dos approach. Type the below command in the VS Command prompt.

path=%path%;C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools

I know that it will be stored until my machine reboot. As a developer I need a solution to this, because I may use SLSvcUtil more frequently and adding the path all the time will not work out. As it’s a command prompt so guessed that it will be wrapper to dos command prompt and some one is setting him the paths while opening it. I checked the properties of my VS 2010 command prompt and saw that target is %comspec% /k “”C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat”” x86. I was happy that VS command prompt is getting called from a batch file, so that I can set my path their. I open vcvarsall.bat and figured out that It’s calling other batch files based on your processor. The file content is below


@echo off
if “%1” == “” goto x86
if not “%2” == “” goto usage

if /i %1 == x86       goto x86
if /i %1 == amd64     goto amd64
if /i %1 == x64       goto amd64
if /i %1 == ia64      goto ia64
if /i %1 == x86_amd64 goto x86_amd64
if /i %1 == x86_ia64  goto x86_ia64
goto usage

if not exist “%~dp0bin\vcvars32.bat” goto missing
call “%~dp0bin\vcvars32.bat”
goto :eof

if not exist “%~dp0bin\amd64\vcvars64.bat” goto missing
call “%~dp0bin\amd64\vcvars64.bat”
goto :eof





As mine is a x86 32 bit processor so I have to look for vcvars32.bat. With a calculated guess I open the Bin subfolder. I was right the file vcvars32.bat was their in the Bin folder. With a quick glance of vcvars32.bat I could make out that he is the guy I was searching. I edited vcvars32.bat and updated my path as shown below

@set PATH=C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools;%PATH%

I reopened my Command prompt window and typle SLsvcUtil.exe…. it worked. Now I don’t want to worry about setting the path when ever I do a machine reboot.


2 Responses

Subscribe to comments with RSS.

  1. This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

    generika apotheke

    November 8, 2010 at 8:03 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: