Share Coding

Tutorials, Problems, Stuffs …

Error “Copying file obj\Debug\build.force…” and Warning “Source file ‘obj\Debug\\TemporaryGeneratedFile…” in VS2013

Error 5 Copying file obj\Debug\build.force to obj\Debug\Package\PackageTmp\obj\Debug\build.force failed. Could not find file 'obj\Debug\build.force'.
Warning	3 Source file 'obj\Debug\\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs' specified multiple times	
Warning	4 Source file 'obj\Debug\\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs' specified multiple times	
Warning	2 Source file 'obj\Debug\\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs' specified multiple times

I encountered above messages in VS2013. I tried to clean solution, rebuild project and also run VS as administrator, but those doesn’t work for me.

My solution is open xxxxxx.csproj with a notepad and delete the lines from csproj file:

<Content Include="obj\Debug\build.force" />
<Compile Include="obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs" />
<Compile Include="obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs" />
<Compile Include="obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs" />

Detect navigation bar, or get it’s height in Android

Problem: To solve different device display problem. (fitSystemWindows)

Some android device has a virtual navigation barlayout_structure_system_android1When I want the application ActionBar or content fitSystemWindows=”true”, the content shown under the Status Bar and the Navigation Bar.

It is not a solution to add padding bottom to solve this.

As the title, I try to detect if the navigation bar exist, then add padding bottom. But the detection is not reliable.

  1. Detect if has bar key
    boolean hasSoftKey = ViewConfiguration.get(context).hasPermanentMenuKey();
  2. Detect if has at least back key and home keyboolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
  3.  Get navigation bar height:The following coding get the default navigation bar height of the device. Many device have it, even they don’t have N Bar.
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
    return resources.getDimensionPixelSize(resourceId);
return 0;     


Solution: Add bottom margin when I slip the UI under the Status Bar

/* Status Bar */
protected void setStatusBar(Activity activity, int imageRes) {
    // Lower then API level 19, do nothing
    // Do if API level >= 21 (Android 4.4)
    } else {
        // This is the Android 4.4 Wear for the android watch
    // Change the background image / color of the status bar
    ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(;

    ViewGroup contentView = (ViewGroup) activity.findViewById(;
    if (contentView.getChildCount() > 1) {

    int res = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
    int height = 0;
    if (res != 0)
        height = activity.getResources().getDimensionPixelSize(res);

    ImageView image = new ImageView(activity);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);



Limitation: Webview cannot set padding on it, only margin works.

App icon generator for Android and iOS

Cannot SSH while server connected VPN

Esxi 5.0 Server has a CentOS vm.
Once it connected outside VPN, it then cannot SSH because they are not the same gateway.
So we need to add route to whitelist our host IP to connect our gateway first.

Assume our gateway is, and we would like to allow all my subnetwork to pass through:

route add -net netmask gw

Entity Framework Update table without primary Key (II)

The property ‘xxx’ is part of the object’s key information and cannot be modified

UserRight dboUserRight = DBModel.UserRights.FirstOrDefault(x => x.UserID == id 
                                                             && x.PageID == pid); 
dboUserRight.CanWrite = newValue; 

Method 1: Replace old record

UserRight updatedUserRight = new UserRight();
updatedUserRight.CanWrite = newValue;
updatedUserRight.OtherProperty = xxxx;

Get every new post delivered to your Inbox.