Test-NetConnection gives inconsistent results - c#

run into an interesting one today.
I have a bunch of code in C# that creates uses Powershell via a RunspacePool.
I feed it commands and it outputs exactly what Powershell would output if you ran Powershell on it's own, each line is a new entry in a List.
The strange thing is, today when trying the "Test-NetConnection" command in the program it has inconsistent results.
Command:
Test-NetConnection -ComputerName 'D123' -InformationLevel Detailed
D123 is a Windows 7 VM on the same network
Below you can see two results, it appears to be a 50% chance of getting either:
Count = 32
[0]: "ComputerName : D123"
[1]: "RemoteAddress : fe80::9503:8d01:d690:6c0a%14"
[2]: "PingSucceeded : True"
[3]: "PingReplyDetails : System.Net.NetworkInformation.PingReply"
[4]: "TcpClientSocket :"
[5]: "TcpTestSucceeded : False"
[6]: "RemotePort : 0"
[7]: "TraceRoute :"
[8]: "Detailed : True"
[9]: "InterfaceAlias : Internal"
[10]: "InterfaceIndex : 14"
[11]: "InterfaceDescription : Intel(R) 82574L Gigabit Network Connection #2"
[12]: "NetAdapter : MSFT_NetAdapter (CreationClassName = "MSFT_NetAdapter", DeviceID ="
[13]: ""{FDA85168-53B0-4F24-ABEB-BDC9F3A29958}", SystemCreationClassName = "CIM_NetworkPort","
[14]: "SystemName = "WIN-IAJUP1S3FL9.testdomain.com")"
[15]: "NetRoute : MSFT_NetRoute (InstanceID = "poB:DD9#?55"
[16]: "?55DD55"
[17]: "")"
[18]: "SourceAddress : MSFT_NetIPAddress (Name = "poB:DDl:pBD?:lDpC:mDmp?o/"
[19]: "?55"
[20]: "?55"
[21]: "55"
[22]: "", CreationClassName = "","
[23]: "SystemCreationClassName = "", SystemName = "")"
[24]: "NameResolutionSucceeded : True"
[25]: "BasicNameResolution : {}"
[26]: "LLMNRNetbiosRecords : {}"
[27]: "DNSOnlyRecords : {}"
[28]: "AllNameResolutionResults :"
[29]: "IsAdmin : True"
[30]: "NetworkIsolationContext : Private Network"
[31]: "MatchingIPsecRules :"
Or
Count = 9
[0]: "ComputerName : D123"
[1]: "RemoteAddress : fe80::9503:8d01:d690:6c0a%14"
[2]: "AllNameResolutionResults : 172.16.0.10"
[3]: "fe80::9503:8d01:d690:6c0a"
[4]: "InterfaceAlias : Internal"
[5]: "SourceAddress : fe80::b0f8:20b:f90c:cf3e%14"
[6]: "NetRoute (NextHop) : ::"
[7]: "PingSucceeded : True"
[8]: "PingReplyDetails (RTT) : 0 ms"
The second block is what it should be returning, it is also what the command shows when running on Powershell.
What i'd like to know is why it is returning so many values, from the looks of it it's returning results for all members in the command and not just the op level ones (if that makes sense, look here: Working with .NET properties in Power Shell), but I have absolutely no idea why.
EDIT1: The blocks of output are copy+pastes from Visual Studio, so the Count = 32 is how many lines Powershell passed back and the [number] is the List position.
EDIT2: It seems that the more details is coming from adding " | select *" to the command, this is strange though because none of my code does this and it gets the additional details 50% of the time.

Thanks to the help of Veefu and John I looked into my code more.
Unsure why it does this, but whenever I had the Powershell code run in the main Window Load event it would affect all subsequent executions of the same Powershell command.
When moved to a different section of the code it behaved as expected.
Unsure why this was happening but selecting specific properties from the Powershell output is more consistent, so to anyone who looks at this I'd suggest doing as Veefu said in the comments.

Related

visual studio Immediate Windows

I am working on debuging some logic and wanted to see if there is a way I can display this full list?
Cache.Select(Cache => Cache.Id.ToString());
{System.Linq.Enumerable.WhereSelectListIterator<OrderTemplateTool.Data.Dictionary, string>}
[0]: "4c5d3244-40cf-4ee2-a874-3f269b441a6d"
[1]: "2873049b-968a-4c9e-977f-38a8f14a35b6"
[2]: "272e63d0-494e-4d61-b621-c70a137b4b93"
....
[98]: "3f021aae-d54f-4d23-a257-c507b14ee46c"
[99]: "8b54508f-d6b4-4ced-ab58-5d3d3815d7bd"
< More... (The first 100 of 209 items were displayed.) >

BSOD 0x8E STATUS_SINGLE_STEP

I have a BSOD 0x8E every day on five devices in same times on Windows 7.
Allways exception code - 04 - STATUS_SINGLE_STEP
as example:
1: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
KERNEL_MODE_EXCEPTION_NOT_HANDLED_M (1000008e)
This is a very common bugcheck. Usually the exception address pinpoints
the driver/function that caused the problem. Always note this address
as well as the link date of the driver/image that contains this address.
Some common problems are exception code 0x80000003. This means a hard
coded breakpoint or assertion was hit, but this system was booted
/NODEBUG. This is not supposed to happen as developers should never have
hardcoded breakpoints in retail code, but ...
If this happens, make sure a debugger gets connected, and the
system is booted /DEBUG. This will let us see why this breakpoint is
happening.
Arguments:
Arg1: 80000004, The exception code that was not handled
Arg2: ffdff2a5, The address that the exception occurred at
Arg3: a9c34d48, Trap Frame
Arg4: 00000000
Debugging Details:
------------------
DUMP_CLASS: 1
DUMP_QUALIFIER: 400
BUILD_VERSION_STRING: 7601.17514.x86fre.win7sp1_rtm.101119-1850
SYSTEM_MANUFACTURER: System manufacturer
SYSTEM_PRODUCT_NAME: System Product Name
SYSTEM_SKU: SKU
SYSTEM_VERSION: System Version
BIOS_VENDOR: American Megatrends Inc.
BIOS_VERSION: 1002
BIOS_DATE: 06/04/2013
BASEBOARD_MANUFACTURER: ASUSTeK COMPUTER INC.
BASEBOARD_PRODUCT: P8H61-I LX R2.0
BASEBOARD_VERSION: Rev X.0x
DUMP_TYPE: 2
BUGCHECK_P1: ffffffff80000004
BUGCHECK_P2: ffffffffffdff2a5
BUGCHECK_P3: ffffffffa9c34d48
BUGCHECK_P4: 0
EXCEPTION_CODE: (HRESULT) 0x80000004 (2147483652) - <Unable to get error code text>
FAULTING_IP:
+0
ffdff2a5 0000 add byte ptr [eax],al
TRAP_FRAME: a9c34d48 -- (.trap 0xffffffffa9c34d48)
ErrCode = 00000000
eax=00000000 ebx=846410c0 ecx=00000000 edx=00000000 esi=0c4cdb04 edi=00000000
eip=ffdff2a5 esp=a9c34dbc ebp=801ef000 iopl=0 ov dn di ng nz na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00004c86
ffdff2a5 0000 add byte ptr [eax],al ds:0023:00000000=??
Resetting default scope
CPU_COUNT: 2
CPU_MHZ: a8c
CPU_VENDOR: GenuineIntel
CPU_FAMILY: 6
CPU_MODEL: 3a
CPU_STEPPING: 9
CPU_MICROCODE: 6,3a,9,0 (F,M,S,R) SIG: 17'00000000 (cache) 17'00000000 (init)
CUSTOMER_CRASH_COUNT: 1
DEFAULT_BUCKET_ID: BAD_STACK_0x8E
BUGCHECK_STR: 0x8E
PROCESS_NAME: avp.exe
CURRENT_IRQL: 0
ANALYSIS_SESSION_HOST: NETMANNOTE
ANALYSIS_SESSION_TIME: 11-17-2017 12:11:18.0584
ANALYSIS_VERSION: 10.0.15063.468 x86fre
LAST_CONTROL_TRANSFER: from 00000000 to ffdff2a5
STACK_TEXT:
a9c34db8 00000000 0000027f 00000000 00000000 0xffdff2a5
STACK_COMMAND: .trap 0xffffffffa9c34d48 ; kb
SYMBOL_NAME: ANALYSIS_INCONCLUSIVE
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: Unknown_Module
IMAGE_NAME: Unknown_Image
DEBUG_FLR_IMAGE_TIMESTAMP: 0
BUCKET_ID: BAD_STACK_0x8E
PRIMARY_PROBLEM_CLASS: BAD_STACK
FAILURE_BUCKET_ID: BAD_STACK_0x8E
TARGET_TIME: 2017-11-16T13:53:07.000Z
OSBUILD: 7601
OSSERVICEPACK: 1000
SERVICEPACK_NUMBER: 0
OS_REVISION: 0
SUITE_MASK: 336
PRODUCT_TYPE: 1
OSPLATFORM_TYPE: x86
OSNAME: Windows 7
OSEDITION: Windows 7 WinNt (Service Pack 1) TerminalServer EmbeddedNT SingleUserTS
OS_LOCALE:
USER_LCID: 0
OSBUILD_TIMESTAMP: 2010-11-20 11:42:49
BUILDDATESTAMP_STR: 101119-1850
BUILDLAB_STR: win7sp1_rtm
BUILDOSVER_STR: 6.1.7601.17514.x86fre.win7sp1_rtm.101119-1850
ANALYSIS_SESSION_ELAPSED_TIME: cc3
ANALYSIS_SOURCE: KM
FAILURE_ID_HASH_STRING: km:bad_stack_0x8e
FAILURE_ID_HASH: {993602b9-6aa7-fbab-86a8-bb6ad81a3997}
Followup: MachineOwner
The service name can be different: av.exe, scvhost.ext,..
I know that is due to the a driver does not process STATUS_SINGLE_STEP exception.
Is any idea how to find wrong driver? There is no stack and module name in the dump...
I tried to run the Mirosoft Driver Verifier with standart flags and all drivers without Microsoft drivers, dump listing is above.

XAML Parse Exception on project deploy error

I have a WPF application that works fine on certain platforms and systems, including, of course, the development system, however, it runs into issues on some, but not all, platforms on deploy. This sounds like an issue with regard to dependencies, of course, but I'm not sure how to track down what/which.
The WERInternalMetadata.xml problem signature shows:
<ProblemSignatures>
<EventType>CLR20r3</EventType>
<Parameter0>QroLockdownShell.exe</Parameter0>
<Parameter1>1.0.0.0</Parameter1>
<Parameter2>559aaa45</Parameter2>
<Parameter3>mscorlib</Parameter3>
<Parameter4>4.0.30319.34209</Parameter4>
<Parameter5>534894cc</Parameter5>
<Parameter6>4527</Parameter6>
<Parameter7>105</Parameter7>
<Parameter8>System.Windows.Markup.XamlParse</Parameter8>
</ProblemSignatures>
When I use ILDASM to look for 105 from Parameter 7, it leads me to this:
Method #19 (06000105)
-------------------------------------------------------
MethodName: get_BackgroundImage (06000105)
Flags : [Public] [HideBySig] [ReuseSlot] [SpecialName] (00000886)
RVA : 0x00004478
ImplFlags : [IL] [Managed] (00000000)
CallCnvntn: [DEFAULT]
hasThis
ReturnType: Class System.Windows.Media.ImageSource
No arguments.
CustomAttribute #1 (0c0000ed)
-------------------------------------------------------
CustomAttribute Type: 0a00002f
CustomAttributeName: System.Runtime.CompilerServices.CompilerGeneratedAttribute :: instance void.ctor()
Length: 4
Value : 01 00 00 00 > <
ctor args: ()
I'm not sure how to make heads or tails of this...I would be very, very thankful for any help!

HtmlAgilityPack Save Process Not Letting Go Of File

I am saving some of the rendered html of a web site by overriding the Render method and using HtmlAgilityPack. Here is the code:
protected override void Render(HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new StringWriter()))
{
base.Render(htmlwriter);
string output= htmlwriter.InnerWriter.ToString();
var doc = new HtmlDocument();
doc.LoadHtml(output);
doc.Save(currDir + "\\" + reportDir + "\\dashboardTable.html");
}
}
However, some process does not let go of the saved file and I am unable to delete it from the server. Does anyone know of an HtmlAgilityPack issue that would cause this?
Any advice is appreciated.
Regards.
EDIT:
I have tried both of the methods suggested. I can't tell if they are the solution yet because my app is frozen on the server due to the files I can't delete. However, when I use these solutions on my own machine, the rendered HTML does not save as an HTML table anymore but rather like this:
INCIDENT MANAGEMENT
Jul '12 F'12
Trend F'12 2011
(avg)
Severe Incidents (Sev1/2): 3 2.1 4.16
Severe Avoidable Incidents (Sev1/2): 1 1.3 1.91
Incidents (Sev3): 669 482 460.92
Incidents (Sev4) - No business Impact: 1012 808 793
Proactive Tickets Opened: 15 19.3 14
Proactive Tickets Resolved/Closed: 14 17.3 11
CHANGE MANAGEMENT
Total Planned Changes: 531 560 583.58
Change Success Rate (%): 99.5 99.4 99
Non-Remedial Urgent Changes: 6 11 47.08
PROBLEM MANAGEMENT
New PIRs: 2 1.4 2
Closed PIRs: 0 2 3
Overdue Action items: 2 3.2 0
COMPLIANCE MEASUREMENTS
Jul Trend Jun
Total Number of Perimeter Devices: 250 258
Perimeter Devices - Non Compliant: 36 31
Total Number of Internal Devices: 6676 6632
Internal Devices - Non Compliant: 173 160
Unauthorized Perimeter Changes: 0 0
Unauthorized Internal Changes 0 0
LEGEND
ISP LINKS
July June Trend
SOC CPO DRP SOC CPO DRP
40% 34% 74% 39% 35% 74%
BELL MPLS HEAD ENDS
July June Trend
SOC CPO SOC CPO
8% 5% 7% 10% 8% 5.5% 7% 10%
ENTERPRISE NETWORK (# of issues called out)
July June Trend
CORE FW/DMZ CORE FW/DMZ
1 0 1 0
US & INTL (# of issues called out)
July June Trend
US Intl US Intl
2 2 2 3
LINE OF BUSINESS BELL WAN MPLS
<> 50%-65% >65% <> 50%-65% >65% Trend
Retail: 2272 0 1 2269 4 0
Business Banking: 59 1 0 60 0 0
Wealth: 122 2 0 121 2 1
Corporate: 51 0 0 49 2 0
Remote ATM: 280 0 0 280 0 0
TOOLS
Version Currency Vulnerability Status Health Status
Key Messages:
where only the text data has been saved and all of the HTML and CSS is missing. If I just use doc.Save() I get an exact representation of the table as it displays on the website.
Try this instead. Maybe the Save method isn't closing the underlying stream.
using( FileStream stream = File.OpenWrite( currDir + "\\" + reportDir + "\\dashboardTable.html" ) ){
doc.Save(stream);
stream.Close();
}
Edit
Per #L.B's comments it appears that HtmlAgilityPack does use a using block as in my example so it will be ensuring that the stream gets closed.
Thus as I suggested at the end of my original answer this must be a server environment problem
Original Answer
This may be some sort of bug with HtmlAgilityPack - you may want to report it to the developers.
However to eliminate that possibility you may want to consider explicitly controlling the creation of the StreamWriter for the file so you are explicitly closing it yourself. Replace this line:
doc.Save(currDir + "\\" + reportDir + "\\dashboardTable.html");
With the following:
using (StreamWriter fileWriter = new StreamWriter(currDir + "\\" + reportDir + "\\dashboardTable.html"))
{
doc.Save(fileWriter);
fileWriter.Close();
}
If the issue still persists even with this change then that would suggest an issue with your server environment rather than an issue with HtmlAgilityPack. Btw to test if this change makes a difference you should start from a clean server environment rather than one where you are already having issues deleting the file in question.

Using RedLaser SDK via MonoTouch crashing as soon as BarcodePickerController shown

I'm using Chris Branson's RedLaser MonoTouch bindings and sample from here:
https://github.com/chrisbranson/RedLaserSample
Firstly, to help out those also having trouble with this sample project, I had to update both the makefile to build the RedLaser.dll MonoTouch bindings and the sample MonoDevelop csproj to get the actual app compiling.
Makefile
The makefile supplied by Chris unzipped the RedLaser SDK download, but RedLaser changed their naming convention and so it was no longer working. I simplified it, instead requiring the user to put the libRedLaserSDK.a file into the build directory manually:
BTOUCH=/Developer/MonoTouch/usr/bin/btouch
BUILDVER=build139
VERSION=3.2.4
BINDIR=./bin/
all: $(BINDIR)RedLaser.dll
$(BINDIR)libRedLaserSDK.a:
#echo "You'll need to obtain a copy of RedLaserDevSDK-$(VERSION).zip from"
#echo "http://redlaser.com/sdk/index.php"
#echo Locate the libRedLaserSDK.a file and place within
#echo $(BINDIR)
#echo
#open http://redlaser.com/sdk/index.php
#exit 1
$(BINDIR)RedLaser.dll: Makefile AssemblyInfo.cs RedLaser.cs enums.cs $(BINDIR)libRedLaserSDK.a
$(BTOUCH) --out=$# -e RedLaser.cs enums.cs AssemblyInfo.cs --link-with=$(BINDIR)libRedLaserSDK.a,libRedLaserSDK.a
clean:
-rm -rf $(BINDIR)*.dll
The directory containing the makefile should also contain the files redlaser.cs, enums.cs and AssemblyInfo.cs (i.e. the same as Chris's).
MonoDevelop project build settings
I think the reason this stopped working was a bug in MonoDevelop or MonoTouch and the way it expands the 'Additional mtouch arguments' when they contained quotation marks. Chris's original arguments looked like this:
-cxx -gcc_flags="-framework SystemConfiguration -framework CFNetwork -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework OpenGLES -framework Security -L${ProjectDir}/Lib -lRedLaserSDK -ObjC"
MonoDevelop doesn't parse this correctly, instead inserting quotation marks around each option separated by a space. Looking in the build output (under 'Compiling to native code') showed that this got expanded to:
"/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib/RedLaser.dll" -debug -nolink -sdk "5.1" -targetver "5.1" --armv7 "-cxx" "-gcc_flags=\"-framework" "SystemConfiguration" "-framework" "CFNetwork" "-framework" "CoreVideo" "-framework" "CoreMedia" "-framework" "AVFoundation" "-framework" "OpenGLES" "-framework" "Security" "-L/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib" "-lRedLaserSDK" "-ObjC\""
The solution involves adding explicit quotation marks around the whole 'gcc_flags' option, manually escaping the inner quotation marks. e.g:
"-cxx" "-gcc_flags=\"-framework SystemConfiguration -framework CFNetwork -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework OpenGLES -framework Security -L${ProjectDir}/Lib -lRedLaserSDK -ObjC\""
This expands correctly into:
"/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib/RedLaser.dll" -debug -nolink -sdk "5.1" -targetver "5.1" --armv7 "-cxx" "-gcc_flags=\"-framework SystemConfiguration -framework CFNetwork -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework OpenGLES -framework Security -L/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib -lRedLaserSDK -ObjC\""
Ok, so now that I had it compiling I attempted to run it on my phone. The app loads up fine, and successfully calls into the RedLaser SDK via the RedLaserSDK.CheckReadyStatus() function. But as soon as I hit the scan button (which loads the BarcodePickerController) it crashes with a native exception deep within the RedLaser SDK:
terminate called throwing an exception
Native stacktrace:
0 RedLaserSample 0x0159d62d mono_handle_native_sigsegv + 244
1 RedLaserSample 0x015b6251 sigabrt_signal_handler + 112
2 libsystem_c.dylib 0x319b67ed _sigtramp + 48
3 libsystem_c.dylib 0x319ac20f pthread_kill + 54
4 libsystem_c.dylib 0x319a529f abort + 94
5 libc++abi.dylib 0x34fb1f6b abort_message + 46
6 libc++abi.dylib 0x34faf34d _ZL17default_terminatev + 24
7 libobjc.A.dylib 0x358e536f _objc_terminate + 170
8 libc++abi.dylib 0x34faf3c5 _ZL19safe_handler_callerPFvvE + 76
9 libc++abi.dylib 0x34faf451 _ZdlPv + 0
10 libc++abi.dylib 0x34fb079f __cxa_throw + 122
11 RedLaserSample 0x000404a9 _ZN5zxing6qrcode19FinderPatternFinder18selectBestPatternsEv + 172
12 RedLaserSample 0x000415e9 _ZN5zxing6qrcode19FinderPatternFinder4findERKNS_11DecodeHintsE + 512
13 RedLaserSample 0x0003a7f7 _ZN5zxing6qrcode8Detector6detectERKNS_11DecodeHintsE + 366
14 RedLaserSample 0x00046b97 _ZN5zxing6qrcode12QRCodeReader6decodeENS_3RefINS_12BinaryBitmapEEENS_11DecodeHintsE + 130
15 RedLaserSample 0x0004ec35 _ZN5zxing6Reader6decodeENS_3RefINS_12BinaryBitmapEEE + 240
16 RedLaserSample 0x00058455 -[FormatReader decode:] + 116
17 RedLaserSample 0x00013835 -[ZXingDecoder findCodesInBitmap:bytesPerRow:width:height:] + 656
18 RedLaserSample 0x0005f6af -[BarcodePhotoEngine zxingFindBarcodesInPixmap:] + 222
19 RedLaserSample 0x00055f25 __38-[BarcodeEngine findBarcodesInPixMap:]_block_invoke_059 + 76
20 libdispatch.dylib 0x34635c59 _dispatch_call_block_and_release + 12
21 libdispatch.dylib 0x34637d0f _dispatch_queue_drain + 274
22 libdispatch.dylib 0x34637b75 _dispatch_queue_invoke$VARIANT$mp + 40
23 libdispatch.dylib 0x346387e7 _dispatch_worker_thread2 + 210
24 libsystem_c.dylib 0x31967dfb _pthread_wqthread + 294
25 libsystem_c.dylib 0x31967cd0 start_wqthread + 8
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Running the very similar RedLaser Xcode sample project (i.e. no MonoTouch involvement, all objective-c) works fine.
Also, if it is of any significance, disabling all barcode scan types allows the BarcodePickerController to load up and display the camera view. Obviously it never detects a barcode though.
The crash you mention has been fixed in the bindings now.
It was related to QR's usage of C++ exceptions and incorrect linking arguments.
According to the Makefile you pasted, this RedLaser binding uses the LinkWith[1] feature supported by MonoTouch to eliminate the need to use any "Additional mtouch arguments".
Just wipe out any arguments needed for RedLaser from your additional mtouch arguments configuration in your Project Options and things will likely build & work properly.
If not, try using the RedLaser binding from https://github.com/xamarin/monotouch-bindings which may be more up-to-date?
Notes:
http://blog.xamarin.com/2011/11/02/monotouch-native-libraries-made-easy/

Categories

Resources