Sunday, November 30, 2014

My pet project Android Web Terminal

My pet project Android Web Terminal was homeless for few months. I found a new home and everyone is welcome http://www.androidwebterminal.com/

Wednesday, November 16, 2011

Failed to connect to the device. Ensure that the device is completely booted and is connected to the PC.

Today I got this error when I updated the phone from Windows Phone 7 to 7.5 (Mango)

To solve this, I had to change the project settings to use the Target Operating system to 7.1 All worked!

Friday, October 28, 2011

How to download full-version of skype ?

http://www.skype.com/go/downloading?source=lightinstaller&ver=5.5.0.124.259&LastError=12002

Tuesday, April 26, 2011

Reference to class 'xxx' is not allowed when its assembly is linked using No-PIA mode

To fix this error you need to Change the Embed Interop Type to false in the properties of the reference.

Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format. in VB.NET 2010

Could not load file or assembly 'Interop.PortableDeviceApiLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. ?

Today, I wanted to add PortableDeviceApiLib assembly to my project to pull some information from a iPhone device. After I add reference to the dll. I started getting this issue. To fix this you need to change the Platform to x86

Project Properties> Build > Target Platform to "x86"

strange solution, but it works.

Monday, January 31, 2011

Web page to access clipboard exception with Watin

I have been working on a solution to get the clipboard working with Watin automated program. because security exception is really annoying!

here is goes,

class Program
{
[STAThread]
static void Main(string[] args) {


SecurityAlertDialogHandler securityAlertDialogHandlerMock = new SecurityAlertDialogHandler();

using (IE ie = new IENoWaitForComplete("url goes here")) {

ie.AddDialogHandler(securityAlertDialogHandlerMock);

//GetPicture(ie.Images[0], ie);
ie.WaitForComplete();

IEElement banner = ieImages[0].NativeElement as IEElement;

IHTMLElement bannerHtmlElem = banner.AsHtmlElement;
IEElement bodyNative = ie.Body.NativeElement as IEElement;
mshtml.IHTMLElement2 bodyHtmlElem = (mshtml.IHTMLElement2)bodyNative.AsHtmlElement;
mshtml.IHTMLControlRange controlRange = (mshtml.IHTMLControlRange)bodyHtmlElem.createControlRange();

controlRange.add((mshtml.IHTMLControlElement)bannerHtmlElem);
controlRange.execCommand("Copy", false, System.Reflection.Missing.Value);
controlRange.remove(0);

if (Clipboard.GetDataObject() != null) {
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Bitmap)) {
System.Drawing.Image image = (System.Drawing.Image)data.GetData(DataFormats.Bitmap, true);
// do something here
}
}
}
}

}

class IENoWaitForComplete : IE
{
public IENoWaitForComplete(string url) : base(url) { }

public override void WaitForComplete(int timeOutPeriod) {
// Skip Wait logic
}
}

class SecurityAlertDialogHandler : BaseDialogHandler
{
private bool _hasHandledSecurityAlertDialog;

public bool HasHandledSecurityAlertDialog {
get { return _hasHandledSecurityAlertDialog; }
}

public override bool HandleDialog(Window window) {
new WinButton(1, window.Hwnd).Click();
return true;
}

public override bool CanHandleDialog(Window window) {
return window.StyleInHex == "94C808CC";
}

}

Tuesday, January 25, 2011

C# Enum.prase in Java or Enum valueOf in C#

this is how to use it in Java

Java
------
public enum Direction {
NORTH, SOUTH, EAST, WEST
}

Direction home = Direction.valueOf(“SOUTH”);

C#
------

System.Enum.Parse(typeof(Direction), "SOUTH",true);

varibale++ vs ++varibale confustion in Java

I just noticed that variable name ++ assignments can be bit confusing (may be due to the fact that I have been a Microsoft based programmer from almost 10 years).

here goes.

Eg,

int r = 4;
int result = r++;

guess whats the result value going to be? it is still 4. Because Java won't perform the actual calculation of the operator until you use variable r somewhere in the code.

however if you use

int r = 4;
int result = ++r;

this will perform the arithmetic operation inline and return the result to 'result' variable.

Friday, January 14, 2011

C# Format.String ( {0} ) equivalent in Java ?

Last few days I have been learning Java. When i used C#, String.Format({0}) was one of my favorites and I was wondering how to do this in Java.

String.format("some string here %s ", valuehere);