.net-4.0

DateTime value is different across different versions of .NET framework

家住魔仙堡 提交于 2019-12-24 04:57:12
问题 I have a service(Language: VB.NET, Framework:.NET 3.5) that returns a dataset from which I read a date. The value of the column in the database is: "1980-03-30 00:00:00.000". In a client(Language: C#) that uses .NET 3.5, the value is coming thorough as : 3/30/1980 12:00:00 AM However, when I change the same client to use .NET 4 or .NET 4.5, the date which comes through the service is: 3/29/1980 11:00:00 PM 回答1: The difference in DateTime values is not because of .Net framework, its because of

Why must the new() constraint require a public constructor?

岁酱吖の 提交于 2019-12-24 03:27:32
问题 Disclaimer: Theoretical Question The new constraint specifies that any type argument in a generic class declaration must have a public parameterless constructor. Source: http://msdn.microsoft.com/en-us/library/sd2w2ew5(v=vs.80).aspx What if I wanted my generic class to have a protected parameterless constructor instead? For instance, if I want to write a Singleton class which I "attach" to other classes to make them Singleton s, I don't want the derived classes to be instantiable - everything

Why must the new() constraint require a public constructor?

纵饮孤独 提交于 2019-12-24 03:27:20
问题 Disclaimer: Theoretical Question The new constraint specifies that any type argument in a generic class declaration must have a public parameterless constructor. Source: http://msdn.microsoft.com/en-us/library/sd2w2ew5(v=vs.80).aspx What if I wanted my generic class to have a protected parameterless constructor instead? For instance, if I want to write a Singleton class which I "attach" to other classes to make them Singleton s, I don't want the derived classes to be instantiable - everything

Oracle.DataAccess.Client.OracleException at Connection.Open()

时光总嘲笑我的痴心妄想 提交于 2019-12-24 03:22:31
问题 this question can look like a clone of others, but I can't find a correct answer to this one. This is my scenario: I have a C# software called by webservices that need to write to an oracle database. In my test server no problems, it works like a charm, but, in another equal server it gives to me this error: Oracle.DataAccess.Client.OracleException at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx,

Set Folder Permissions

送分小仙女□ 提交于 2019-12-24 02:54:06
问题 I have the following code which works fine when creating folders: public void CreateFolders() { _SharePoint.ClientContext _ClientContext = new _SharePoint.ClientContext("https://sharepoint.oshiro.com/sites/oshirodev/"); _ClientContext.Credentials = new NetworkCredential("user", "pass", "oshiro.com"); var _web = _ClientContext._web; var _Root = _web.Lists.GetByTitle("Library1"); var _folder1 = _Root.RootFolder.Folders.Add("Folder1"); var _subfolder1 = _folder1.Folders.Add("SubFolder1");

Rx produce and consume on different threads

两盒软妹~` 提交于 2019-12-24 02:41:35
问题 I have tried to simplify my issue by a sample code here. I have a producer thread constantly pumping in data and I am trying to batch it with a time delay between batches so that the UI has time to render it. But the result is not as expected, the produce and consumer seems to be on the same thread. I don't want the batch buffer to sleep on the thread that is producing. Tried SubscribeOn did not help much. What am I doing wrong here, how do I get this to print different thread Ids on producer

Code contracts - Rewriter fails with missing reference

∥☆過路亽.° 提交于 2019-12-24 02:08:01
问题 I'm trying to use code contracts for some libraries I have. My library A has a reference to ThirdParty library B. Library C references A, and never uses B nor does it use the bits of A that use B. The rewriter fails though trying to find library B. The reference assembly for A exists, I was hoping that the rewriter would be just happy with that. Any ideas on how I can build this, short of moving the bits in A that rely on B out into its own assembly? EDIT: To answer a question, yes, there are

Locking to load data to cache

限于喜欢 提交于 2019-12-24 02:06:06
问题 I have a helper class in a web app, and among the things it does is to present common, unchanging data objects as static properties. I'm loading these object as below: public static class MyWebHelper { #region - Constants & Fields private const string LocationCacheKey = "MyWebHelper_Locations"; private static object LocationLoadLock = new object(); private static MemoryCache m_SiteCache; #endregion #region - Properties /// <summary> /// Gets the uneditable collection of locations. /// <

Why Convert.ToInt32(1.0/0.00004) != (Int32)(1.0/0.00004)

元气小坏坏 提交于 2019-12-24 01:44:54
问题 Why this code http://ideone.com/YRcICG void Main() { double a = 0.00004; Int32 castToInt = (Int32)(1.0/a); Int32 convertToInt = Convert.ToInt32(1.0/a); Console.WriteLine("{0} {1:F9} {2:F9}", castToInt == convertToInt, castToInt, convertToInt); Console.WriteLine((((int)(1.0/(1.0/25000))) == 24999)); } results in False 24999,000000000 25000,000000000 True in context of CLR/C# implementation 回答1: The trick lies in the way the double is represented so (1.0/a) will be represented in the following

How does Task Parallel Library scale on a terminal server or in a web application?

女生的网名这么多〃 提交于 2019-12-24 01:29:10
问题 I understand that the TPL uses work-stealing queues for its tasks when I execute things like Parallel.For and similar constructs. If I understand this correctly, the construct will spin up a number of tasks, where each will start processing items. If one of the tasks complete their allotted items, it will start stealing items from the other tasks which hasn't yet completed theirs. This solves the problem where items 1-100 are cheap to process and items 101-200 are costly, and one of the two