问:
First Chance exception in ntdll 0XC0000005 Windbg
Please help me analyze this crash dump . This is my last resort.

We have a windows COM/DCOM service that crashes with this dump. It looks as if there is some heap corruption going on here. This crash strangely occurs only on Windows server 2008 sp2 and is causing a lot of headaches.

Can any windbg experts help here? I would appreciate any kinda of help with locating the error or proving tips on how to debug this since i am a newbie with windbg.
Thanks in advance.
Below is the windbg output

```<code>Comment: 'Dump created by DbgHost. First chance exception 0XC0000005'
Symbol search path is: C:\debug symbols;C:\Windows\Symbols

Windows Server 2008/Windows Vista Version 6002 (Service Pack 2) UP Free x86 compatible
Product: LanManNt, suite: Enterprise TerminalServer SingleUserTS
Machine Name:
Debug session time: Tue Nov 30 14:15:48.000 2010 (GMT+2)
System Uptime: 5 days 0:32:32.875
Process Uptime: 0 days 1:29:39.000
...........................................................
Loading unloaded module list  .....
This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(868.ae4): Access violation - code c0000005 (first/second chance not available)
eax=c0c0c0a0 ebx=00140000 ecx=c0c0c0a0 edx=00141000 esi=00140000 edi=00140000
eip=7005a43d esp=04ebf2dc ebp=04ebf320 iopl=0         nv up ei ng nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010286
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for verifier.dll - verifier!VerifierStopMessage+0x591d:
7005a43d 8139aaaacdab    cmp     dword ptr [ecx],0ABCDAAAAh ds:0023:c0c0c0a0=????????
*** WARNING: Unable to verify checksum for vsrv.exe
0:011> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************

*** WARNING: Unable to verify checksum for TCheckLic.dll
*** WARNING: Unable to verify checksum for regserverps.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for regserverps.dll -
*** WARNING: Unable to verify checksum for carsps.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for carsps.dll -
*** WARNING: Unable to verify checksum for vsrvps.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for vsrvps.dll -
*** WARNING: Unable to verify checksum for vdbaccs.dll
*** WARNING: Unable to verify checksum for VsrvPing.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for msiltcfg.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for WlS0WndH.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for wsock32.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for comctl32.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for wtsapi32.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for winnsi.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for sxs.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for winsta.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for psapi.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for lpk.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for clbcatq.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ws2_32.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for nsi.dll
*************************************************************************
***                                                                   ***
***                                                                   ***
***    Your debugger is not using the correct symbols                 ***
***                                                                   ***
***    In order for this command to work properly, your symbol path   ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: IMAGE_NT_HEADERS32                            ***
***                                                                   ***
*************************************************************************
Failed calling InternetOpenUrl, GLE=12007
*************************************************************************
***                                                                   ***
***                                                                   ***
***    Your debugger is not using the correct symbols                 ***
***                                                                   ***
***    In order for this command to work properly, your symbol path   ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: kernel32!pNlsUserInfo                         ***
***                                                                   ***
*************************************************************************
*************************************************************************
***                                                                   ***
***                                                                   ***
***    Your debugger is not using the correct symbols                 ***
***                                                                   ***
***    In order for this command to work properly, your symbol path   ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: kernel32!pNlsUserInfo                         ***
***                                                                   ***
*************************************************************************

FAULTING_IP:
verifier!VerifierStopMessage+591d
7005a43d 8139aaaacdab    cmp     dword ptr [ecx],0ABCDAAAAh

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 7005a43d (verifier!VerifierStopMessage+0x0000591d)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 00000000
   Parameter[1]: c0c0c0a0
Attempt to read from address c0c0c0a0

PROCESS_NAME:  vsrv.exe

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

EXCEPTION_PARAMETER1:  00000000

EXCEPTION_PARAMETER2:  c0c0c0a0

READ_ADDRESS:  c0c0c0a0

FOLLOWUP_IP:
verifier!VerifierStopMessage+591d
7005a43d 8139aaaacdab    cmp     dword ptr [ecx],0ABCDAAAAh

NTGLOBALFLAG:  2000000

APPLICATION_VERIFIER_FLAGS:  0

ADDITIONAL_DEBUG_TEXT:  Enable Pageheap/AutoVerifer

FAULTING_THREAD:  00000ae4

DEFAULT_BUCKET_ID:  HEAP_CORRUPTION

PRIMARY_PROBLEM_CLASS:  HEAP_CORRUPTION

BUGCHECK_STR:  APPLICATION_FAULT_HEAP_CORRUPTION_INVALID_POINTER_READ

LAST_CONTROL_TRANSFER:  from 7005a9e0 to 7005a43d

STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be wrong.
04ebf320 7005a9e0 00141000 c0c0c0c0 00000004 verifier!VerifierStopMessage+0x591d
04ebf33c 700587eb 00141000 00240000 01000002 verifier!VerifierStopMessage+0x5ec0
04ebf390 77622614 00140000 01000002 c0c0c0c0 verifier!VerifierStopMessage+0x3ccb
04ebf3d8 775eb7cd 00140000 01000002 c0c0c0c0 ntdll!RtlDebugFreeHeap+0x2f
04ebf4cc 775d7545 c0c0c0c0 c0c0c0c0 04ebf604 ntdll!RtlpFreeHeap+0x5f
04ebf4e8 762f9a26 00140000 00000000 c0c0c0c0 ntdll!RtlFreeHeap+0x14e
04ebf4fc 773aaf25 00140000 00000000 c0c0c0c0 kernel32!HeapFree+0x14
04ebf510 773aaf41 7747f6f8 c0c0c0c0 04ebf538 ole32!CRetailMalloc_Free+0x1c
04ebf520 75e16efc c0c0c0c0 04ebf604 037d3e6c ole32!CoTaskMemFree+0x13
04ebf538 75e08221 c0c0c0c0 c0c0c0c0 037d3e6c rpcrt4!NdrPointerFree+0xb5
04ebf560 75e0825a 00000000 04ebf58c 75e16ecb rpcrt4!NdrpEmbeddedPointerFree+0x4c
04ebf56c 75e16ecb 04ebf604 09afcff0 037d3e60 rpcrt4!NdrSimpleStructFree+0x1c
04ebf58c 75e16ecb 09afcff0 09afcff0 037d3e52 rpcrt4!NdrPointerFree+0x91
04ebf5ac 75ea25c8 09afcff0 04ebf840 037d3e4e rpcrt4!NdrPointerFree+0x91
04ebf5d4 75ea248b 04ebf840 00000002 04ebf7e0 rpcrt4!NdrpFreeParams+0x150
04ebf5e4 75ea2429 feabd21b 09a52fe0 07bd6f28 rpcrt4!NdrStubCall2+0x9aa
04ebf65c 751d192d 037d4968 00000000 00000000 rpcrt4!NdrStubCall2+0x55c
04ebfa04 75ea293b 09a52fe0 0982cfc0 07bd6f28 rsaenh!AesExpandKey+0x23
04ebfa54 7747a8c5 09a52fe0 07bd6f28 0982cfc0 rpcrt4!CStdStubBuffer_Invoke+0xa0
04ebfa9c 7747aa59 07bd6f28 09225f08 08dbec38 ole32!SyncStubInvoke+0x3c
04ebfae8 773a61d6 07bd6f28 09a12f18 09a52fe0 ole32!StubInvoke+0xb9
04ebfbc4 773a60e7 0982cfc0 00000000 09a52fe0 ole32!CCtxComChnl::ContextInvoke+0xfa
04ebfbe0 773a6df5 07bd6f28 00000001 09a52fe0 ole32!MTAInvoke+0x1a
04ebfc0c 7747a981 07bd6f28 00000001 09a52fe0 ole32!STAInvoke+0x46
04ebfc40 7747a79b d0908070 0982cfc0 09a52fe0 ole32!AppInvoke+0xaa
04ebfd1c 7747ae2d 07bd6ed0 06ffd420 00000400 ole32!ComInvokeWithLockAndIPID+0x32c
04ebfd44 773a6bcd 07bd6ed0 00000400 06df2e30 ole32!ComInvoke+0xc5
04ebfd58 773a6b8c 07bd6ed0 04ebfe18 00000400 ole32!ThreadDispatch+0x23
04ebfd9c 75fafd72 00ba002a 00000400 0000babe ole32!ThreadWndProc+0x167
04ebfdc8 75fafe4a 773a6aef 00ba002a 00000400 user32!InternalCallWinProc+0x23
04ebfe40 75fb018d 00000000 773a6aef 00ba002a user32!UserCallWinProcCheckWow+0x14b
04ebfea4 75fa8b7c 773a6aef 00000001 04ebff34 user32!DispatchMessageWorker+0x322
04ebfeb4 0044fbc9 04ebff14 00000000 00000000 user32!DispatchMessageA+0xf
04ebff34 0044faf1 00000000 00000000 041b2e88 vsrv!ATL::CComApartment::Apartment+0xc9   [d:\program files\microsoft visual studio\vc98\atl\include\atlbase.h @ 3837]
04ebff88 762fd0e9 041b2e88 04ebffd4 775b19bb vsrv!ATL::CComApartment::_Apartment+0x11   [d:\program files\microsoft visual studio\vc98\atl\include\atlbase.h @ 3815]
04ebff94 775b19bb 041b2e88 6a03c808 00000000 kernel32!BaseThreadInitThunk+0xe
04ebffd4 775b198e 00402428 041b2e88 ffffffff ntdll!__RtlUserThreadStart+0x23
04ebffec 00000000 00402428 041b2e88 00000000 ntdll!_RtlUserThreadStart+0x1b

STACK_COMMAND:  .cxr 00000000 ; kb ; ~11s; .ecxr ; kb

SYMBOL_NAME:  heap_corruption!heap_corruption

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: heap_corruption

IMAGE_NAME:  heap_corruption

DEBUG_FLR_IMAGE_TIMESTAMP:  0

FAILURE_BUCKET_ID:  HEAP_CORRUPTION_c0000005_heap_corruption!heap_corruption

BUCKET_ID:    APPLICATION_FAULT_HEAP_CORRUPTION_INVALID_POINTER_READ_heap_corruption!heap_corruption

WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/vsrv_exe/68_50_606_0/4ce50c9e  /verifier_dll/6_0_6001_18000/4791a775/c0000005/0001a43d.htm?Retriage=1

Followup: MachineOwner
</code>```

答:
Can you repro this?

If so,

Set up your symbols properly to use the symbol server.

E.g. set your environment variable

_NT_SYMBOL_PATH=SRV*c:\websymbols*http://msdl.microsoft.com/download/symbols

Set up Application Verifier to use the default tests and run your application through with a command line similar to windbg -xd av -xd ch -xd sov ApplicationCommandLine.

If you have a memory corruption, AppVerif will likely catch it and raise a second chance exception in your debugger. Make sure you enable full page heap so that heap overruns access-violate immediately.

Familiarise yourself with the !avrf extension, if necessary.

Body:
Please help me analyze this crash dump . This is my last resort.

We have a windows COM/DCOM service that crashes with this dump. It looks as if there is some heap corruption going on here. This crash strangely occurs only on Windows server 2008 sp2 and is causing a lot of headaches.

Can any windbg experts help here? I would appreciate any kinda of help with locating the error or proving tips on how to debug this since i am a newbie with windbg.
Thanks in advance.
Below is the windbg output

Comment: 'Dump created by DbgHost. First chance exception 0XC0000005'
Symbol search path is: C:\debug symbols;C:\Windows\Symbols

Windows Server 2008/Windows Vista Version 6002 (Service Pack 2) UP Free x86 compatible
Product: LanManNt, suite: Enterprise TerminalServer SingleUserTS
Machine Name:
Debug session time: Tue Nov 30 14:15:48.000 2010 (GMT+2)
System Uptime: 5 days 0:32:32.875
Process Uptime: 0 days 1:29:39.000
...........................................................
Loading unloaded module list  .....
This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(868.ae4): Access violation - code c0000005 (first/second chance not available)
eax=c0c0c0a0 ebx=00140000 ecx=c0c0c0a0 edx=00141000 esi=00140000 edi=00140000
eip=7005a43d esp=04ebf2dc ebp=04ebf320 iopl=0         nv up ei ng nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010286
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for verifier.dll - verifier!VerifierStopMessage+0x591d:
7005a43d 8139aaaacdab    cmp     dword ptr [ecx],0ABCDAAAAh ds:0023:c0c0c0a0=????????
*** WARNING: Unable to verify checksum for vsrv.exe
0:011> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************

*** WARNING: Unable to verify checksum for TCheckLic.dll
*** WARNING: Unable to verify checksum for regserverps.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for regserverps.dll -
*** WARNING: Unable to verify checksum for carsps.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for carsps.dll -
*** WARNING: Unable to verify checksum for vsrvps.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for vsrvps.dll -
*** WARNING: Unable to verify checksum for vdbaccs.dll
*** WARNING: Unable to verify checksum for VsrvPing.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for msiltcfg.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for WlS0WndH.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for wsock32.dll -
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for comctl32.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for wtsapi32.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for winnsi.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for sxs.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for winsta.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for psapi.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for lpk.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for clbcatq.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ws2_32.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for nsi.dll
*************************************************************************
***                                                                   ***
***                                                                   ***
***    Your debugger is not using the correct symbols                 ***
***                                                                   ***
***    In order for this command to work properly, your symbol path   ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: IMAGE_NT_HEADERS32                            ***
***                                                                   ***
*************************************************************************
Failed calling InternetOpenUrl, GLE=12007
*************************************************************************
***                                                                   ***
***                                                                   ***
***    Your debugger is not using the correct symbols                 ***
***                                                                   ***
***    In order for this command to work properly, your symbol path   ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: kernel32!pNlsUserInfo                         ***
***                                                                   ***
*************************************************************************
*************************************************************************
***                                                                   ***
***                                                                   ***
***    Your debugger is not using the correct symbols                 ***
***                                                                   ***
***    In order for this command to work properly, your symbol path   ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: kernel32!pNlsUserInfo                         ***
***                                                                   ***
*************************************************************************

FAULTING_IP:
verifier!VerifierStopMessage+591d
7005a43d 8139aaaacdab    cmp     dword ptr [ecx],0ABCDAAAAh

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 7005a43d (verifier!VerifierStopMessage+0x0000591d)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 00000000
   Parameter[1]: c0c0c0a0
Attempt to read from address c0c0c0a0

PROCESS_NAME:  vsrv.exe

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

EXCEPTION_PARAMETER1:  00000000

EXCEPTION_PARAMETER2:  c0c0c0a0

READ_ADDRESS:  c0c0c0a0

FOLLOWUP_IP:
verifier!VerifierStopMessage+591d
7005a43d 8139aaaacdab    cmp     dword ptr [ecx],0ABCDAAAAh

NTGLOBALFLAG:  2000000

APPLICATION_VERIFIER_FLAGS:  0

ADDITIONAL_DEBUG_TEXT:  Enable Pageheap/AutoVerifer

FAULTING_THREAD:  00000ae4

DEFAULT_BUCKET_ID:  HEAP_CORRUPTION

PRIMARY_PROBLEM_CLASS:  HEAP_CORRUPTION

BUGCHECK_STR:  APPLICATION_FAULT_HEAP_CORRUPTION_INVALID_POINTER_READ

LAST_CONTROL_TRANSFER:  from 7005a9e0 to 7005a43d

STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be wrong.
04ebf320 7005a9e0 00141000 c0c0c0c0 00000004 verifier!VerifierStopMessage+0x591d
04ebf33c 700587eb 00141000 00240000 01000002 verifier!VerifierStopMessage+0x5ec0
04ebf390 77622614 00140000 01000002 c0c0c0c0 verifier!VerifierStopMessage+0x3ccb
04ebf3d8 775eb7cd 00140000 01000002 c0c0c0c0 ntdll!RtlDebugFreeHeap+0x2f
04ebf4cc 775d7545 c0c0c0c0 c0c0c0c0 04ebf604 ntdll!RtlpFreeHeap+0x5f
04ebf4e8 762f9a26 00140000 00000000 c0c0c0c0 ntdll!RtlFreeHeap+0x14e
04ebf4fc 773aaf25 00140000 00000000 c0c0c0c0 kernel32!HeapFree+0x14
04ebf510 773aaf41 7747f6f8 c0c0c0c0 04ebf538 ole32!CRetailMalloc_Free+0x1c
04ebf520 75e16efc c0c0c0c0 04ebf604 037d3e6c ole32!CoTaskMemFree+0x13
04ebf538 75e08221 c0c0c0c0 c0c0c0c0 037d3e6c rpcrt4!NdrPointerFree+0xb5
04ebf560 75e0825a 00000000 04ebf58c 75e16ecb rpcrt4!NdrpEmbeddedPointerFree+0x4c
04ebf56c 75e16ecb 04ebf604 09afcff0 037d3e60 rpcrt4!NdrSimpleStructFree+0x1c
04ebf58c 75e16ecb 09afcff0 09afcff0 037d3e52 rpcrt4!NdrPointerFree+0x91
04ebf5ac 75ea25c8 09afcff0 04ebf840 037d3e4e rpcrt4!NdrPointerFree+0x91
04ebf5d4 75ea248b 04ebf840 00000002 04ebf7e0 rpcrt4!NdrpFreeParams+0x150
04ebf5e4 75ea2429 feabd21b 09a52fe0 07bd6f28 rpcrt4!NdrStubCall2+0x9aa
04ebf65c 751d192d 037d4968 00000000 00000000 rpcrt4!NdrStubCall2+0x55c
04ebfa04 75ea293b 09a52fe0 0982cfc0 07bd6f28 rsaenh!AesExpandKey+0x23
04ebfa54 7747a8c5 09a52fe0 07bd6f28 0982cfc0 rpcrt4!CStdStubBuffer_Invoke+0xa0
04ebfa9c 7747aa59 07bd6f28 09225f08 08dbec38 ole32!SyncStubInvoke+0x3c
04ebfae8 773a61d6 07bd6f28 09a12f18 09a52fe0 ole32!StubInvoke+0xb9
04ebfbc4 773a60e7 0982cfc0 00000000 09a52fe0 ole32!CCtxComChnl::ContextInvoke+0xfa
04ebfbe0 773a6df5 07bd6f28 00000001 09a52fe0 ole32!MTAInvoke+0x1a
04ebfc0c 7747a981 07bd6f28 00000001 09a52fe0 ole32!STAInvoke+0x46
04ebfc40 7747a79b d0908070 0982cfc0 09a52fe0 ole32!AppInvoke+0xaa
04ebfd1c 7747ae2d 07bd6ed0 06ffd420 00000400 ole32!ComInvokeWithLockAndIPID+0x32c
04ebfd44 773a6bcd 07bd6ed0 00000400 06df2e30 ole32!ComInvoke+0xc5
04ebfd58 773a6b8c 07bd6ed0 04ebfe18 00000400 ole32!ThreadDispatch+0x23
04ebfd9c 75fafd72 00ba002a 00000400 0000babe ole32!ThreadWndProc+0x167
04ebfdc8 75fafe4a 773a6aef 00ba002a 00000400 user32!InternalCallWinProc+0x23
04ebfe40 75fb018d 00000000 773a6aef 00ba002a user32!UserCallWinProcCheckWow+0x14b
04ebfea4 75fa8b7c 773a6aef 00000001 04ebff34 user32!DispatchMessageWorker+0x322
04ebfeb4 0044fbc9 04ebff14 00000000 00000000 user32!DispatchMessageA+0xf
04ebff34 0044faf1 00000000 00000000 041b2e88 vsrv!ATL::CComApartment::Apartment+0xc9   [d:\program files\microsoft visual studio\vc98\atl\include\atlbase.h @ 3837]
04ebff88 762fd0e9 041b2e88 04ebffd4 775b19bb vsrv!ATL::CComApartment::_Apartment+0x11   [d:\program files\microsoft visual studio\vc98\atl\include\atlbase.h @ 3815]
04ebff94 775b19bb 041b2e88 6a03c808 00000000 kernel32!BaseThreadInitThunk+0xe
04ebffd4 775b198e 00402428 041b2e88 ffffffff ntdll!__RtlUserThreadStart+0x23
04ebffec 00000000 00402428 041b2e88 00000000 ntdll!_RtlUserThreadStart+0x1b

STACK_COMMAND:  .cxr 00000000 ; kb ; ~11s; .ecxr ; kb

SYMBOL_NAME:  heap_corruption!heap_corruption

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: heap_corruption

IMAGE_NAME:  heap_corruption

DEBUG_FLR_IMAGE_TIMESTAMP:  0

FAILURE_BUCKET_ID:  HEAP_CORRUPTION_c0000005_heap_corruption!heap_corruption

BUCKET_ID:    APPLICATION_FAULT_HEAP_CORRUPTION_INVALID_POINTER_READ_heap_corruption!heap_corruption

WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/vsrv_exe/68_50_606_0/4ce50c9e  /verifier_dll/6_0_6001_18000/4791a775/c0000005/0001a43d.htm?Retriage=1

Followup: MachineOwner


来源: stackexchange

问:
Unable to enter data on edittext fields of appium
I am entering data on these checkboxes. The script runs fine but data does not enters. Check the code below:

List<WebElement>pincode = driver.findElements(By.id("com.theentertainerme.entertainer:id/pin_code_round)"));

```<code>    pincode.get(0).sendKeys("0");
    pincode.get(1).sendKeys("0");
    pincode.get(2).sendKeys("0");
    pincode.get(3).sendKeys("0");
</code>```

Check UI of screen
Image added is of UiAutomatorViewer
Please help me out on this.

答:
Instead of doing like that you can enter the four digits by using android keycodes.

```<code>driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
</code>```

This will enter all 1's in the four fields.

ContentLicense: CC BY-SA 3.0

Body:
I am entering data on these checkboxes. The script runs fine but data does not enters. Check the code below:

List<WebElement>pincode = driver.findElements(By.id("com.theentertainerme.entertainer:id/pin_code_round)"));

    pincode.get(0).sendKeys("0");
    pincode.get(1).sendKeys("0");
    pincode.get(2).sendKeys("0");
    pincode.get(3).sendKeys("0");

Check UI of screen
Image added is of UiAutomatorViewer
Please help me out on this.

Body:
Instead of doing like that you can enter the four digits by using android keycodes.

driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);

This will enter all 1's in the four fields.


问:
How to delete data based on the params url selected on rails?
I have two models on rails with following associations:

```<code>class Manufacturer
  has_many :equipments
end

class Equipments
  belongs_to :manufacturer
end
</code>```

I have an Equipments show page with following fields:

```<code>title,
category_id,
sub_category_id,
manufacturer_id
</code>```

When I am on the equipment show page

I am trying to give a button which when clicked will fetch the manufacturer_id on that page based on the equipment_id on the url and delete it from the record of the Manufacturer table.
I know how to do it from Manufacturer show page. It will be like:

Manufacturer.find(params[:manufacturer_id]).

But how can I do it same from the Equipment show page ?

答:
In equipment show page:

```<code><%= link_to 'Delete', delete_manufacturer_equipment_path(@equipment.id), method: :delete, data: { confirm: 'Are you sure?' } %>
</code>```

In equipments controller:

```<code>   def delete_manufacturer
     @manufacturer = Manufacturer.joins(:equipments).where(equipments: {id: params[:id]}).first
     @manufacturer.destroy if @manufacturer.present?
    redirect_to :back, notice: 'Manufacturer successfully deleted'
  end
</code>```

In routes

```<code> resources :equipments do
   member do
     delete :delete_manufacturer
   end
 end
</code>```

Body:
I have two models on rails with following associations:

class Manufacturer
  has_many :equipments
end

class Equipments
  belongs_to :manufacturer
end

I have an Equipments show page with following fields:

title,
category_id,
sub_category_id,
manufacturer_id

When I am on the equipment show page

I am trying to give a button which when clicked will fetch the manufacturer_id on that page based on the equipment_id on the url and delete it from the record of the Manufacturer table.
I know how to do it from Manufacturer show page. It will be like:

Manufacturer.find(params[:manufacturer_id]).

But how can I do it same from the Equipment show page ?

Body:
In equipment show page:

<%= link_to 'Delete', delete_manufacturer_equipment_path(@equipment.id), method: :delete, data: { confirm: 'Are you sure?' } %>

In equipments controller:

   def delete_manufacturer
     @manufacturer = Manufacturer.joins(:equipments).where(equipments: {id: params[:id]}).first
     @manufacturer.destroy if @manufacturer.present?
    redirect_to :back, notice: 'Manufacturer successfully deleted'
  end

In routes

 resources :equipments do
   member do
     delete :delete_manufacturer
   end
 end


问:
100% width in React Native Flexbox
I have already read several flexbox tutorial, but I still cannot make this simple task to work.

How can I make the red box to 100% width?

Code:

```<code>  <View style={styles.container}>
    <Text style={styles.welcome}>
      Welcome to React Natives
    </Text>
    <Text style={styles.line1}>
      line1
    </Text>
    <Text style={styles.instructions}>
      Press Cmd+R to reload,{'\n'}
      Cmd+D or shake for dev menu
    </Text>
  </View>
</code>```

style:

```<code>container: {
  flex: 1,
  justifyContent: 'center',
  alignItems: 'center',
  backgroundColor: '#F5FCFF',
  borderWidth: 1,
  flexDirection: 'column',
},
welcome: {
  fontSize: 20,
  textAlign: 'center',
  margin: 10,
  borderWidth: 1,
},
line1: {
    backgroundColor: '#FDD7E4',
},
instructions: {
  textAlign: 'center',
  color: '#333333',
  marginBottom: 5,
  borderWidth: 1,
},
</code>```

Thank you!

Update 1:
Suggestion by Nishanth Shankar, adding
flex:1 for the wrapper,
flexDirection: 'row'

Output:

Code:

```<code>  <View style={styles.container}>
    <View style={{flex:1}}>
      <Text style={styles.welcome}>
        Welcome to React Natives
      </Text>
    </View>
    <View style={{flex:1}}>
      <Text style={styles.line1}>
        line1
      </Text>
    </View>
    <View style={{flex:1}}>
      <Text style={styles.instructions}>
        Press Cmd+R to reload,{'\n'}
        Cmd+D or shake for dev menu
      </Text>
    </View>
  </View>

  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
    borderWidth: 1,
    flexDirection: 'row',
    flexWrap: 'wrap',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
    borderWidth: 1,
  },
  line1: {
      backgroundColor: '#FDD7E4',
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
    borderWidth: 1,
  },
</code>```

答:
Use javascript to get the width and height and add them in View's style.
To get full width and height, use Dimensions.get('window').width
https://facebook.github.io/react-native/docs/dimensions.html

getSize() {
    return {
        width: Dimensions.get('window').width,
        height: Dimensions.get('window').height
    }
}
```

<p>and then,</p>

<pre class="lang-js prettyprint-override"><code><View style={[styles.overlay, this.getSize()]}>
</code>```

ContentLicense: CC BY-SA 4.0

Title: 100% width in React Native Flexbox

Body:
I have already read several flexbox tutorial, but I still cannot make this simple task to work.

How can I make the red box to 100% width?

Code:

  <View style={styles.container}>
    <Text style={styles.welcome}>
      Welcome to React Natives
    </Text>
    <Text style={styles.line1}>
      line1
    </Text>
    <Text style={styles.instructions}>
      Press Cmd+R to reload,{'\n'}
      Cmd+D or shake for dev menu
    </Text>
  </View>

style:

container: {
  flex: 1,
  justifyContent: 'center',
  alignItems: 'center',
  backgroundColor: '#F5FCFF',
  borderWidth: 1,
  flexDirection: 'column',
},
welcome: {
  fontSize: 20,
  textAlign: 'center',
  margin: 10,
  borderWidth: 1,
},
line1: {
    backgroundColor: '#FDD7E4',
},
instructions: {
  textAlign: 'center',
  color: '#333333',
  marginBottom: 5,
  borderWidth: 1,
},

Thank you!

Update 1:
Suggestion by Nishanth Shankar, adding
flex:1 for the wrapper,
flexDirection: 'row'

Output:

Code:

  <View style={styles.container}>
    <View style={{flex:1}}>
      <Text style={styles.welcome}>
        Welcome to React Natives
      </Text>
    </View>
    <View style={{flex:1}}>
      <Text style={styles.line1}>
        line1
      </Text>
    </View>
    <View style={{flex:1}}>
      <Text style={styles.instructions}>
        Press Cmd+R to reload,{'\n'}
        Cmd+D or shake for dev menu
      </Text>
    </View>
  </View>

  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
    borderWidth: 1,
    flexDirection: 'row',
    flexWrap: 'wrap',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
    borderWidth: 1,
  },
  line1: {
      backgroundColor: '#FDD7E4',
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
    borderWidth: 1,
  },

Body:
Use javascript to get the width and height and add them in View's style.
To get full width and height, use Dimensions.get('window').width
https://facebook.github.io/react-native/docs/dimensions.html

getSize() {
    return {
        width: Dimensions.get('window').width,
        height: Dimensions.get('window').height
    }
}

and then,

<View style={[styles.overlay, this.getSize()]}>


问:
How to Make data automatically fill the form after selecting from dropdown menu
So i'm creating a Customize form so that i can edit my user data using a page.
I have a dropdown menu which is contain username from database.

What im gonna do is , when i click the username i want to costumize , all data of the username goes into the form below it ( like email,password,etc )

This pict explain what i wanted to do

This is my dropdown code :

Costumize Data

Select data to costumize

        <select class="form-control" name="userlist">
            <?php
               $servername = "localhost";
               $username = "root";
               $password = "";
               $dbname = "gamestore";

            // Create Connection
            $conn = mysqli_connect($servername, $username, $password, $dbname);

            // Check connection
            if (!$conn) {
                trigger_error("Connection failed: " . mysqli_connect_error());

            }
            //Run Query
            $stmt = "SELECT DISTINCT `username` FROM `login` ORDER BY user_id ASC";
            $result = mysqli_query($conn,$stmt) or die(mysqli_error($conn));
            while(list($category) = mysqli_fetch_row($result)){
                echo '<option value="'.$category.'">'.$category.'</option>';
            }
            mysqli_close($conn);
            ?>

        </select>

```
</div>
</div>
</p>

<p>And this is my form
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><form class="form-horizontal" method="post" action="edit_user.php">
  <div class="form-group">
    <label class="control-label col-sm-4" for="username">Username:</label>
    <div class="col-sm-6">
      <input type="username" class="form-control" name="username" placeholder="Enter username">
    </div>
  </div>
  <div class="form-group">
    <label class="control-label col-sm-4" for="email">Email:</label>
    <div class="col-sm-6">
      <input type="email" class="form-control" name="email" placeholder="Enter email">
    </div>
  </div>
    <div class="form-group">
    <label class="control-label col-sm-4" for="country">Country:</label>
    <div class="col-sm-6">
      <input type="country" class="form-control" name="country" placeholder="Enter Country">
    </div>
  </div>
  <div class="form-group">
    <label class="control-label col-sm-4" for="password">Password:</label>
    <div class="col-sm-6">
      <input type="password" class="form-control" name="password" placeholder="Enter password">
    </div>
  </div>
  <div class="form-group">

<label class="control-label col-sm-4" for="user_type">Level:</label>
<div class="col-sm-4">
<select class="form-control" name="user_type">
    <option value="user">User</option>
    <option value="admin">Admin</option>
</select>
</div>
</div><div class="form-group">
    <div class="col-sm-offset-4 col-sm-7">
      <button type="submit" class="btn btn-default">Delete</button>
      <button type="submit" class="btn btn-primary">Edit</button>
    </div>
  </div>
</form></code>```

Thank you before !

答:
First thing: Never, look, NEVER put the DB rules into frontend. Create other file and put the content there.

Second: You have one elegant way to do this: Use ajax calling to a php file with to routing/factoring the user object with the data to retrieve to your modal.

Put a bind into dropdown when event change is triggered, call the ajax function, retrieve the data with your db routine returning the user object and on the success callback put that object content into frontend using

```<code>document.getElementsByTag/ByName/getElementById.value
</code>```

, etcetera.

To study what you need, take that:
https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started
https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName

Body:
So i'm creating a Customize form so that i can edit my user data using a page.
I have a dropdown menu which is contain username from database.

What im gonna do is , when i click the username i want to costumize , all data of the username goes into the form below it ( like email,password,etc )

This pict explain what i wanted to do

This is my dropdown code :

Costumize Data

Select data to costumize

        <select class="form-control" name="userlist">
            <?php
               $servername = "localhost";
               $username = "root";
               $password = "";
               $dbname = "gamestore";

            // Create Connection
            $conn = mysqli_connect($servername, $username, $password, $dbname);

            // Check connection
            if (!$conn) {
                trigger_error("Connection failed: " . mysqli_connect_error());

            }
            //Run Query
            $stmt = "SELECT DISTINCT `username` FROM `login` ORDER BY user_id ASC";
            $result = mysqli_query($conn,$stmt) or die(mysqli_error($conn));
            while(list($category) = mysqli_fetch_row($result)){
                echo '<option value="'.$category.'">'.$category.'</option>';
            }
            mysqli_close($conn);
            ?>

        </select>

And this is my form

<form class="form-horizontal" method="post" action="edit_user.php">

    Username:

      <input type="username" class="form-control" name="username" placeholder="Enter username">

    Email:

      <input type="email" class="form-control" name="email" placeholder="Enter email">

    Country:

      <input type="country" class="form-control" name="country" placeholder="Enter Country">

    Password:

      <input type="password" class="form-control" name="password" placeholder="Enter password">

Level:

<select class="form-control" name="user_type">
    <option value="user">User</option>
    <option value="admin">Admin</option>
</select>

      <button type="submit" class="btn btn-default">Delete</button>
      <button type="submit" class="btn btn-primary">Edit</button>

</form>

Thank you before !

Body:
First thing: Never, look, NEVER put the DB rules into frontend. Create other file and put the content there.

Second: You have one elegant way to do this: Use ajax calling to a php file with to routing/factoring the user object with the data to retrieve to your modal.

Put a bind into dropdown when event change is triggered, call the ajax function, retrieve the data with your db routine returning the user object and on the success callback put that object content into frontend using

document.getElementsByTag/ByName/getElementById.value

, etcetera.

To study what you need, take that:
https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started
https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName


问:
Jquery is not working for menu. When i select a particular list in a menu its not getting active

```<code>  <ul>
    <li class="active" ><a href="home">Home</a></li>
    <li><a href="about">About</a></li>
    <li><a href="contact">Contact</a></li>
  </ul>
  <ul>
    <li><a href="login">Your Account</a></li>
    <li><a href="logout"> Logout</a></li>

    </ul>
</div>
</code>```

[HTML and Jquery code][1]https://i.stack.imgur.com/ASdUG.png

[html page output][2]: https://i.stack.imgur.com/gDGK7.png

答:
Try this code:

```<code>var selector = '.nav li';
$(selector).on('click', function(){
    $(selector).removeClass('active');
    $(this).addClass('active');
});
</code>```

And change the order of js file:

jQuery js file

bootstrap min.js

Body:
Home

About

Contact

Your Account

 Logout

[HTML and Jquery code][1]https://i.stack.imgur.com/ASdUG.png

[html page output][2]: https://i.stack.imgur.com/gDGK7.png

Body:
Try this code:

var selector = '.nav li';
$(selector).on('click', function(){
    $(selector).removeClass('active');
    $(this).addClass('active');
});

And change the order of js file:

jQuery js file

bootstrap min.js


问:
How to sort a Collection of Objects?
I have a class Gym which contains the following fields:

```<code>private int id;

private String name;

private String street;

private String housenumber;

private String zipcode;

private String lat;

private String lng;

private String city;
</code>```

All of the data is in a database. A user can filter gyms by some creteria: sports and distance. I have a function which gets all of the gyms out of the database and adds them to a layout.

The lat and lng fields also are in the database.

When a user requests all the gyms the distance between the user and the position is calculated using the following code:

```<code>double distance = Math.round(gpsHelper.calculateDistance(location.getLatitude(), Double.valueOf(gym.getLat()),
                location.getLongitude(), Double.valueOf(gym.getLng()), 0.0, 0.0));
 DecimalFormat df = new DecimalFormat("#.##");
String formattedDistance = "Afstand: " + String.valueOf(df.format(distance)) + " km";
</code>```

What I would like to do is the following: I would like to sort all the gyms by their distance to the user. So sort them by df.format(distance).

Could anyone give me a push into the right direction? I think I've added al the relevant code.

答:
Collections.sort

Collections.sort(List<T> list) sorts the specified list into ascending order, according to the natural ordering of its elements.

For example:

```<code>List<String> fruits = new ArrayList<String>();

fruits.add("Pineapple");
fruits.add("Apple");
fruits.add("Orange");
fruits.add("Banana");

Collections.sort(fruits);

int i=0;
for(String temp: fruits){
    System.out.println("fruits " + ++i + " : " + temp);
}
</code>```

Will give as output:

```<code>fruits 1 : Apple
fruits 2 : Banana
fruits 3 : Orange
fruits 4 : Pineapple
</code>```

See other examples at: Java object sorting example (Comparable and Comparator).

Comparator

Comparator is a comparison function, which imposes a total ordering on some collection of objects. Comparators can be passed to a sort method (such as Collections.sort or Arrays.sort) to allow precise control over the sort order.

```<code>Collections.sort(people, new Comparator<Person>() {

    @Override
    public int compare(Person o1, Person o2) {
        return o1.getLastName().compareTo(o2.getLastName());
    }
});
</code>```

Lambda Expressions

Java 8 introduced Lambda Expressions and the Comparator's equivalent is:

```<code>Comparator<Person> people =
    (Person o1, Person o2)->o1.getLastName().compareTo(o2.getLastName());
</code>```

Title: How to sort a Collection of Objects?

Body:
I have a class Gym which contains the following fields:

private int id;

private String name;

private String street;

private String housenumber;

private String zipcode;

private String lat;

private String lng;

private String city;

All of the data is in a database. A user can filter gyms by some creteria: sports and distance. I have a function which gets all of the gyms out of the database and adds them to a layout.

The lat and lng fields also are in the database.

When a user requests all the gyms the distance between the user and the position is calculated using the following code:

double distance = Math.round(gpsHelper.calculateDistance(location.getLatitude(), Double.valueOf(gym.getLat()),
                location.getLongitude(), Double.valueOf(gym.getLng()), 0.0, 0.0));
 DecimalFormat df = new DecimalFormat("#.##");
String formattedDistance = "Afstand: " + String.valueOf(df.format(distance)) + " km";

What I would like to do is the following: I would like to sort all the gyms by their distance to the user. So sort them by df.format(distance).

Could anyone give me a push into the right direction? I think I've added al the relevant code.

Body:
Collections.sort

Collections.sort(List<T> list) sorts the specified list into ascending order, according to the natural ordering of its elements.

For example:

List<String> fruits = new ArrayList<String>();

fruits.add("Pineapple");
fruits.add("Apple");
fruits.add("Orange");
fruits.add("Banana");

Collections.sort(fruits);

int i=0;
for(String temp: fruits){
    System.out.println("fruits " + ++i + " : " + temp);
}

Will give as output:

fruits 1 : Apple
fruits 2 : Banana
fruits 3 : Orange
fruits 4 : Pineapple

See other examples at: Java object sorting example (Comparable and Comparator).

Comparator

Comparator is a comparison function, which imposes a total ordering on some collection of objects. Comparators can be passed to a sort method (such as Collections.sort or Arrays.sort) to allow precise control over the sort order.

Collections.sort(people, new Comparator<Person>() {

    @Override
    public int compare(Person o1, Person o2) {
        return o1.getLastName().compareTo(o2.getLastName());
    }
});

Lambda Expressions

Java 8 introduced Lambda Expressions and the Comparator's equivalent is:

Comparator<Person> people =
    (Person o1, Person o2)->o1.getLastName().compareTo(o2.getLastName());


问:
Extreme case of "Error retrieving parent for item"
My Xamarin Android project doesn't compile anymore, with a couple error messages saying

Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget.Design.TabLayout'

Other errors that were thrown previously were in the same style, but said

No resource found that matches the given name (at 'textColor' with value '@color/md_white_1000')

I am aware that this is a very common Xamarin bug that is normally fixed by cleaning and rebuilding or, in rare cases, by clearing all packages and package caches so that they are downloaded again. However, this did not fix my error. I also completely reinstalled Xamarin and Visual Studio, but the error persists. At this point, i don't really know what to do except completely reformat my Mac.

Are there any trouble shooting steps I missed? Is this a bug that is only present in some version so that I need to downgrade? Please help, as I haven't been able to compile my code now for two days.

答: I found the answer: Apparently the newest version of the Xamarin AppCompat Package is corrupt. I was able to compile again by manually copying the project from my colleague, who hadn't updated his packages (the packages are in our .gitignore). That solved the problem and also explains why clearing the package caches didn't work: Visual Studio simply re-downloaded the corrupt package.</p>


问:
Bitcode WatchOS3 - how to generate
I am attempting to upload a watchOS3 app to the apple store, however I received a rejection (from apple) thats similar the below

Invalid Executable - The executable 'someWatch Extension' does not contain bitcode.
Once these issues have been corrected, you can then redeliver the corrected binary.

How can I resolve this? It seems like bitcode is mandatory as there is no longer a build setting in Xcode for my watch application to simply "Enable Bitcode=No".

I have also tried looking into running swiftc -embed-bitcode *.swift from my Watch Extensions directory, but I receive the below

MyController.swift:9:8: error: no such module 'WatchKit'
import WatchKit

I really have no clue what to do from here and it UBER frustrating with the lack of documentation out there for watchOS3 to get around this. PLEASE HELP

答:
For me the problem was that ENABLE_BITCODE=NO was set on the project level, and even though Watch did not have it set and should have resolved to YES which is the default for WatchOS, it was still resolved to NO - because of the inherited value from the project.

To resolve it, I removed the ENABLE_BITCODE value at the project level.
(to do this, select it in the Project Build Settings and press delete button on your keyboard so that text loses its boldness).

Title: Bitcode WatchOS3 - how to generate


问:
Convert binary vector to decimal
I have a vector of a binary string:

```<code>a<-c(0,0,0,1,0,1)
</code>```

I would like to convert this vector into decimal.

I tried using the compositions package and the unbinary() function, however, this solution and also most others that I have found on this site require g-adic string as input argument.

My question is how can I convert a vector rather than a string to decimal?

to illustrate the problem:

```<code>library(compositions)
unbinary("000101")
[1] 5
</code>```

This gives the correct solution, but:

```<code>unbinary(a)
unbinary("a")
unbinary(toString(a))
</code>```

produces NA.

答:
There is a one-liner solution:

Reduce(function(x,y) x*2+y, a)

Explanation:

Expanding the application of Reduce results in something like:

Reduce(function(x,y) x*2+y, c(0,1,0,1,0)) = (((0*2 + 1)*2 + 0)*2 + 1)*2 + 0 = 10

With each new bit coming next, we double the so far accumulated value and add afterwards the next bit to it.

Please also see the description of Reduce() function.

Title: Convert binary vector to decimal

Body:
I have a vector of a binary string:

a<-c(0,0,0,1,0,1)

I would like to convert this vector into decimal.

I tried using the compositions package and the unbinary() function, however, this solution and also most others that I have found on this site require g-adic string as input argument.

My question is how can I convert a vector rather than a string to decimal?

to illustrate the problem:

library(compositions)
unbinary("000101")
[1] 5

This gives the correct solution, but:

unbinary(a)
unbinary("a")
unbinary(toString(a))

produces NA.


问:
Jquery click event doesn't fire with Handlebars template
I have a problem with Jquery .on() function and Handlebars template. I wroted Handlebars template and add him dynamically in document:

```<code>$('.services-wrapper').append(serviceTemplate({index : ++maxIndex}));
</code>```

This template has a button:

```<code><p>
    <?= Html::buttonInput('Delete', [
    'class' => 'btn btn-danger delete-service',
    'id' => 'js-delete-service',
        'data' => [
        'index' => $index,
    ],
    ]) ?>
</p>
</code>```

So I wroted click handler on this button:

```<code>$('.service').on('click', '.delete-service', function (e) {
    alert('Clicked');
    //$(this).parent().parent().remove();
});
</code>```

When I add this template to document, click event doesn't fire. What is the problem?

答:
You try to attach the event handler to an element which doesn't exists in your DOM structure. Before adding on('click') try to console log $('.service'). You need to use event delegation: https://learn.jquery.com/events/event-delegation/
So in your case:

```<code>$( ".service-wrapper" ).on( "click", ".delete-service", function( event ) {
  event.preventDefault();
  alert('Clicked');
});
</code>```

Body:
I have a problem with Jquery .on() function and Handlebars template. I wroted Handlebars template and add him dynamically in document:

$('.services-wrapper').append(serviceTemplate({index : ++maxIndex}));

This template has a button:

    <?= Html::buttonInput('Delete', [
    'class' => 'btn btn-danger delete-service',
    'id' => 'js-delete-service',
        'data' => [
        'index' => $index,
    ],
    ]) ?>

So I wroted click handler on this button:

$('.service').on('click', '.delete-service', function (e) {
    alert('Clicked');
    //$(this).parent().parent().remove();
});

When I add this template to document, click event doesn't fire. What is the problem?

Body:
You try to attach the event handler to an element which doesn't exists in your DOM structure. Before adding on('click') try to console log $('.service'). You need to use event delegation: https://learn.jquery.com/events/event-delegation/
So in your case:

$( ".service-wrapper" ).on( "click", ".delete-service", function( event ) {
  event.preventDefault();
  alert('Clicked');
});


问:
How to refresh cards in Outlook Actionable Messages?
I'm trying to refresh a card in Outlook Actionable Messages, but the documentation doesn't specify how to do this, even though the functionality is mentioned.

I've tried returning new card data in my response using both application/json and application/ld+json, but neither of those seem to work.

I've also tried returning JSON in the CARD-ACTION-STATUS, but that doesn't have any effect either.

Is this functionality actually available?

答:
I can confirm that this functionality is available, but a critical piece of information is missing from the documentation: You need to set the CARD-UPDATE-IN-BODY header with a value of true and it will work.

Content type on the response doesn't seem to matter, and the CARD-ACTION-STATUS header seems to be ignored.


问:
Using HostListener/Binding with a NgFor Element in Angular 2
I have list of users. I want that when the cursor hover on the button, it sets *ngIf to true and then displays information about the user (and false when the cursor leave the button).

user-list.html:

{{user.name}}

{{user.description}}

```
<p><strong><code>user-list.component.ts</code>:</strong></p>
<pre class="lang-ts prettyprint-override"><code>import { Component, OnInit } from '@angular/core';
import { User } from 'class/user';
import { UserService } from 'user/user.service';

@Component({
  selector: 'user-list',
  templateUrl: 'user-list.component.html',
  providers: [UserService]
})
export class UserListComponent implements OnInit {
  users: User[];

  constructor(private userService: UserService) {
  };

  ngOnInit(): void {
    this.getUsers();
  }

  getUsers(): void {
    this.userService.getUsers().then(users => this.users = users);
  }

  toggleUser(user: User): void {
    user.active = !user.active;
  }
}
</code>```

I used "toggleUser(user: User)" like this :
(click)='toggleUser(user)', however I want now a onHover instead of click.

I saw the tutorial about directives attributes on Angular.io website and a StackOverflow topic on HostBinding('ngIf').

Hostbinding ngIf in Angular2

onUserHover.directive.ts:

 import { Directive, ElementRef, HostBinding, HostListener } from '@angular/core';

@Directive({ selector: '[onUserHover]' })
export class OnUserHoverDirective {

    constructor(private el: ElementRef) {
    }

    @HostBinding('ngIf') ngIf: boolean;

    @HostListener('mouseenter') onMouseEnter() {
        console.log('onMouseEnter');
        this.ngIf = true;
    }

    @HostListener('mouseleave') onmouseleave() {
        this.ngIf = false;
    }
}
```
<p><strong>But I have one error on the browser :</strong></p>
```Can't bind to `ngIf` since it isn't a known property of `div`
```

What can I do to implement this feature in Angular 2 style ?

答:
What you forgot is to bind the variable to the element

```<code><div onUserHover [ngIf]="ngif" *ngIf="ngIf">
</code>```

Your directive isn't working?

Did you remember to add the directive to the declarations attribute of
  @NgModule? It is easy to forget! Open the console in the browser tools
  and look for an error like this:

EXCEPTION: Template parse errors:   Can't bind to 'myHighlight' since
  it isn't a known property of 'p'.

Angular detects that you're trying to bind to something but it can't
  find this directive in the module's declarations array. After
  specifying HighlightDirective in the declarations array, Angular knows
  it can apply the directive to components declared in this module.

Body:
I have list of users. I want that when the cursor hover on the button, it sets *ngIf to true and then displays information about the user (and false when the cursor leave the button).

user-list.html:

{{user.name}}

{{user.description}}

user-list.component.ts:

import { Component, OnInit } from '@angular/core';
import { User } from 'class/user';
import { UserService } from 'user/user.service';

@Component({
  selector: 'user-list',
  templateUrl: 'user-list.component.html',
  providers: [UserService]
})
export class UserListComponent implements OnInit {
  users: User[];

  constructor(private userService: UserService) {
  };

  ngOnInit(): void {
    this.getUsers();
  }

  getUsers(): void {
    this.userService.getUsers().then(users => this.users = users);
  }

  toggleUser(user: User): void {
    user.active = !user.active;
  }
}

I used "toggleUser(user: User)" like this :
(click)='toggleUser(user)', however I want now a onHover instead of click.

I saw the tutorial about directives attributes on Angular.io website and a StackOverflow topic on HostBinding('ngIf').

Hostbinding ngIf in Angular2

onUserHover.directive.ts:

 import { Directive, ElementRef, HostBinding, HostListener } from '@angular/core';

@Directive({ selector: '[onUserHover]' })
export class OnUserHoverDirective {

    constructor(private el: ElementRef) {
    }

    @HostBinding('ngIf') ngIf: boolean;

    @HostListener('mouseenter') onMouseEnter() {
        console.log('onMouseEnter');
        this.ngIf = true;
    }

    @HostListener('mouseleave') onmouseleave() {
        this.ngIf = false;
    }
}

But I have one error on the browser :

Can't bind to `ngIf` since it isn't a known property of `div`

What can I do to implement this feature in Angular 2 style ?

Body:
What you forgot is to bind the variable to the element

<div onUserHover [ngIf]="ngif" *ngIf="ngIf">

Your directive isn't working?

Did you remember to add the directive to the declarations attribute of
  @NgModule? It is easy to forget! Open the console in the browser tools
  and look for an error like this:

EXCEPTION: Template parse errors:   Can't bind to 'myHighlight' since
  it isn't a known property of 'p'.

Angular detects that you're trying to bind to something but it can't
  find this directive in the module's declarations array. After
  specifying HighlightDirective in the declarations array, Angular knows
  it can apply the directive to components declared in this module.


问:
SQL database doesn't recognize non English characters
I'm trying to create a application which uses a database but I need it to save data as Unicode...
I changed the types to nchar or ntext but still it saves my characters as question marks
Any solution?
Thanks for your help</p>

答:
You have to tell the database that you're sending it unicode strings.

Using parameterized queries (which you should be for security):

```<code>SqlCommand cmd;
cmd.Parameters.Add("@mycolumn", SqlDbType.NVarChar, 255).Value = "hello";
</code>```

Using a straight query (please, for the sake of all things good, use parameterized queries):

```<code>string query = "INSERT INTO mytable (mycolumn) VALUES (N'hello');";
</code>```

P.S. it's probably better to use nvarchar in the database as opposed to nchar as I believe nchar will pad your strings to the field length.

Body:
You have to tell the database that you're sending it unicode strings.

Using parameterized queries (which you should be for security):

SqlCommand cmd;
cmd.Parameters.Add("@mycolumn", SqlDbType.NVarChar, 255).Value = "hello";

Using a straight query (please, for the sake of all things good, use parameterized queries):

string query = "INSERT INTO mytable (mycolumn) VALUES (N'hello');";

P.S. it's probably better to use nvarchar in the database as opposed to nchar as I believe nchar will pad your strings to the field length.


问:
Selenium script fails with TestNG annotation
Steps:
1. In eclipse I've created a new project named 'ForSe'.

Under 'src' folder → 'default package' I created a class named Login.java.

My code inside this class is like this:

```<code>public class Login_Valid {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver","*my path*");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.get("*URL of prject ForSe*");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//*@id='email_address']")).sendKeys("*email address*");
        driver.findElement(By.xpath("//*[@id='password']")).sendKeys("*Password*");
        driver.findElement(By.xpath("//*[@id='login-form']/div[4]/button")).click();
    }
}
</code>```

The scripts run very well when I run with run as java application.
But when I use the same script with TestNG, it skips/fails my test.

Steps taken to create TestNG script is as follows:

Installed TestNG and under same src creates a new package named ForSe_TestCases.java

My TestNG scripts is as follows:

```<code>public class ForSe_TestCases
{
    WebDriver driver;
    String url = "*project's URL*";

    @Test (priority = 0)
    public void IO_login(WebDriver driver)
    {

        //ForSe test environment URL
        driver.navigate().to(url);

        //this is official email address of IO
        driver.findElement(By.xpath("//*[@id='email_address']")).sendKeys("*email address*");

        //this is password
        driver.findElement(By.xpath("//*[@id='password']")).sendKeys("*Password*");

        //click on submit button to login
        driver.findElement(By.xpath("//*[@id='login-form']/div[4]/button")).click();
        System.out.println("Login button pressed");
    }

    @BeforeTest
    public void setup()
    {
        // Set property for Chrome
        System.setProperty("webdriver.chrome.driver","*my path*");
        WebDriver driver = new ChromeDriver();

        //apply implicit wait
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        //maximize window
        driver.manage().window().maximize();
    }
}
</code>```

I'm unable to understand at which step I'm going wrong. This the error message I get on running my test by Run as TestNG

```<code>    [Utils] [ERROR] [Error] org.testng.TestNGException:
    Cannot inject @Test annotated Method [IO_login] with [interface org.openqa.selenium.WebDriver].

    ===============================================
    Default test
        Tests run: 1, Failures: 1, Skips: 0
    ===============================================
    ===============================================
    Default suite
    Total tests run: 1, Failures: 1, Skips: 0
    ===============================================
</code>```

答:
Please replace your code with below and try, I tested it in my machine.

```<code>import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeTest;

public class Testngtest
{
WebDriver driver;
String url = "*project's URL*";

@Test (priority = 0)
public void IO_login()
{

    //ForSe test environment URL
    driver.navigate().to("Url");

    //this is official email address of IO
    driver.findElement(By.xpath("//*[@id='email_address']")).sendKeys("*email address*");

    //this is password
    driver.findElement(By.xpath("//*[@id='password']")).sendKeys("*Password*");

    //click on submit button to login
    driver.findElement(By.xpath("//*[@id='login-form']/div[4]/button")).click();
    System.out.println("Login button pressed");
}

@BeforeTest
public void setup()
{
    // Set property for Chrome

    System.setProperty("webdriver.chrome.driver","*my path*");

    driver = new ChromeDriver();

    //apply implicit wait
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    //maximize window
    driver.manage().window().maximize();
}
}
</code>```

Below are the changes that I made to original code.

1.Removed driver parameter to IO_login method()

2.Removed declaration of web driver in setup method again, we already declared it inside the class and outside of all methods.

Let me know if you have any queries.

Body:
Steps:
1. In eclipse I've created a new project named 'ForSe'.

Under 'src' folder → 'default package' I created a class named Login.java.

My code inside this class is like this:

public class Login_Valid {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver","*my path*");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.get("*URL of prject ForSe*");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//*@id='email_address']")).sendKeys("*email address*");
        driver.findElement(By.xpath("//*[@id='password']")).sendKeys("*Password*");
        driver.findElement(By.xpath("//*[@id='login-form']/div[4]/button")).click();
    }
}

The scripts run very well when I run with run as java application.
But when I use the same script with TestNG, it skips/fails my test.

Steps taken to create TestNG script is as follows:

Installed TestNG and under same src creates a new package named ForSe_TestCases.java

My TestNG scripts is as follows:

public class ForSe_TestCases
{
    WebDriver driver;
    String url = "*project's URL*";

    @Test (priority = 0)
    public void IO_login(WebDriver driver)
    {

        //ForSe test environment URL
        driver.navigate().to(url);

        //this is official email address of IO
        driver.findElement(By.xpath("//*[@id='email_address']")).sendKeys("*email address*");

        //this is password
        driver.findElement(By.xpath("//*[@id='password']")).sendKeys("*Password*");

        //click on submit button to login
        driver.findElement(By.xpath("//*[@id='login-form']/div[4]/button")).click();
        System.out.println("Login button pressed");
    }

    @BeforeTest
    public void setup()
    {
        // Set property for Chrome
        System.setProperty("webdriver.chrome.driver","*my path*");
        WebDriver driver = new ChromeDriver();

        //apply implicit wait
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        //maximize window
        driver.manage().window().maximize();
    }
}

I'm unable to understand at which step I'm going wrong. This the error message I get on running my test by Run as TestNG

    [Utils] [ERROR] [Error] org.testng.TestNGException:
    Cannot inject @Test annotated Method [IO_login] with [interface org.openqa.selenium.WebDriver].

    ===============================================
    Default test
        Tests run: 1, Failures: 1, Skips: 0
    ===============================================
    ===============================================
    Default suite
    Total tests run: 1, Failures: 1, Skips: 0
    ===============================================

Body:
Please replace your code with below and try, I tested it in my machine.

import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeTest;

public class Testngtest
{
WebDriver driver;
String url = "*project's URL*";

@Test (priority = 0)
public void IO_login()
{

    //ForSe test environment URL
    driver.navigate().to("Url");

    //this is official email address of IO
    driver.findElement(By.xpath("//*[@id='email_address']")).sendKeys("*email address*");

    //this is password
    driver.findElement(By.xpath("//*[@id='password']")).sendKeys("*Password*");

    //click on submit button to login
    driver.findElement(By.xpath("//*[@id='login-form']/div[4]/button")).click();
    System.out.println("Login button pressed");
}

@BeforeTest
public void setup()
{
    // Set property for Chrome

    System.setProperty("webdriver.chrome.driver","*my path*");

    driver = new ChromeDriver();

    //apply implicit wait
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    //maximize window
    driver.manage().window().maximize();
}
}

Below are the changes that I made to original code.

1.Removed driver parameter to IO_login method()

2.Removed declaration of web driver in setup method again, we already declared it inside the class and outside of all methods.

Let me know if you have any queries.


问:
How to use foreach in codeigniter
I am trying to get values from database table with use of foreach , as i am getting result but it is showing all value from table as i am using it for slide show how can i get 1 detail at single time...    This is my code

```<code> <div class="col-md-10">
  <div class="carousel slide" data-ride="carousel">
    <div class="carousel-inner">
        <?php
        $result_array = $this->db->get('vm_feedback')->result_array();
        foreach ($result_array as $key => $v) {?>
         <div class="item active">
         <div class="col-md-12">
            <div class="testimonial-text">
                <p style="color:black;"><?php  echo $v['feed_desc'];?></p>
                <span class="testimonial-by"><?php echo $v['feed_name'];?></span>
            </div>
         </div>
         </div>
        <?php   } ?>
    </div>
   </div>
  </div>
</code>```

Result i am geting:

what i need :

答:
If you want only one record you can go with row_array();</p>

```<code> <?php
        $v = $this->db->get('vm_feedback')->row_array();

         <div class="item active">
         <div class="col-md-12">
            <div class="testimonial-text">
                <p style="color:black;"><?php  echo $v['feed_desc'];?></p>
                <span class="testimonial-by"><?php echo $v['feed_name'];?></span>
            </div>
         </div>
         </div>
</code>```

Title: How to use foreach in codeigniter

Body:
I am trying to get values from database table with use of foreach , as i am getting result but it is showing all value from table as i am using it for slide show how can i get 1 detail at single time...    This is my code

        <?php
        $result_array = $this->db->get('vm_feedback')->result_array();
        foreach ($result_array as $key => $v) {?>

<?php  echo $v['feed_desc'];?>

                <?php echo $v['feed_name'];?>

        <?php   } ?>

Result i am geting:

what i need :

Body:
If you want only one record you can go with row_array();

 <?php
        $v = $this->db->get('vm_feedback')->row_array();

         <div class="item active">
         <div class="col-md-12">
            <div class="testimonial-text">
                <p style="color:black;"><?php  echo $v['feed_desc'];?></p>
                <span class="testimonial-by"><?php echo $v['feed_name'];?></span>
            </div>
         </div>
         </div>


问:
php array_multisort use array name as argument
Sorry if this is duplicate, I have tried to look at previous posts, but maybe my limited understanding of php gets in the way.

This works to sort arrays 1 and 3 by array 2:

```<code><?php

$ar[1] = array("game","scissors","rock","paper");
$ar[2] = array("D", "B", "A", "C");
$ar[3] =array("four","two","one","three");

array_multisort($ar[2],$ar[1],$ar[3]);

for ($j=0;$j<=3;$j++) {

    for ($i=1;$i<=3;$i++) {
  echo $ar[$i][$j]." ";
}
echo "\n";
}

?>
</code>```

output:

rock  A  one

 scissors  B  two

 paper  C  three

 game  D  four

Fine. But I want the list of arrays used as argument for array_multisort() to be specified by user input, so it can't be literal. Instead, I would like the program to decide the order of arrays in the list based on the user input and then name the resulting array of arrays $supar (superarray). But when using $supar as argument for array_multisort(), no sorting is carried out.

```<code><?php

$ar[1] = array("game","scissors","rock","paper");
$ar[2] = array("D", "B", "A", "C");
$ar[3] =array("four","two","one","three");

$supar = array($ar[2],$ar[1],$ar[3]);
array_multisort($supar);

for ($j=0;$j<=3;$j++) {

    for ($i=1;$i<=3;$i++) {
  echo $ar[$i][$j]." ";
}
echo "\n";
}

?>
</code>```

Output:

game  D  four

 scissors  B  two

 rock  A  one

 paper  C  three

How should I do to make array_multisort() sort the arrays in $supar by a specified $ar array?

Thank you for your patience.

答:
You can call array_multisort() (or any other function) without specifying its arguments explicitly if you have the arguments in an array by using call_user_func_array().

array_multisort() gets its arguments by reference (in order to be able to modify them). You have to consider this when you build the array you use as argument to call_user_func_array() and put references in this array:

```<code>// Input arrays
$ar[1] = array("game", "scissors", "rock", "paper");
$ar[2] = array("D", "B", "A", "C");
$ar[3] = array("four", "two", "one", "three");

// Build the list of arguments for array_multisort()
// Use references to the arrays you want it to sort
$supar = array(&$ar[2], &$ar[1], &$ar[3]);

// Call array_multisort() indirectly
// This is the same as array_multisort($ar[2], $ar[1], $ar[3]);
call_user_func_array('array_multisort', $supar);
</code>```

Check it in action: https://3v4l.org/ptiog

Body:
Sorry if this is duplicate, I have tried to look at previous posts, but maybe my limited understanding of php gets in the way.

This works to sort arrays 1 and 3 by array 2:

<?php

$ar[1] = array("game","scissors","rock","paper");
$ar[2] = array("D", "B", "A", "C");
$ar[3] =array("four","two","one","three");

array_multisort($ar[2],$ar[1],$ar[3]);

for ($j=0;$j<=3;$j++) {

    for ($i=1;$i<=3;$i++) {
  echo $ar[$i][$j]." ";
}
echo "\n";
}

?>

output:

rock  A  one

 scissors  B  two

 paper  C  three

 game  D  four

Fine. But I want the list of arrays used as argument for array_multisort() to be specified by user input, so it can't be literal. Instead, I would like the program to decide the order of arrays in the list based on the user input and then name the resulting array of arrays $supar (superarray). But when using $supar as argument for array_multisort(), no sorting is carried out.

<?php

$ar[1] = array("game","scissors","rock","paper");
$ar[2] = array("D", "B", "A", "C");
$ar[3] =array("four","two","one","three");

$supar = array($ar[2],$ar[1],$ar[3]);
array_multisort($supar);

for ($j=0;$j<=3;$j++) {

    for ($i=1;$i<=3;$i++) {
  echo $ar[$i][$j]." ";
}
echo "\n";
}

?>

Output:

game  D  four

 scissors  B  two

 rock  A  one

 paper  C  three

How should I do to make array_multisort() sort the arrays in $supar by a specified $ar array?

Thank you for your patience.

Body:
You can call array_multisort() (or any other function) without specifying its arguments explicitly if you have the arguments in an array by using call_user_func_array().

array_multisort() gets its arguments by reference (in order to be able to modify them). You have to consider this when you build the array you use as argument to call_user_func_array() and put references in this array:

// Input arrays
$ar[1] = array("game", "scissors", "rock", "paper");
$ar[2] = array("D", "B", "A", "C");
$ar[3] = array("four", "two", "one", "three");

// Build the list of arguments for array_multisort()
// Use references to the arrays you want it to sort
$supar = array(&$ar[2], &$ar[1], &$ar[3]);

// Call array_multisort() indirectly
// This is the same as array_multisort($ar[2], $ar[1], $ar[3]);
call_user_func_array('array_multisort', $supar);

Check it in action: https://3v4l.org/ptiog


问:
Project Rider Local Database File
I am looking for a way to include a standart .MDF database to my C# project in Project Rider. I really like the way it works with Databases.

I know that Visual Studio uses Microsoft SQL Server databases, even for local ones, but i can't use a local file of .MDF type for an SQL Server in Porject Rider.

Is there a way to accomplish the connection? If not, what could be a good alternative for a local database?

Thanks!

答: You can't just use a MDF file directly, it must be used with SQL Server.  If you are looking for some kind of local database just to be able to store some data and query it in SQL format, take a look at SQLite or look into Microsoft SQL Server Express or greater.</p>

Title: Project Rider Local Database File


问:
What causes "resource temporarily unavailable" in v4l2
I have compiled adv7180 driver available here.

I am unloading the ov5642 cameradriver(which in my case is built-in) and loading the adv7180_tvin module and after I am loading mxcv4l2_capture module which creates video0 in /dev/.
(dmesg command says: "mxc camera on IPU2_CSI1 registered as video0")

But when I try to access video0 with v4l2-ctl I got a message "resource temporarily unavailable" or when I am using gstreamer I got message "Can not open /dev/video0" (but the device is really created).

Is that a problem in device tree settings or it can be caused by something else? Which tools should I use to find out what causes this issue?

My device tree settings look like below:

```<code>&i2c3{
adv7180: adv7180@20{
compatible = "adv,adv7180";
reg = <0x20>;
clocks = <&clks IMX6QDL_CLK_CKO2>;
clock-names = "csi_mclk";
pwn-gpios = <&gpio3 10 GPIO_ACTIVE_LOW>;
ipu_id = <1>;
csi_id = <1>;
mclk = <24000000>;
mclk_source = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hummingboard2_parallel>;

cvbs = <1>;

};
};
</code>```

I need to add that before adv7180 I was using above settings for ov5642 camera (excluding cvbs setting) and everything worked properly.

EDIT:

Ok I got one clue.

When I load modules in dmesg message "mxc_v4l2_master_attach: ipu(0:1)/csi(1:1)/mipi(0:0) doesn't match" shows.
But it only happens when ipu_id=<1> in v4l2_cap device tree settings and in adv7180 settings. When i change ipu_id to ipu_id=<0> in v4l2 settings and adv7180 dmesg now shows "parallel attach to IPU1 CSI1 and I can access the /dev/video0 succesfully with v4l2-ctl tool.

But In my case there is only one possibility to use IPU2_CSI1.

Why can't I set IPU2 to adv7180 when I was using it successfully to ov5642 ?

答:
Ok. I found it !

I couldn't set bit 20 in IOMUXC_GPR1 register using mach-imx6q.c file so I did it this way:

in console:

```<code>sudo devmem2 0x20e0004
</code>```

and read the existing value (which was in my case 0x48643005). Then I set bit 20 to one ("1") so I got 0x48743005 and I put this value into the register:

```<code>sudo devmem2 0x20e0004 w 0x48743005
</code>```

next I loaded adv7180_tvin and mxc_v4l2_capture modules and captured frames using gsreamer:

```<code>gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! imxipuvideotransform ! autovideosink deinterlace=true
</code>```

Everything works great ! Thanks for help !

Body:
I have compiled adv7180 driver available here.

I am unloading the ov5642 cameradriver(which in my case is built-in) and loading the adv7180_tvin module and after I am loading mxcv4l2_capture module which creates video0 in /dev/.
(dmesg command says: "mxc camera on IPU2_CSI1 registered as video0")

But when I try to access video0 with v4l2-ctl I got a message "resource temporarily unavailable" or when I am using gstreamer I got message "Can not open /dev/video0" (but the device is really created).

Is that a problem in device tree settings or it can be caused by something else? Which tools should I use to find out what causes this issue?

My device tree settings look like below:

&i2c3{
adv7180: adv7180@20{
compatible = "adv,adv7180";
reg = <0x20>;
clocks = <&clks IMX6QDL_CLK_CKO2>;
clock-names = "csi_mclk";
pwn-gpios = <&gpio3 10 GPIO_ACTIVE_LOW>;
ipu_id = <1>;
csi_id = <1>;
mclk = <24000000>;
mclk_source = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hummingboard2_parallel>;

cvbs = <1>;

};
};

I need to add that before adv7180 I was using above settings for ov5642 camera (excluding cvbs setting) and everything worked properly.

EDIT:

Ok I got one clue.

When I load modules in dmesg message "mxc_v4l2_master_attach: ipu(0:1)/csi(1:1)/mipi(0:0) doesn't match" shows.
But it only happens when ipu_id=<1> in v4l2_cap device tree settings and in adv7180 settings. When i change ipu_id to ipu_id=<0> in v4l2 settings and adv7180 dmesg now shows "parallel attach to IPU1 CSI1 and I can access the /dev/video0 succesfully with v4l2-ctl tool.

But In my case there is only one possibility to use IPU2_CSI1.

Why can't I set IPU2 to adv7180 when I was using it successfully to ov5642 ?

Body:
Ok. I found it !

I couldn't set bit 20 in IOMUXC_GPR1 register using mach-imx6q.c file so I did it this way:

in console:

sudo devmem2 0x20e0004

and read the existing value (which was in my case 0x48643005). Then I set bit 20 to one ("1") so I got 0x48743005 and I put this value into the register:

sudo devmem2 0x20e0004 w 0x48743005

next I loaded adv7180_tvin and mxc_v4l2_capture modules and captured frames using gsreamer:

gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! imxipuvideotransform ! autovideosink deinterlace=true

Everything works great ! Thanks for help !


问:
MVC 5 Owin Facebook Auth results in Null Reference Exception
I'm trying to setup integrated OWIN Facebook authentication in a new MVC 5 project in Visual Studio 2013. I have configured apps and keys as per this tutorial:

http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

However, I'm getting a NullReferenceException thrown from this call in the AccountController:

```<code>    [AllowAnonymous]
    public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
    {
        var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
</code>```

I already checked the response in Fiddler and am getting what appears to be a success response from Facebook, but still get this error. The response looks like this:

```<code>{"id":"xxx","name":"xxx","first_name":"xxx","last_name":"xxx","link":
"https:\/\/www.facebook.com\/profile.php?id=xxx","location":{"id":"xxx","name":"xxx"},
"gender":"xxx","timezone":1,"locale":"en_GB","verified":true,"updated_time":"2013-10-23T10:42:23+0000"}
</code>```

I get this when debugging in http as well as https. I'm guessing this is a framework bug but have so far drawn a blank diagnosing this through reflector.

答:
I came across this post a few days ago but unfortunately none of the above solutions worked for me. so here is how I managed to fix it and get the email from Facebook.

Update following NuGet Pacakges

Microsoft.Owin to version 3.1.0-rc1

Microsoft.Owin.Security to version 3.1.0-rc1

Microsoft.Owin.Security.Cookies to version 3.1.0-rc1

Microsoft.Owin.Security.OAuth to version 3.1.0-rc1

Microsoft.Owin.Security.Facebook to version 3.1.0-rc1

Then add the following code to the Identity Startup class

```<code>var facebookOptions = new FacebookAuthenticationOptions()
        {
            AppId = "your app id",
            AppSecret = "your app secret",
            BackchannelHttpHandler = new FacebookBackChannelHandler(),
            UserInformationEndpoint = "https://graph.facebook.com/v2.8/me?fields=id,name,email,first_name,last_name",
            Scope = { "email" }
        };

        app.UseFacebookAuthentication(facebookOptions);
</code>```

This is the definition class for FacebookBackChannelHandler():

```<code>using System;
using System.Net.Http;

public class FacebookBackChannelHandler : HttpClientHandler
{
    protected override async System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request,
        System.Threading.CancellationToken cancellationToken)
    {
        // Replace the RequestUri so it's not malformed
        if (!request.RequestUri.AbsolutePath.Contains("/oauth"))
        {
            request.RequestUri = new Uri(request.RequestUri.AbsoluteUri.Replace("?access_token", "&access_token"));
        }

        return await base.SendAsync(request, cancellationToken);
    }
}
</code>```

Body:
I'm trying to setup integrated OWIN Facebook authentication in a new MVC 5 project in Visual Studio 2013. I have configured apps and keys as per this tutorial:

http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

However, I'm getting a NullReferenceException thrown from this call in the AccountController:

    [AllowAnonymous]
    public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
    {
        var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

I already checked the response in Fiddler and am getting what appears to be a success response from Facebook, but still get this error. The response looks like this:

{"id":"xxx","name":"xxx","first_name":"xxx","last_name":"xxx","link":
"https:\/\/www.facebook.com\/profile.php?id=xxx","location":{"id":"xxx","name":"xxx"},
"gender":"xxx","timezone":1,"locale":"en_GB","verified":true,"updated_time":"2013-10-23T10:42:23+0000"}

I get this when debugging in http as well as https. I'm guessing this is a framework bug but have so far drawn a blank diagnosing this through reflector.

Body:
I came across this post a few days ago but unfortunately none of the above solutions worked for me. so here is how I managed to fix it and get the email from Facebook.

Update following NuGet Pacakges

Microsoft.Owin to version 3.1.0-rc1

Microsoft.Owin.Security to version 3.1.0-rc1

Microsoft.Owin.Security.Cookies to version 3.1.0-rc1

Microsoft.Owin.Security.OAuth to version 3.1.0-rc1

Microsoft.Owin.Security.Facebook to version 3.1.0-rc1

Then add the following code to the Identity Startup class

var facebookOptions = new FacebookAuthenticationOptions()
        {
            AppId = "your app id",
            AppSecret = "your app secret",
            BackchannelHttpHandler = new FacebookBackChannelHandler(),
            UserInformationEndpoint = "https://graph.facebook.com/v2.8/me?fields=id,name,email,first_name,last_name",
            Scope = { "email" }
        };

        app.UseFacebookAuthentication(facebookOptions);

This is the definition class for FacebookBackChannelHandler():

using System;
using System.Net.Http;

public class FacebookBackChannelHandler : HttpClientHandler
{
    protected override async System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request,
        System.Threading.CancellationToken cancellationToken)
    {
        // Replace the RequestUri so it's not malformed
        if (!request.RequestUri.AbsolutePath.Contains("/oauth"))
        {
            request.RequestUri = new Uri(request.RequestUri.AbsoluteUri.Replace("?access_token", "&access_token"));
        }

        return await base.SendAsync(request, cancellationToken);
    }
}


问:
Is PHP used for quick and easy website where other languages are used in more complex websites?
I just put this question in serverfault.com and I know that this question may be rejected in Stackoverflow.

But I thought programmers know better.

This stat shows that PHP is used by 75.2% of all the websites whose server-side programming language.

http://w3techs.com/technologies/overview/programming_language/all

And this page shows that PHP is the least used server-side language in ranked by usage on top websites

http://w3techs.com/technologies/topsite/programming_language

Q1. Does this mean PHP is used for quick and easy website where other languages are used in more complex websites?

Q2. Why PHP is ranked at the bottom? Or why big company tend to use other language than PHP?

Update: I know that facebook and other biggies uses PHP. But it does not tell why there are more other languages are used in top websites.

答:
It's not so much a matter of the language itself, otherwise python would score much higher for low-profile web sites, since it's easier to learn and has fewer pitfalls than PHP.

However, PHP is the only language you can really expect on a cheap shared host, and this makes it the only viable choice when you don't get to pick your platform specifics. Consequently, shrink-wrap software targeted at such environments uses PHP.
High-profile sites run on their own servers, and the choice of language is determined by other factors: ease of use (a.k.a. developer performance), suitability for the problem domain, suitability for the preferred programming paradigm (procedural, object-oriented, data-centric, functional, etc.), the team's personal preferences and experience, available libraries, runtime performance, existing codebase, existing system components.

ContentLicense: CC BY-SA 2.5


问:
How to set parent window overtop child window in Qt
I want the parent window to always be on top of the child window.

```<code>QMainWindow a();
a.show();

QMainWindow b(&a);
mat.show();
</code>```

How to set a over b?

答:
Your setup seems a bit weird. The mainwindow B with A as its parent. If you want to have independants window, I think you should remove the inheritance link.

In this cas, you can change the order of the show calls to change the order of the window :

```<code>QMainWindow a;
QMainWindow b;

b.show();
a.show();
</code>```

If you're sure that's the way you want to go, you have mlultiple solution.

May you can call the show method in an other order ? Untested.

Maybe you can set up the windows flags before calling the show. If you want to have A over everything, in a permanent way, you change the windows flags :

It would be something like:

```<code>QMainWindow a;
QMainWindow b;

a.setWindowsFlags(Qt::WindowStaysOnTopHint| Qt::X11BypassWindowManagerHint);
a.show();
b.show();
</code>```

If you want to manipulate the "who is over who" in your app, maybe you should unite them in a stack, or giving them a common ancestor, or something like that.

Body:
I want the parent window to always be on top of the child window.

QMainWindow a();
a.show();

QMainWindow b(&a);
mat.show();

How to set a over b?

Body:
Your setup seems a bit weird. The mainwindow B with A as its parent. If you want to have independants window, I think you should remove the inheritance link.

In this cas, you can change the order of the show calls to change the order of the window :

QMainWindow a;
QMainWindow b;

b.show();
a.show();

If you're sure that's the way you want to go, you have mlultiple solution.

May you can call the show method in an other order ? Untested.

Maybe you can set up the windows flags before calling the show. If you want to have A over everything, in a permanent way, you change the windows flags :

It would be something like:

QMainWindow a;
QMainWindow b;

a.setWindowsFlags(Qt::WindowStaysOnTopHint| Qt::X11BypassWindowManagerHint);
a.show();
b.show();

If you want to manipulate the "who is over who" in your app, maybe you should unite them in a stack, or giving them a common ancestor, or something like that.


问:
Months with less than 31 days omitted from list
Consider the following code that was working perfectly yesterday, but now today (30th March), it has stopped working...

```<code><form class="date">
<select name="date" onchange="this.form.submit()">

<?php
  for ($i = 0; $i <= 60; ++$i) {
    $time = strtotime(sprintf('+%d months', $i));
    $value = date('Y-m', $time);
    $label = date('F Y', $time);
    $nowvalue = date('Y-m');
    $nowlabel = date('F Y');
        if(isset($_GET['date'])) {
          if(strcmp($value,$_GET['date']) == 0) {
             //If 0, $value and $_GET['date'] are the same: The option is selected
             printf('<option value="%s" selected>%s</option>', $value, $label);
          } else {
             printf('<option value="%s">%s</option>', $value, $label);
          }
        } else {
          if($value == $nowvalue) {
            printf('<option value="%s" selected>%s</option>', $value, $label);
          } else {
            printf('<option value="%s">%s</option>', $value, $label);
          }
    }
  }
  ?>
</select>
</form>
</code>```

This outputs a select list of upcoming months, that onchange, reloads the page with a different query in the URL for the calendar on that page to react on.

If i manually update the query in the URL, it works fine, but this select list is repeating dates, have a look at the image below...

This cant be a coincidence that all of the months with the shortest days are missing, or in fact have been replaced with the same name as the month before?

Does anyone have an idea why this might be happening?

答:
This is because when you loop through dates on a monthly basis on the 31st of the month you will come across months that have less than 30 days. PHP does automatically adjust the date to the last day of the month but instead goes to the end of the month and then adds the remaining days to it and gets the date that way which is the next month.

So if you get to February, which only has 28 days (most years) it will get to the 28th and add three days and give you March 3rd.

To solve this you need to set the date to the first day of the month and then iterate through the dates.

Body:
Consider the following code that was working perfectly yesterday, but now today (30th March), it has stopped working...

<form class="date">
<select name="date" onchange="this.form.submit()">

<?php
  for ($i = 0; $i <= 60; ++$i) {
    $time = strtotime(sprintf('+%d months', $i));
    $value = date('Y-m', $time);
    $label = date('F Y', $time);
    $nowvalue = date('Y-m');
    $nowlabel = date('F Y');
        if(isset($_GET['date'])) {
          if(strcmp($value,$_GET['date']) == 0) {
             //If 0, $value and $_GET['date'] are the same: The option is selected
             printf('<option value="%s" selected>%s</option>', $value, $label);
          } else {
             printf('<option value="%s">%s</option>', $value, $label);
          }
        } else {
          if($value == $nowvalue) {
            printf('<option value="%s" selected>%s</option>', $value, $label);
          } else {
            printf('<option value="%s">%s</option>', $value, $label);
          }
    }
  }
  ?>
</select>
</form>

This outputs a select list of upcoming months, that onchange, reloads the page with a different query in the URL for the calendar on that page to react on.

If i manually update the query in the URL, it works fine, but this select list is repeating dates, have a look at the image below...

This cant be a coincidence that all of the months with the shortest days are missing, or in fact have been replaced with the same name as the month before?

Does anyone have an idea why this might be happening?


问:
LinPhone Android sdk integration
I have to integrate linphone sdk in my android project for video calling functionality.

I have research and found the below link to download the sample code

https://github.com/BelledonneCommunications/linphone-android

and configure with my android studio and install NDK for it in windows7 system but it missing the classes for the running sample.

```<code>import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.mediastream.Log;
</code>```

This type of files are missing in the sample code.

Please provide me the steps to start integrating linphone in my android app.

Thank you in advance.

答:
Please read the instructions under

COMPILATION INSTRUCTIONS

To build liblinphone for Android, you must:

https://github.com/BelledonneCommunications/linphone-android

Follow each step and if you run into any specific issue then post it with details so that someone can help you.

Note:

1) Make sure you clone the github repo properly. When cloned properly you'll get all the libraries.

2) Don't forget that you will need to make as mentioned in the instructions:

Run the Makefile script in the top level directory, make.

Title: LinPhone Android sdk integration

Body:
I have to integrate linphone sdk in my android project for video calling functionality.

I have research and found the below link to download the sample code

https://github.com/BelledonneCommunications/linphone-android

and configure with my android studio and install NDK for it in windows7 system but it missing the classes for the running sample.

import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.mediastream.Log;

This type of files are missing in the sample code.

Please provide me the steps to start integrating linphone in my android app.

Thank you in advance.


问:
Invalid Gradle JDK configuration found: Android Studio
When Launching the Android Studio getting this exception every time and project is not run.

Error:Invalid Gradle JDK configuration found. Open Gradle Settings
Platform SDK does not point to valid JDK (/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home)

答: I was having same kind of problem with my machine which has program files located on the network and Java_Home environment variable was pointing to the program files location which was on the network. I installed a local Java JDK and defined the JDK path in Java_Home environment variable. This worked for me.