.net-4.0

Moving constants to a separate assembly [closed]

情到浓时终转凉″ 提交于 2019-12-10 13:48:15
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . I have a project which utilizes many global constants. Eventually I am planning to extract some parts of the program and create assemblies of its own. Is it worthy (or is it possible?) to create an assembly for global constants alone (viz, GlobalConstants.dll), so that I can

Can't understand the Exception when using dynamic with generic collection in .net4

試著忘記壹切 提交于 2019-12-10 13:45:38
问题 check the code below please: static void Main(string[] args) { IList<dynamic> items = new List<dynamic>(); items.Add(3); items.Add("solid"); dynamic i = new ExpandoObject(); items.Add(i); //System.Collections.Generic.IList<object>' does not contain a definition for 'Add' Console.WriteLine(); } is this a bug in "dynamic" mechanism? 回答1: Looks like a bug (or is it a feature request?): https://connect.microsoft.com/VisualStudio/feedback/details/534288/ilist-dynamic-cannot-call-a-method-add

FolderBrowserDialog SelectedPath with reparse points

一笑奈何 提交于 2019-12-10 13:41:42
问题 I'm having issues with the SelectedPath property of the FolderBrowserDialog when the folder I select is on a remote server and is a symbolic link (or any kind of reparse point). If i select a normal folder, then I get the full path returned, for example "\SERVER\folder\subfolder\thing_I_clicked_on". However, if the folder is a reparse point, i get just "\SERVER\thing_I_clicked_on" (so it's missing the full path) var dialog = new FolderBrowserDialog(); dialog.ShowDialog(); MessageBox.Show

Creating a dynamic extension method in C#?

流过昼夜 提交于 2019-12-10 13:39:50
问题 Is it possible to workaround this error: public static class LayoutExtensions { /// <summary> /// Verifies if an object is DynamicNull or just has a null value. /// </summary> public static bool IsDynamicNull(this dynamic obj) { return (obj == null || obj is DynamicNull); } Compile time Error: The first parameter of an extension method cannot be of type 'dynamic' 回答1: No. See https://stackoverflow.com/a/5311527/613130 When you use a dynamic object, you can't call an extension method through

Intellisense in .skin files in ASP.NET 4

♀尐吖头ヾ 提交于 2019-12-10 13:29:01
问题 Is there a good way to apply intellisense in .skin files in ASP.NET 4? like a microsoft visual studio tool for example? I installed an intellisense schema for .skin files to my visual studio 2008 long time ago but it had some bugs so i had to remove it. any improvements in visual studio 2010? 回答1: Try this: Tools -> Options -> Text editor -> File extensions. Now type skin in the extension textbox and select User Control Editor from the dropdownlist. Click Add . Close and reopen your .skin

Is it possible to scope ServiceStack.Text.JsConfig settings to just your library?

寵の児 提交于 2019-12-10 13:27:48
问题 I'm writing a custom library that uses ServiceStack.Text internally. Other libraries that consume mine may also use ServiceStack.Text. I want to change some JsConfig options (specifically date handling), but, like any good citizen, I don't want my modifications of those values to cause side effects for my consumer. Unfortunately JsConfig is a static class, so its settings are static, and would bleed to other consumers of ServiceStack in the same AppDomain I believe. That's an undesired

Fail early or clearly throw when an enum cannot be serialized

会有一股神秘感。 提交于 2019-12-10 13:23:53
问题 In the scenario where a WCF service returns a DataContract with an enum member that has an invalid value (an int not present in the Enum type) the thrown exception on the client side is The underlying connection was closed: The connection was closed unexpectedly. Strangely enough this exception is triggered because the DataContractSerializer cannot serialize at the serverside of the connection. I would rather have something more usefull thrown at me and more important earlier, at runtime on

DateTime.TryParse cannot parse DateTime.MinValue

倾然丶 夕夏残阳落幕 提交于 2019-12-10 13:13:33
问题 I'm using a library called Json.NET that uses the following code internally to parse a JSON string into a DateTime: if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt); return dt; } I thought Json.NET was screwing up the conversion, but it looks like it's DateTime.TryParse itself that's botching the value. When I parse the following valid Iso date (which corresponds to UTC DateTime

Apply attribute to return value - In F#

为君一笑 提交于 2019-12-10 12:57:53
问题 in C# it is possible to apply an attribute to the return of a method: [return: DynamicAttribute] public object Xyz() { return new ExpandoObject(); } Is this possible in F#? Background : I would like a method of a library written in F# which will be consumed in a language like C# to return "dynamic" from a method. If I look into a similarly defined method compiled from C# it seems like the return type is object and the DynamicAttribute is applied to the return value of the object. 回答1: Sure,

TreatControlCAsInput issue. Is this a bug?

怎甘沉沦 提交于 2019-12-10 12:35:14
问题 Just ran across the problem described below. If "Console.TreatControlCAsInput = true;", you have to press [enter] twice on ReadLine(). I've written some demo code below. I am correct in surmising that this code demonstrate a bug in the .NET 4 framework? Console.Write("Test 1: Console.TreatControlCAsInput = false\nType \"hello\": "); { string readline = Console.ReadLine(); // type "hello" [enter]. Console.WriteLine("You typed: {0}", readline); // Prints "hello". } Console.Write("Test 2: