{"id":5889,"date":"2014-04-08T01:51:39","date_gmt":"2014-04-08T01:51:39","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/08\/netrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-04-08T01:51:39","modified_gmt":"2014-04-08T01:51:39","slug":"netrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/08\/netrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":".netRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1355030928a7422efe6349a3ae9bca83?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJoey Adams<br \/>\nc# .net<br \/>\nSuch as int, long, ushort, uint, short, etc.Why isn&#8217;t there a short hand for System.DateTime?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/283f2d8d0a11ae7d384105111c391539?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSimon Svensson<br \/>\nc# .net visual-studio-2010 linq visual-studio-2012<br \/>\nSomehow following code doesn&#8217;t compile in VS2010 but compiles in VS2012 without changes. The problematic line in VS2010 is names.Select(foo.GetName)error CS1928: &#8216;string[]&#8217; does not contain a definition for &#8216;Select&#8217; and the best extension method overload &#8216;System.Linq.Enumerable.Select&lt;TSource,TResult&gt;(System.Collections.Generic.IEnumerable&lt;TSource&gt;, System.Func&lt;TSource,TResult&gt;)&#8217; has some invalid arguments.using System; using System.Linq;namespace ConsoleApplication1 {class Pro<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/34b152ef95a49568ce45df38cd87e54b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJim Mischel<br \/>\n.net timer<br \/>\nNote that I&#8217;m asking about something that will call a callback function more often than once every 15 ms using something like System.Threading.Timer. I&#8217;m not asking about how to accurately time a piece of code using something like System.Diagnostics.Stopwatch or even QueryPerformanceCounter.Also, I&#8217;ve read the related questions:http:\/\/stackoverflow.com\/questions\/448761\/accurate-windows-timer-system-timers-timer-is-limited-to-15-msechttp:\/\/stackoverflow.com\/questions\/163022\/high-resolution-timer<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fc763c6ff6c160ddad05741e87e517b6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBill the Lizard<br \/>\nc# .net out-of-memory<br \/>\nWhy does this:class OutOfMemoryTest02 {static void Main(){string value = new string(&#8216;a&#8217;, int.MaxValue);} }Throw the exception; but this wont:class OutOfMemoryTest {private static void Main(){Int64 i = 0;ArrayList l = new ArrayList();while (true){l.Add(new String(&#8216;c&#8217;, 1024));i++;}} }Whats the difference?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/074c2b060d56469cd0ef5cc22a296511?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nClafou<br \/>\n.net localization internationalization datetime-format pseudolocalization<br \/>\nMy computer is configured with a culture that is not en-US. When using the native Win32 GetDateFormat function, i get correctly formatted dates:22\/\/11\/\/2011 4::42::53 P?~M]This is correct; and is also how Windows renders it:the taskbarRegion and Language settingsWindows ExplorerOutlookWhen i try to convert a date to a string in .NET using my current locale, e.g.:DateTime.Now.ToString(); DateTime.Now.ToString(CultureInfo.CurrentCulture);i get an incorrect date:22\/\/\/\/11\/\/\/\/2011 4::::42::::53 P?~M]<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/584af3726b023529d793a14ec8f3ba10?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKos L.A.<br \/>\n.net winforms nunit-2.5<br \/>\nFirst of all, sorry for my english since it&#8217;s not my native language.Problem was happened in my .NET Windows Forms Application and reproduced only on Virtaul PC Windows 7 (x64) for some reasons. I faced with Win32Exception in one place of my application when resizing main application form containing a lot of custom controls, including two stacked to each other tabcontrols etc&#8230; Exception&#8217;s message was &#8220;Error creating window handle&#8221;. Spending some time I found solution for that problem on Micro<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/71ae61f3d92a5bfed2ec863dc2a2a246?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRobert P<br \/>\nc# .net winapi watin screenshot<br \/>\nI&#8217;m currently working with WatiN, and finding it to be a great web browsing automation tool. However, as of the last release, it&#8217;s screen capturing functionality seems to be lacking. I&#8217;ve come up with a workable solution for capturing screenshots from the screen (independently generating code similar to this StackOverflow question) in addition to some code by Charles Petzold. Unfortunately, there is a missing component: Where is the actual window?WatiN conveniently provides the browser&#8217;s hWnd<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b5eeca6a29e9ed32de6c6f236256ee83?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGrand Avenue Software<br \/>\nc# .net authentication active-directory .net-4.5<br \/>\nIn testing our .NET 4.0 application under .NET 4.5, we&#8217;ve encountered a problem with the FindByIdentity method for UserPrincipal. The following code works when run in a .NET 4.0 runtime, but fails under .NET 4.5:[Test] public void TestIsAccountLockedOut() {const string activeDirectoryServer = &#8220;MyActiveDirectoryServer&#8221;;const string activeDirectoryLogin = &#8220;MyADAccount@MyDomain&#8221;;const string activeDirectoryPassword = &#8220;MyADAccountPassword&#8221;;const string userAccountToTest = &#8220;TestUser@MyDomain&#8221;;const<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c14410098f9fed129fd8e36285b699c8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser2668128<br \/>\nc# asp.net .net asp.net-web-api<br \/>\nI have created a basic ASP.NET Web Api Application inside VS Express 2013 using all of the defaults. I added a controller and it returns XML just as I want.As soon as I install the CORS package:Install-Package Microsoft.AspNet.WebApi.Cors -PreI can&#8217;t even run the application anymore:An exception of type &#8216;System.IO.FileLoadException&#8217; occurred in mscorlib.dll and wasn&#8217;t handled before a managed\/native boundaryAdditional information: Could not load file or assembly &#8216;System.Web.Http, Version=5.0.0.0<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/94d4115a9ebb288e4594726cbc2ac9a3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHeavenCore<br \/>\nc# .net vb.net visual-studio<br \/>\nTake the following class:Public Class DocumentNumberPrivate m_DOC_NUMBER As Integer = 0Public Sub New(ByVal DOC_NUMBER As Integer)m_DOC_NUMBER = DOC_NUMBEREnd SubPublic Sub New(ByVal DEPOT_CODE As String)Dim ParseInput As Integer = 0If Integer.TryParse(DEPOT_CODE, ParseInput) = False Thenm_DOC_NUMBER = 0Elsem_DOC_NUMBER = ParseInputEnd IfEnd Sub&#8221;&#8217; &lt;summary&gt;&#8221;&#8217; Returns the DOC_NUMBER as a zero-padded number, eg: 0000028374&#8221;&#8217; &lt;\/summary&gt;Public Overrides Function ToString() As StringRe<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Joey Adams c# .net Such as int, long, ushort, uint, short, etc.Why isn&#8217;t there a short hand for System.DateTime? Simon Svensson c# .net visual-studio-2010 linq visual-studio-2012 Somehow following code doesn&#8217;t compile in VS2010 but compiles in VS2012 without changes. The problematic line in VS2010 is names.Select(foo.GetName)error CS1928: &#8216;string[]&#8217; does not contain a definition for &#8216;Select&#8217; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5889","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5889"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5889\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}