Category: .NET

  • 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

  • Instrumentation in C# / .NET

    For many programmers a try/catch with stack trace it is enough Others want to see also functions arguments,like in will produce the result ERROR An exception occured in method InstrumentationPostSharp.Person.Drink with (beersNumber = 10,vodkaNumber = 2) For this you can install the package https://www.nuget.org/packages/LoggerAspect.Nlog that have full source code at https://github.com/vnvizitiu/AOP/tree/master/PostSharpTutorial and watch my video…

  • RavenDB embedabble

    I have made an application with RavenDB embeddable. The good part is that is embeddable and easy to work with – at least,at start. What I have learned: If you forgot to use using,then RavenDB will throw an exception complaining about multiple sessions. Code:   If you use multiple instance of the same EmbeddableDocumentStore,even on…

  • Export to Excel,Word,Pdf,Html,CSV

    I have made an application / package that exports data ( classes/datatable/csv/json) to Word/Excel/PDF. I have made several tries in the past,however now is the definitive source for .NET 4.x It is FULL code source,with tests and tutorials..   The code is at https://github.com/ignatandrei/Exporter  The NuGet package is at https://www.nuget.org/packages/ExporterWordExcelPDF The demo online is at…