base-class-library

Why does IPAddress.MapToIPv4() throw ArgumentOutOfRangeException?

独自空忆成欢 提交于 2019-12-03 11:03:02
This code throws an ArgumentOutOfRangeException on the last line var initAddress = IPAddress.Parse("1.65.128.190"); var ipv6Address = initAddress.MapToIPv6(); Assert.IsTrue(ipv6Address.IsIPv4MappedToIPv6); var ipv4Address = ipv6Address.MapToIPv4(); Can anyone explain why MapToIPv6() and MapToIPv4() are not round trip compatible? edit: The exception originates from the IPAddress constructor, called by MapToIPv4(). Also, when the first line is var initAddress = IPAddress.Parse("1.65.128.90"); no exceptions are thrown anymore edit2: as @Luaan reproduced this, I added the tag [bug-reporting]. Also

.NET 4.5 CustomReflectionContext: what is it useful for?

南笙酒味 提交于 2019-12-03 05:25:07
What's New in the .NET Framework 4.5 Developer Preview mentions Ability to customize a reflection context to override default reflection behavior through the CustomReflectionContext class. What is the purpose of the ReflectionContext ? MSDN is not quite clear on the subject. In the past with .NET, there has been tension between wanting to be able to automate certain features through reflection, and being able to customize them. For example, take the Properties panel in Visual Studio - in scenarios where this shows some .NET type (e.g., a control on a design surface), it can automatically

Exactly how large is the .NET (3.5) Framework Class Library?

两盒软妹~` 提交于 2019-12-03 02:51:27
I've regularly read that the framework is just too large for one developer to have experience with every part of it. Having some actual numbers would certainly help put things in perspective. MSDN seems to list them all but there are no actual numbers (from what I could see) and spending hours counting them is not my idea of productive time. Number of Namespaces Number of Classes Number of Structs Number of Interfaces I realize there are also delegates, enums, events, etc, but the above types are of most interest. Also, the number of types in the Base Class Library (BCL) as well as the size of

CallerMemberName in .NET 4.0 not working

扶醉桌前 提交于 2019-12-03 01:25:47
I am trying to use CallerMemberName attribute in .NET 4.0 via BCL portability pack. It is always returning an empty string instead of the member name. What am I doing wrong? public partial class Form1 : Form { public Form1() { InitializeComponent(); MessageBox.Show(new class2().CallMe); } } public class class2 { public string CallMe { get { return HelpMe(); } } private string HelpMe([CallerMemberName] string param = "") { return param; } } Targeting 4.0 works just fine if you add: namespace System.Runtime.CompilerServices { sealed class CallerMemberNameAttribute : Attribute { } } Pradeep I

Apparent F#/BCL floating point bug

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 06:19:02
问题 The following is in FSI: > System.Math.Round(0.2916, 2);; val it : float = 0.29 > it * 100.;; val it : float = 29.0 > int it;; val it : int = 28 The result is the same everywhere I tried - a compiled F# 3.1/.NET 4.0 application, FSI in Visual Studio 2013 and 2015, .NET Fiddle, @fsibot.... Surely this is a bug somewhere, isn't it? What's going on here? 回答1: This is just how floating point numbers work. The number that appears as 29 in the output is actually slightly smaller than 29 (because

Apparent F#/BCL floating point bug

做~自己de王妃 提交于 2019-12-01 22:46:05
The following is in FSI: > System.Math.Round(0.2916, 2);; val it : float = 0.29 > it * 100.;; val it : float = 29.0 > int it;; val it : int = 28 The result is the same everywhere I tried - a compiled F# 3.1/.NET 4.0 application, FSI in Visual Studio 2013 and 2015, .NET Fiddle, @fsibot.... Surely this is a bug somewhere, isn't it? What's going on here? This is just how floating point numbers work. The number that appears as 29 in the output is actually slightly smaller than 29 (because floating point numbers are not precise): > (System.Math.Round(0.2916, 2) * 100.0) - 29.0;; val it : float = -3

Bundle .NET dlls to run application in .NET-less machine?

南楼画角 提交于 2019-11-30 19:48:04
AFAIK, ngen turns MSIL into native code (also reffered to as pre-JIT), however I never payed too much attention at it's startup performance impact. Ngen'd applications still require the .NET base class libraries (the runtime). Since the base class libraries have everything our .NET assemblies need (correct?) would it be possible to ship the framework's DLLs with my ngen'd application so that it does not require the runtime to be installed? (e.g., the scenario for most Windows XP machines) Oh, and please don't bother mentioning Remotesoft's Salamander Linker or Xenocode's Postbuild . They are

Meaning of confusing comment above “string.Empty” in .NET/BCL source?

爷,独闯天下 提交于 2019-11-30 11:48:32
问题 I'm trying to understand why string.Empty is readonly and not a const . I saw this Post but I don't understand the comment Microsoft wrote about it. As Jon Skeet wrote in a comment "I don't know - it doesn't make much sense to me, to be honest..." Shared Source Common Language Infrastructure 2.0 Release. string.cs is in sscli20\clr\src\bcl\system\string.cs // The Empty constant holds the empty string value. //We need to call the String constructor so that the compiler doesn't mark this as a

What is the maximum amount of characters or length for a Directory?

巧了我就是萌 提交于 2019-11-30 07:58:12
问题 What is the maximum amount of characters that a typical path can contain for a directory when using C#? For example C:\test\ has 7 characters in length , what is the maximum length? 回答1: Maximum for MaxPath in CLR is 260 characters The maximum amount of characters is defined by MAX_PATH in the Win32 API library. This setting is 260 and that same setting is used, hard-coded, inside the CLR BCL. A path reaching that amount of characters is likely to cause trouble (see aside below). This maximum

Bundle .NET dlls to run application in .NET-less machine?

北城以北 提交于 2019-11-30 05:03:01
问题 AFAIK, ngen turns MSIL into native code (also reffered to as pre-JIT), however I never payed too much attention at it's startup performance impact. Ngen'd applications still require the .NET base class libraries (the runtime). Since the base class libraries have everything our .NET assemblies need (correct?) would it be possible to ship the framework's DLLs with my ngen'd application so that it does not require the runtime to be installed? (e.g., the scenario for most Windows XP machines) Oh,