Category: .NET

  • Making any call to a function of an object thread safe

        I was wondering how to modify old code to support threads /task . So I was making a small project about making any function of an object thread safe. NuGet Package at : https://www.nuget.org/packages/ThreadSafeObject/ The solution contain tests and 2 console project for .NET Core and .NET Framework 4.5.1 The usage is pretty…

  • Task and generic list

    Could you spot the problem in transforming one code that is sequential into a Task ( threaded ) one? First,this is the sequential one:     This is the modified with task:   Ok. If you do not know,here is a helper: Sometimes,at line it gives the error: System.Reflection.TargetInvocationException: Exception has been thrown by the…

  • Maintaining history of data

      What is this about? I tend to quote Fowler: “Usually when we see properties on a class,they represent questions we can ask of an object now. However there are times when we don’t want to just ask questions about a property of an object now,we also want to ask these questions about some point…

  • Five common mistakes for ASP.NET MVC accesing resources : css,js,images,ajax

    This is a Razor /MVC5 variant of older post http://msprogrammer.serviciipeweb.ro/2010/10/09/five-common-mistakes-for-asp-net-mvc-accesing-resources-css-js-images-ajax/ To have once for all the link to show to people,because too much makes the same error again and again. (From here – you can use ResolveUrl or Url.Content – it’s the same for me. I use ResolveUrl because I used first …) Case 1…

  • Async + sync completion + lock

    Let’s suppose that you have 2 functions = one true sync and one true async . Let’s suppose more that the sync one can must finish before calling next time ( think about some weird COM component or,in our days,SqlConnection ) If we look just at the async function,we could wait for all. However,the sync…

  • spot errors in VB

    Please spot the errors in the following code in VB.NET: Dim Diff As String = con.ExecuteCommand(“SELECT DATEDIFF(Day,(select [date] from table where Username = ‘” + txtUserName.Text + “‘),’” & DateTime.Now.ToString() & “‘)”) If (Diff > 30) Then Response.Redirect(“PleaseChangeMyPassword.aspx”) End If   ( find at least 3…) Side note: No wonder Visual Basic has died (…

  • Generating Visual Studio solution( or project) references

    A Visual Studio pacakge is a plugin of Visual Studio that can do (almost) anything inside Visual Studio I have made a small project that generates a list of all solution ( or project) references from VS:   You can find the solution at https://github.com/ignatandrei/ToolsAndUtilities/tree/master/VS2015/FindReferencesVS Also the video is at https://youtu.be/a3YHVjJ9fm4 Enjoy!

  • Thank you for all the API

    In our days it is simpler to make an application by putting together some API . I wanted to make a list of all my 5 Minutes .NET playlist videos . First,I have tried to find an application(nothing). Then I have read  You Tube API from https://console.developers.google.com/apis/library . With 2 http requests( one for retrieving…

  • IDisposable and Marshal.ReleaseCOMObject and dynamic in C#

      If you have worked with COM,you know that for every COM object that you access is not only necessary to null the reference,but also call Marshall.ReleaseCOMObject . This is a very error prone task,because you have all try / finally blocks All of this could be done easy with IDisposable,if 1. IDisposable calls the…

  • AppContext

    AppContext is like Application in ASP.NET (MVC). You can see the value all over the application And we can have the result in all dll’s by Video demo at https://youtu.be/GMgn4o3yPqw