A Place for C Sharpers/.Netters

I Will do coding till last moment of life-Kiran Patil

Access Internet/Local Website from Your Windows Mobile Device Emulators

Posted by kiranpatils on November 19, 2009

Challenge

If you want to access any website Or You want your locally developed mobile application/web application to be viewed in Windows Device Emulator then you are at the right post.

Solution
  1. Download ActiveSync and install on your local machine where you would like to run Emulator. How to setup ActiveSync?
  2. Open Visual Studio and click on Tools | Connect to Device:

clip_image002

  1. Select Device emulator to run and say connect.

clip_image004

  1. It will open your device emulator:

clip_image006

  1. Verify that ActiveSync is up and running by its symbol in Notification Area.

clip_image008

  1. Open Device Emulator Manager

clip_image010

  1. Currently running Device Emulator Manager will be shown in Green.

clip_image012

  1. Right click and say “Cradle”

clip_image014

  1. As you click on Cradle ActiveSync window will popup. Select Guest Partnership[Or better do cancel it will by default to Guest Mode]. If your Emulator got synced with ActiveSync then Notification Icon will go Green.
  1. Now you are ready to access website.
    1. Internet – Enter your URL.

clip_image016

    1. Local – To Access your Local Website which is running on Cassini(Development Web Server). To access it you need to access it by IP ADDRESS:PORTNUMBER. Please note that you can’t access it by localhost:PORTNO Because localhost points to Emulator’s localhost and it will never go to your machine. You have to see both Emulator and your local machine as a two different devices even though they are running on same machine.

clip_image018

If this blog helped you. Say a big thanks to my friends who always give me a shout whenever they found something challenging like this and inspire me to learn a new things which finally inspires me to pen down on my blog and share with you :)

Happy Emulating!

Webliography

Setup ActiveSync

Nice blog – Thanks to this blog

If you have Windows Vista or Later

Accessing Device Emulator Without ActiveSync

Feedback

Posted in ASP.NET, Windows Mobile | Tagged: , , | Leave a Comment »

Delivering Multimedia

Posted by kiranpatils on November 16, 2009

Now a days I’ve started preparing for my next Microsoft Certification exam 70-547. And it’s going on really well as i am learning the things which i was knowing but now i am coming in to know the PRO. use of it.

Anyways today i am going to show you how you can deliver Multimedia on your website. Because in this era everyone needs to have it :)

But before we delve in coding part which we all developers love to do. Let’s take a look at some basic things which is good to know.

Non-Streaming :- The Audi/Video files must be downloaded completely before playback can begin.

Non-Streaming Audio Formats are waveform(.wav), sound(.snd), Unix Audio(.au), Audio Interchange File format(.aif.aiff,.aifc)

Non-Streaming Video Formats are Audio-Video Interleaved(.avi)

Streaming :- The Audi/Video files can started playback and files keep downloading itself in background. This one gives better user experience.

Streaming Audio Formats are Moving Pictures Experts Group standard 1, Layer 1,2,3 (.mpa,.mp2,.mp3), Windows Media Audio(.wma)

Streaming Video Formats are Moving Pictures Experts Group standard 1 (.mpg,.mpeg,.mpv,.mpe), Windows Media Video (.wmv)

Hooh..too much theory. Let’s start how we can deliver multimedia on our page.

There are two ways of doing this:

1. Embedded Playback : you can embed Windows Media Player on your page directly. But client should have installed Windows Media Player on his/her computer to view your multimedia files.

The code looks like as below:

<div class="csharpcode"><html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
 <title>MultiMedia Page</title>

 <script type="text/javascript" language="javascript">
 function StartPlayer()
 {
 //Using DOM play your MultiMedia File
 document.player1.URL = "Resources/vande.avi";
 }

 function StartStreamingPlayer()
 {
 document.player1.URL = "Resources/Intro_to_ASP_.NET_3.5.wmv";
 }
 function StopPlayer()
 {
 document.player1.controls.stop();
 }

 function PausePlayer(buttonPauseOrPlay)
 {
 if(buttonPauseOrPlay.value == "Pause")
 {
 document.player1.controls.pause();
 buttonPauseOrPlay.value = "Play";
 }
 else
 {
 document.player1.controls.play();
 buttonPauseOrPlay.value = "Pause";
 }
 }
 </script>

</head>
<body>
 <form id="form1" runat="server">
 <div>
 <object id="player1" height="400" width="590" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
 </object>
 <br />
 <br />
 <input type="button" name="btnPlay" value="Start Non-Streaming File(.avi)" onclick="StartPlayer()" />
 <input type="button" name="btnPlay" value="Start Streaming File(.wmv)" onclick="StartStreamingPlayer()" />
 <input type="button" name="btnStop" value="Stop" onclick="StopPlayer()" />
 <input type="button" name="btnPause" value="Pause" onclick="PausePlayer(this)" />
 <br />
 UI Mode :
 <select id="selUIMode" onchange="this.document.player1.uiMode = selUIMode.value;">
 <option value="invisible">Invisible</option>
 <option value="none">None</option>
 <option value="mini">Mini Player</option>
 <option value="full">Full Player</option>
 </select>
 </div>
 </form>
</body>
</html></div>
<div class="csharpcode">

Output of the above piece of code is as below: It will be real fun when you try on your own :)

Media Player In Browser

In above code the main things is :


 </span><object id="player1" height="400" width="590" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
 </object>

<pre> 

2. Playing file with an External Player is easy. Just following piece of code does that for you:

this.document.location.replace(FILENAME.wma);

Hope you’ve enjoyed it!

Happy Video Playing!

Posted in ASP.NET | Tagged: | Leave a Comment »

MSDN got a new look!

Posted by kiranpatils on November 1, 2009

One of my best friend MSDN – i guess yours too :) got a new look! Few days back while i was searching for something on MSDN – Which i always do :) i saw the new look of MSDN. It really looks a great and really few nice enhancements they did.

image

image

Switch View functionality is really great you can switch the views to Classic, Lightweight Beta and ScriptFree

Happy Reading!

Posted in Latest happenings, MSDN | Tagged: , | Leave a Comment »

How to Debug Windows Service

Posted by kiranpatils on November 1, 2009

Hi Folks, Sorry for being invisible for a long time. But i got really tied up with my bits. Anyways it’s good if i be more busy then i will get more stuff to write :)

First of All Happy Diwali And Happy new year to all of you! I hope this year you face so many challenges which makes you strong in your field!

Challenge

If anyone of you worked developing Windows Services in Visual Studio then one thing you must be wondering too do Debug – which makes programming easier. It’s not as easy as putting breakpoint and do debug like console,windows or web. It is an art to debug windows service.

Solution

To Debug windows service you can use Debugger.Break() method — Signals a breakpoint to an attached debugger.

So here are the steps to debug any piece of code in windows service:

1. Call Debugger.Break() Method before the line you want to put Debug point.

2. Now on the point which you want to get called put breakpoint. Means next line to your Debugger.Break() Line.

3. Now start your windows service. Whenever your piece of code executed. You will see Visual Studio Just-In Time Debugger Window. Choose VS instance and here you go!

Have a Happy Debugging!

Webliography

http://dotnettipoftheday.org/tips/how-to-debug-windows-service-startup.aspx — Another Blog

http://stackoverflow.com/questions/761120/how-to-debug-a-windows-service-using-breakpoints — Same Challenge

Posted in Windows Forms | Tagged: | Leave a Comment »

Get up to 25 percent off select Microsoft Certification exams

Posted by kiranpatils on October 4, 2009

Howdy! I just logged in today in to my MCP portal and found one great thing that MS is giving special discount on Certification exams..Yippee!!!

They have kept three slots : 15%,20% and 25%

All TS Level exams comes under 15% and 20% slot – TS Level means Technology Specialist exams. For example 70-536 comes under TS Level.

All PRO Level exams comes under 25%  slot – PRO Level means Professional level exams. For example 70-547 comes under PRO Level[Hoorah!! currently i am preparing for this exam :) ]

Best thing in this offer is that : This Offer is Good until December 31, 2009 or while supplies last.

So, if you take it positively then you got a reason to give exam before December and which will boost you to start preparation for the exam :)

So, to get your voucher code follow the steps as given below:

1. Go to this URL :

http://www.prometric.com/microsoft/careeroffer.htm

2. From the given table locate your exam code. for example 547 or 536

3. Right side of that column click on “Get Voucher” Link.

4. Fill the form. Please provide the valid e-mail ID. Because your voucher will be mailed to you.

5.Now keep this Voucher code with you and when you go to your local prometric center. Just provide that Voucher Code and you might need to provide the same e-mail id. Which you provided in last step.

6. Take your exam.

7. If you passed the exam  then plan the party for your friends by using the discounted amount :)

Pls note that it is valid by 31 Dec. 2009.

Good luck on your exam!

Posted in Latest happenings | Leave a Comment »

Showing Default Date and Visible Date with Calendar control

Posted by kiranpatils on September 2, 2009

Challenge:

if you are using Calendar control to show Birthday of your friend. So, when you run the application it will show whose b’day is coming in this month or next month or next month …. So, you can be ready for a treat :) . The Challenge here is how to select that particular date and how to make it visible while user runs the application?

Solution:

You can set SelectedDate of Calendar Control to show date selected like this:

DateTime dtBirthday = getUpcomingBirthday(); //assume this method returns upcoming b’day in DateTime

calBirthday.SelectedDate = dtBirthday.Date; //use Date here else it won’t work

You can set VisibleDate of Calendar Control to show that date:

calBirthday.VisibleDate= dtBirthday.Date; //use Date here else it won’t work

Here DateTime.Date part it too important. Else it won’t work. Do you know why? i know but it’s homework for you guys :)

Cheers

Posted in ASP.NET, ASP.NET Controls | Leave a Comment »

Form Reset With Validation Control

Posted by kiranpatils on September 2, 2009

Challenge:

Reset button won’t clear validation control messages.

Solution:

For that you have to write JS onclick of reset button and do hide it like this:

document.getElementById(“regurlarexpressionID”).style.visibility = “hidden”;

See this link:

http://forums.asp.net/t/567612.aspx

Posted in ASP.NET, ASP.NET Controls | Leave a Comment »

Programmatically Posting Data to ASP .NET Web Applications

Posted by kiranpatils on September 2, 2009

Usually what we do. We open a page and fill up a form and submit a form data by pressing “Submit” Button. And after that we get some data/response  as per the logic.  But how to do this programmatically?? — That’s what we have been doing since so long..we faced too many challenges and finally we made it working. You also want to do the same then here we go…

First follow this nice article :

http://dotnet.sys-con.com/node/45127

if you follow all the steps and also COPY-PASTE the whole code given below:

http://gemsres.com/photos/story/res/45127/source.html

IT WON’T WORK

As someone has already commented on that post — That it throws Internal Server Error(500). But unfortunately no solution has been answered. But don’t worry. i’m here to answer that :)

Okay, The problem is in your target ASPX page — Means ASPX Page which has form tag. it should have event validation false:

<%@ Page EnableEventValidation=”false” %>

That’s it. It should work now. And if it dosen’t works then try to debug using Fiddler — Really great tool

Okay, So in short to post form data programmatic ally using ASP.NET following steps are required.

1. ViewState Must be passed.

2. In Target page — enableeventvalidation – false.

3. Fiddler must need to install to see what’s going on :)

Webliography

http://xneuron.wordpress.com/2007/12/05/programmatically-post-a-form-in-aspnet/

http://schleichermann.wordpress.com/2009/07/13/asp-net-programmatically-submit-form-post/

Hope this helps :)

Posted in ASP.NET | Leave a Comment »

There is no script engine for file extension “.vbs”

Posted by kiranpatils on August 13, 2009

Challenge:

If you received an error saying There is no script engine for file extension “.vbs” then you are on right post :)

Solution:

I tried doing this : regsvr32 %systemroot%\system32\vbscript.dll

http://www.technologystory.net/2009/02/25/windows-vista-tips-there-is-no-script-engine-for-file-extension-vbs/

But like you — for me too no luck :(

But finally following trick worked for me :)

1. Locate the file %windir%\inf\wsh.inf (inf is a hidden
folder)

2.right click and select “Install”.

Happy Coding!!

Posted in Uncategorized | Leave a Comment »

svn: Can’t create tunnel: The system cannot find the path specified.

Posted by kiranpatils on August 13, 2009

We are using CruiseControl.NET for continuous integration. I must say really great tool!

We have configured a server where CruiseControl runs and our repository is on Tortoise SVN and it uses SVN+SSH. When we start our “ccnet.exe” it was giving us error like this “svn: Can’t create tunnel: The system cannot find the path specified.”

We really got confused as the message says the system can’t find the file specified But which file?? :(

After struggling a lot we found the solution..Here it is:

SVN_SSH Environment Variable value was like this[Won't Work]:

C:\Program Files\Putty\bin\plink.exe

It should be like this [Will work]:

C:\\Program Files\\Putty\\bin\\plink.exe

OR

C:/Program Files/Putty/bin/plink.exe

That’s it!!

If you are new and don’t know how to access Environment Variables see this:http://www.pushok.com/help/svnscc/index.php?redirect=adv_svnssh.htm

HTH

"Writing a code is a one kind of prayer for me"

Posted in SubVersion | Tagged: | Leave a Comment »