Archive for the ‘.NET 4.0’ Category
Posted by jpluimers on 2014/05/08
It is almost 3 years that Ostemar wrote an interesting answer on Stack Overflow to the question
Why does .NET use banker’s rounding as default? – Stack Overflow.
Few people (even many programmers don’t!) know about rounding and how it can influence software, let alone what bankers rounding does so lets set a few things straight first.
Rounding matters. Depending on the kinds of software you write, it matters a little, or a lot.
For instance, in these categories, it can matter an awful lot:
- Financial applications
- Statistical applications
Bankers rounding means rounding half even. Which means that #.5 will round to the even number closest to #.
In bankers rounding, 1.5 rounds to 2, 3.5 to 4 as does 4.5, -1.5 rounds to -2, -3.5 to -4 as does -4.5.
This is called “unbiased” because for reasonable distributions of y values, the expected (average) value of the rounded numbers is the same as that of the original numbers.
This is contrary to what the majority of people are accustomed to: Round half away from zero is taught in most countries (even for the Dutch, despite the alias “Dutch Rounding” for round half to even).
Round half away from zero rounds 1.5 rounds to 2, 3.5 to 4 and 4.5 to 5. Negative numbers round like this: -1.5 rounds to -2, -3.5 to -4 as does -4.5 to -5.
This is only free of overall bias if the original numbers are positive or negative with equal probability.
In short, .NET uses bankers rounding because it follows the IEEE 754 rounding rules.
This was his answer: Read the rest of this entry »
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, .NET CF, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | 3 Comments »
Posted by jpluimers on 2014/04/22
The first bulleted link below has been living in my drafts like forever (i.e. somewhere since mid June 2009), so time to write a bit about ISO 8601 and .NET.
First a few links about converting a DateTime into ISO 8601 string format:
Some solutions use the “K” as a time zone specifier. At first, I couldn’t find any documentation for it, not even Google Search for Google Search for “ssK” DateTime ToString returns anything useful.
Later on, I found The “K” Custom Format Specifier in Custom Date and Time Format Strings.
So my preferred solutions for me are these:
System.DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssK");
System.DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssK");
I avoid these:
System.DateTime.Now.ToString("o");
because it gets you too many digits in the second fracion.
System.DateTime.Now.ToUniversalTime().ToString("s") + "Z";
because it is less clear what it does (might be resolved with a comment).
–jeroen
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, ISO 8601, Software Development | 1 Comment »
Posted by jpluimers on 2014/04/17
Thanks User Andrew Hare – Stack Overflow for answering this on Stack Overflow.
I’m pretty sure it works in all .NET and C# versions starting with 2.0.
Here is a hack-ish way to do it without having to load the entire output string into an XmlDocument: Read the rest of this entry »
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/04/16
Posted in .NET, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, ASP.NET, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, Visual Studio 11, Visual Studio 2008, Visual Studio 2010, Visual Studio 2013, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2014/04/16

A while ago, I was working with a not so cooperative corporate firewall. All web browsers would work fine, but most other applications would not go through the proxy in a nice way.
For instance, DropBox would show the dreadfull “Connection Error” dialog shown on the right.
That dialog basically means “Dropbox has no clue what happens, try fiddling with your proxy or account settings, then press Reconnect Now” to retry.
Many other applications had issues (for instance Visual Studio connecting to Team Foundation System was very unreliable and the workarounds clumsy).
CNTLM: not the solution
I got inspired by the [WayBack] I code and code: Tutorial: How to use Dropbox behind a corporate proxy server using CNTLM, even though I was pretty sure the corporate firewall was not NTLM based.
And indeed, CNTLM -v -M http://google.com -c CNTLM.INI would give errors like this:
cntlm: Proxy returning invalid challenge!
headers_send: fd 4 warning -999 (connection closed)
Connection closed
HTTP Fiddler: looks promising
So I fired up my old buddy [WayBack] Fiddler 2 HTTP debugging proxy.
Further on, you will learn that Fiddler2 is much more, but right now it is enough to know that it basically sits as a local proxy between your applications and the outside world. Read the rest of this entry »
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, base64, Cntlm, Development, DropBox, Encoding, Fiddler, JavaScript/ECMAScript, NTLM, Power User, Scripting, SocialMedia, Software Development, Web Development, Windows, Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP, Windows-Http-Proxy | Leave a Comment »
Posted by jpluimers on 2014/04/15
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, ASP.NET, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Fiddler, Software Development, Visual Studio 11, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, Web Development | Leave a Comment »
Posted by jpluimers on 2014/04/10
Posted in .NET, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/04/09
Interesting read:
The C language specification describes an abstract computer, not a real one – The Old New Thing – Site Home – MSDN Blogs.
In other words: any language that merges null behaviour in the underlying storage will have a problem somwehere.
So if you want to have true nullable types, your null flag should be stored outside the underlying storage.
The .NET framework 2 and up, most database management systems and many other environment support that.
But most languages don’t support it for pointer types. So there will be portions of address spaces either inaccessible, or only accessible when skipping the null pointer checks.
Note that the thread above contains some very interesting bits, for instance this one:
Matt 28 Mar 2013 5:58 PM #
@MarkY “Dereferencing null is undefined? Cool! I thought it was guaranteed to crash, just like a false assertion or something. So crashing is the OS guarantee, not the language guarantee apparently.”
Nope. It’s not an OS guarantee either. The OS won’t ever normally allocate memory at address zero, but there’s nothing to stop you telling it to. Try doing “VirtualAlloc(1, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)” on your pre-Windows8 machine.
In fact, this is the reason why null-dereferences in kernel mode are often exploitable as elevation of privilege attacks. The null-page is mappable and within the user-addressable region of memory, so if the kernel dereferences a null pointer, it reads attacker controllable data.
And btw, this is the reason why on Linux and Windows8+ you can’t map the null-page.
–jeroen
via: The C language specification describes an abstract computer, not a real one – The Old New Thing – Site Home – MSDN Blogs.
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Borland C++, Borland Pascal, C, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C++, C++ Builder, Database Development, Delphi, Development, Pascal, Quick Pascal, Software Development, Turbo Pascal, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 8.0, VB.NET 9.0 | Leave a Comment »
Posted by jpluimers on 2014/04/02
Every once in a while, someone hoses their computer far enough that it has to be reinstalled, but the original Microsoft product keys are misplaced, and some creepy anti-virus tool disallows the running of standard product key recovery tools like nirsoft’s.
Well, there is enough sourcecode that does recover it, just look for any of these strings:
Some hits:
The below full executables can trigger a virus warning (ordered from less often to most often):
–jeroen
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, CommandLine, Delphi, Development, PowerShell, Software Development | Leave a Comment »
Posted by jpluimers on 2014/03/29
Brilliant piece of open source:
SmallestDotNet – SmallestDotNet.com is a single page site that does one thing. It tells you the smallest, easiest download you’d need to get the .NET Framework on your system.
Even on Mac OS X it is helpful and recommends Mono and on iOS it recommends looking at MonoTouch.
Thanks Scott Hanselman for making this available!
–jeroen
via:
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Apple, Development, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User, Software Development, Windows, Windows 7, Windows 8, Windows 8.1, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | Tagged: .NET Framework, scott hanselman | Leave a Comment »