$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like
13 Oct // php the_time('Y') ?>
Yesterday I wrote about converting an IP Address to an Integer in C#. But both methods I presented return the IP Address in network byte order.
However in some cases, especially when calling WinApi functions, you will need to convert the Integer to host byte order which is little-endian on Intel processors.
In an unmanaged language we could do very fast byte swap with inline assembly, eg:
1 2 3 4 | function Swap32(value: Integer): Integer; asm bswap eax end; |
From WinApi we could use the ntohl function and in managed languages we can use the NetworkToHostOrder method from the System.Net.IPAddress class.
For an IPv4 address we need to make sure we are using the proper overload by casting the result of System.BitConverter to an int:
1 2 3 4 | IPAddress ipa = IPAddress.Parse("10.4.2.91"); uint ip = (uint)IPAddress.NetworkToHostOrder( (int)System.BitConverter.ToUInt32( ipa.GetAddressBytes(), 0)); |
12 Oct // php the_time('Y') ?>
For a call to a WinApi function I needed to convert an IP Address to an Integer in C#.
This can be done using the System.Net.IPAddress class:
1 2 3 4 | using System.Net; IPAddress ipa = IPAddress.Parse("10.4.2.91"); uint ip = (uint)ipa.Address; |
Although this works, the compiler issues a warning:
warning CS0618: ‘System.Net.IPAddress.Address’ is obsolete: ‘This property has been deprecated. It is address family dependent. Please use IPAddress.Equals method to perform comparisons. http://go.microsoft.com/fwlink/?linkid=14202′
This warning is issued because the Address property is not IPv6 compatible. The warning can be suppressed like this:
1 2 3 4 5 6 7 | using System.Net; IPAddress ipa = IPAddress.Parse("10.4.2.91"); #pragma warning disable 612, 618 uint ip = (uint)ipa.Address; #pragma warning restore 612, 618 |
But it would be better to use the non deprecated GetAddressBytes() Method:
1 2 3 4 5 6 | using System.Net; IPAddress ipa = IPAddress.Parse("10.4.2.91"); // for IPv4 we can convert to UInt32... uint ip = System.BitConverter.ToUInt32(ipa.GetAddressBytes(), 0); |
18 Jul // php the_time('Y') ?>
Today I was asked to troubleshoot an executable that didn’t work correctly on Windows XP Embedded.
On startup it displayed the following message:
1 2 3 4 5 6 7 | Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass embly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b0 3f5f7f11d50a3a' or one of its dependencies. The system cannot find the path spec ified. File name: 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyTok en=b03f5f7f11d50a3a' ---> System.IO.DirectoryNotFoundException: The system canno t find the path specified. (Exception from HRESULT: 0x80070003) |
I verified that System.Configuration.dll was present (in C:\Windows\Microsoft.NET\Framework\v2.0.50727).