Wednesday, December 17, 2008

Wednesday, December 10, 2008

Flex: How to do a deep copy of an object?

Import mx.utils.ObjectUtil and use ObjectUtil.copy().

Wednesday, November 12, 2008

Flex: Cookies in Adobe AIR

You can send cookie from Adobe AIR application using URLRequest but you need to make the manageCookies property false.

myURLRequest.requestHeaders.push(new URLRequestHeader("Cookie", "Your_Cookie"));
myURLRequest.manageCookies = false;

Thursday, October 30, 2008

How to set the icons for an AIR application in Flex?

Open [ApplicationName]-app.xml file and add the following.

< icon>
< image16x16> yourIcon16.png</image16x16>
< image32x32> yourIcon32.png</image32x32>
< image48x48> yourIcon48.png</image48x48>
< image128x128> yourIcon128.png</image128x128>
</icon>

Icons will be included/updated once you build the .air package.

How to read a file from an AIR application in Flex?

//To read the file "src/myFiles/sampleFile.txt"

var myFile:File = File.applicationDirectory;
myFile = myFile.resolvePath("myFiles\\sampleFile.txt");

var myFileStream:FileStream = new FileStream();
myFileStream.open(myFile, FileMode.READ);

var fileData:String = myFileStream.readUTFBytes(myFileStream.bytesAvailable);

Tuesday, October 14, 2008

Flex 3: Panel is not showing rounded corners at the bottom even after setting cornerRadius

You will get rounded corners at the bottom only if your panel contains a control bar. So if you need rounded corners at the bottom of the panel then add a control bar to your panel.

< mx:Panel >
< !-- What ever you already have -- >
< mx:ControlBar/ >
< mx:Panel >

Here the colour of the control bar will be the colour of your panel border.

Thursday, September 4, 2008

How to set the default browser in Flex?

Go to: Window > Preferences > General > Web Browser and set your default browser. Please see the screen shot below.

Tuesday, July 29, 2008

Flex 3: How to retrieve data from dragSource in a list control?

Flex controls DataGrid and List use "items" as the name of the format when they automatically create a DragSource. So you can retrieve them using myDragEvent.dragSource.dataForFormat("items"). For the Tree control, "treeItems" is the default format string.

Saturday, July 26, 2008

Samsung FLO(SCH F519): How to mute the keypad tone?

Use the volume keys on the side when you are on the main standby screen [Simple but I took quite a lot of time to figure it out].

Thursday, June 12, 2008

ASP.NET is not enabled - MoM 2005 Installation.

I got this error while installing MoM 2005 in a Windows 2003 Server machine however ASP.net pages where working fine in IIS.

This is how I solved this problem.

Go to Control Panel > Add or Remove Programs > Add or Remove Windows components.



Select Details for Application Server. Mark ASP.net and give OK to install ASP.net.

Monday, June 2, 2008

SelfSSL: Failed to build the subject name blob: 0x80092023 on installing certificate

Make sure that there is no syntax error(s) in the command using which you invoked SelfSSL. What happened to me is that, I used /N:SG_TEST instead of /N:CN=SG_TEST.

How to retrieve Site ID form the IIS?

Right click the 'web site' in IIS and select 'properties'. Now select the 'properties' under the 'Web Site' tab, 'Enable Logging' section. You will see a window similar to the one shown below.



W3SVC<Site ID> (shown in the image) will give you the Site ID. Here 1 is the 'Site ID'.

Wednesday, May 14, 2008

How to install a windows service using Visual Studio?

Select Start -> Programs -> Microsoft Visual Studio xxxx -> Visual Studio Tools -> Visual Studio xxxx Command Prompt and give the command

InstallUtil "FullPathToYourService"

Thursday, May 8, 2008

iPod album art shows up black?

The simple solution is connect your iPod to iTunes. Then uncheck 'display album art' (in Music tab under Devices) and 'apply'. Then check 'display album art' again. It might fix your issue. If not then remove the album art and disconnect the iPod from iTunes. Connect again and add the album art image. I had this problem and I solved it as described above.

Friday, May 2, 2008

Generic Host Process for Win32 Services has encountered a problem and needs to close

Install this fix: http://www.microsoft.com/downloads/details.aspx?FamilyID=A87B44B9-7A6A-49B6-BD89-AFAD4E049C48&displaylang=en

Tuesday, April 29, 2008

Ruby on Rails: Difference between <% %> and <% -%>

<% -%> supress the trailing new line. You can also use <%- %> to supress leading whitespace. You need to use <%= %> when you need to output something.

Wednesday, April 23, 2008

Ruby on Rails: undefined method `render_text'

Change render_text "Hello World" to render :text => "Hello World"

Thursday, April 10, 2008

C# : How to convert a string to an enum?

Use Enum.Parse()

Eg:
enum eType
{
Type1,
Type2,
Type3
}

eType obj = (eType) Enum.Parse(typeof(eType), "Type1");

Wednesday, April 9, 2008

How to use variable number of parameters in C#

It is very easy to use variable number of parameters in C# with the help of params keyword.

Here is a small example which will find the largest integer in from a list of integers where the size of the list is unknown.

public int FindLargest(int Num, params int[] Nums)
{
int Large = Num;
foreach (int n in Nums)
{
if (n > Large)
{
Large = n;
}
}
return Large;
}

Tuesday, April 8, 2008

C# : What is the difference between ref and out?

As far as I understood, the ref is like in/out and out is just out. What I meant is that you can send a value in to a function using a ref parameter but you can't send a value using an out parameter. Out parameter can be used only for returning a value from a function. Also the ref parameters should be initialized before passing to the function.

Thursday, April 3, 2008

C# : Text box text is not getting refreshed

I had to do a code like the one shown below

txtSample.Text = "Text Sample1";

//few lines of code

txtSample.Text = "Text Sample2";

But it was showing only 'Text Sample2'.

I was looking for a solution and I found that I need to invalidate the rectangle so that the new text will be displayed. There is a method Invalidate() associated with all the controls. But it was not working for me. You need to use the Refresh() method if you need the control fully painted before you take the next step.

Wednesday, April 2, 2008

Thursday, March 20, 2008

Localhost and 127.0.0.1 is working but LocalIP is not working

Some problem with your firewall settings. Disable it and try. If its working change your firewall settings accordingly.

Tuesday, March 18, 2008

Windows 2003 Server : Web Service - HTTP Error 404 - File or directory not found

By default, ISS disables dynamic content in Windows 2003 Server. Enable the required extension (In Web Service Extensions node).

Service reference could not be loaded because more than one endpoint configuration for that contract was found

Check your app.config file. Remove the end points which are not required under the client tag.

Monday, March 17, 2008

HTTP POST is not working in webservices hosted remotely

Enable HTTP POST in the web.config file of your webservice.

See http://support.microsoft.com/default.aspx?scid=kb;en-us;819267

Problem after hosting webservice

When I tried to host a WebService and then to check it in the browser I got the content of the file rather than the list of WebMethods.

To solve this, first check whether the asp.net version is set in the website properties in IIS.

If your problem is not solved (most probably you install IIS after installing .net) run "aspnet_regiis.exe -i"(it will be there in your .net frame work folder) and then run "iisreset".

This fixed my problem.

C# : System.Web.UI namespace is missing?

Add a reference to System.Design.

If you are using System.Web.UI.WebControls or System.Web.UI.HtmlControls or etc. you may also need a reference to System.Web.

Friday, March 14, 2008

C# : How to convert an object to xml string?

using System.Xml;
using System.Xml.Serialization;
using System.IO;

public string GetXMLFromObject(object o)
{
XmlSerializer XmlS = new XmlSerializer(o.GetType());

StringWriter sw = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(sw);

XmlS.Serialize(tw, o);
return sw.ToString();
}

Thursday, March 13, 2008

TCP error code 10061: No connection could be made because the target machine actively refused it

The port in which you connected may be blocked by some firewalls. Or you are not listening to a wrong port.

How to debug Windows Media Plugins?

Download 'Dbgview.exe' from Microsoft. Go to 'Capture' menu and enable 'Capture Global Win32'.

Now use 'Debug.WriteLine("The message you need")' in your plugin code. Thats it. Now when you run your plugin the debug messages will be captured by the Dbgview.

Wednesday, March 12, 2008

regasm : No types where registered

When I tried to register a dll file created in C# using regasm I got this Error. You can fix it very easly but setting [assembly: ComVisible(true)] in AssemblyInfo.cs

Visual Studio 2008 - C# : The output path property is not set for this project

Right click the project in the solution explorer and select properties. Select the Build tab and set the Output path.