Archive for the ‘.NET 4.0’ Category
Posted by jpluimers on 2014/12/02
Last year’s summer, I posted some .NET/C#: some starting posts on the yield keyword and mentioned that async and await might be the most complicated compiler transform.
So here are some posts to learn more about async and await: Read the rest of this entry »
Posted in .NET, .NET 4.0, .NET 4.5, C#, C# 5.0, Development, Jon Skeet, Software Development | 1 Comment »
Posted by jpluimers on 2014/11/04
Normally you would not want to use a reserved word as an identifier. But sometimes it can be very convenient, for instance for a code generator that wraps remoting calls or does ORM.
Both Delphi and C# have an escape for this:
The prefixes are to tell the compiler knows you really know what you are doing, and are using a reserved word as an identifier.
The cool thing: in the Run Time Type Information (Delphi) or Reflection (C# and VB.NET) you will see the names without the prefix.
Some examples from StackOverflow: 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, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Conference Topics, Conferences, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Event, Jon Skeet, Software Development, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 7.0, VB.NET 7.1, VB.NET 8.0, VB.NET 9.0 | Leave a Comment »
Posted by jpluimers on 2014/09/10
Yesterday I posted this question on StackOverflow and G+: Is there a url or site like example.org which always produces a 404 error?
Soon after that, I found out three links that produce predictable HTTP status codes:
They also work for https:
Edit 20241223: these also return a 404: http://www.google.com/undefined and https://www.google.com/undefined
On StackOverflow very few people even noticed the question, probably wondering “why?”.
I’m using these links for positive and negative testing of some http / https handling code that needs to be good at coping with positive and negative responses.
In my testing life, I’ve learned the hard way that both negative and positive tests are core part of your suite, hence the question.
–jeroen
via: Is there a url or site like example.org which always produces a 404 error?. Read the rest of this entry »
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Chrome, Communications Development, Development, HTTP, Internet protocol suite, Power User, REST, Software Development, TCP, Web Browsers, Web Development | Leave a Comment »
Posted by jpluimers on 2014/09/09
Bosak posted an interesting piece of code on StackOverflow last year. His particular code was in C#, but it does not matter what kind of compiler you use:
Sometimes a compiler will complain about unreachable code, for instance when it thinks a function never returns a value.
But you know the program logic does.
Simple solution: When you have code that never should be reached: throw an appropriate exception.
public static int GetInt(int number)
{
int[] ints = new int[]{ 3, 7, 9, int.MaxValue };
foreach (int i in ints)
if (number <= i)
return i;
return int.MaxValue; //this should be unreachable code since the last int is int.MaxValue and number <= int.MaxValue is allways true so the above code will allways return
}
The last return could be replaced like this, as proposed by Matt Houser: 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, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/07/10
In case I need to export DocX in .NET again: DocX – Home which is also at github.com/WordDocX/DocX
(I did it both with Word Automation and OOXML, they were a pain).
–jeroen
Posted in .NET, .NET 4.0, .NET 4.5, C#, C# 4.0, C# 5.0, Development, Office, Office 2007, Office 2010, Office 2013, Office PIA, Software Development | Leave a Comment »
Posted by jpluimers on 2014/07/03
I’ve done quite a bit of VB.NET maintenance lately.
Most of that code was riddled with CType, both for conversions and casts. Quite a bit code had Option Explicit and Option Strict Off. A lot of those CType constructions had empty Try / Catch / End Try blocks around them.
Those empty catch blocks are a code smell. They pretend to be able to survive any exceptional disaster, but in practice you can’t. You have to indicate what kinds of disasters you can handle, for instance if a meteorite hits your data center (thanks George Stocker).
Turning off Option Strict can be OK under many circumstances (the default is off), but having Option Explicit off is usually a code smell as well, just like On Error Resume Next (which was also in plenty of the source code).
I do understand a lot of VB.NET source comes from people having programmed in VB 6, VBScript or VBA for a long time where those constructs were more common. But writing code in the 21st century is much more about writing code that you can prove to be right. Having proper error handling and compiler type checking is a big part of that.
It pays to go with the idiom, for example read the good and bad ways of vb.net – Safest way to check for integer.
Back to CType: basically you have do distinguish between conversions and casts. The reason is that when you know it will be a form of cast, CType is way to expensive. And if you know you will be doing conversions, than casting is not what you want.
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Development, Software Development, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 7.0, VB.NET 7.1, VB.NET 8.0, VB.NET 9.0 | Leave a Comment »
Posted by jpluimers on 2014/07/02
I only need it every once in a while, so finding the right links and tips to help me usually takes too much time.
So here is a small list to get started:
Keywords: CLR, SOS.DLL, WinDbg, mscordacwks.dll, PSSCOR4
Some tips: 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, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Debugging, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2014/06/26
Interesting: about a year and a half ago, the Nikon SDK C# wrapper project started ad sourceforge.
Basically, it allows you to integrate the operation of your Nikon DSLR into your .NET projects.
It has some very interesting features:
- Control your Nikon DSLR via USB
- Capture Jpeg and Raw images directly to system memory
- Receive ‘Live View’ images
- Record Video
- Query and change camera settings (Exposure, Aperture, ISO, etc.)
- And much more…
Downloads: Nikon SDK C# Wrapper – Browse Files at SourceForge.net.
–jeroen
via: Nikon SDK C# Wrapper | Free Security & Utilities software downloads at SourceForge.net.
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/06/10
Wow, it seems I’ve been living under a stond since early 2011: the first StudioShell checkin.
[WayBack] StudioShell opens marvellous possibilities in Visual Studio 2010, 2012 and up.
Just look at the feature list: Read the rest of this entry »
Posted in .NET, .NET 4.0, .NET 4.5, C#, C# 4.0, C# 5.0, CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »