Hold on to your hats, cowboys and cowgirls! A lot of exciting things are coming out of the .NET Managed Languages team for Visual Studio 2015 Update 1. Read on to learn more about new IDE features, interactive C#, new code analysis management, Visual F# improvements, and the new F5 experience for Roslyn open source development. New Editor Features Now that we have Roslyn in Visual Studio 2015, we can leverage its power to create the smartest IDE out there. The improvements we’ve made to the IDE experience in Update…
Category: .NET
.NET (dotnet) is a developer platform made up of tools, programming languages, and libraries for building many different types of applications.
So, there are various implementations of .NET (dotnet). Each implementation allows .NET code to execute in different places—Linux, macOS, Windows, iOS, Android, and many more. This framework has two main versions:
- Framework is the original implementation of .NET. It supports running websites, services, desktop apps, and more on Windows.
- Core is a cross-platform implementation for running websites, services, and console apps on Windows, Linux, and macOS. .NET Core is open source on GitHub.
Then, Xamarin/Mono is a .NET (dotnet) implementation for running apps on all the major mobile operating systems, including iOS and Android.
The .NET Standard is a formal specification of the APIs that are common across .NET implementations. This allows the same code and libraries to run on different implementations.
Therefore, the two major components of .NET (dotnet) Framework are the Common Language Runtime and the .NET Framework Class Library.
- The Common Language Runtime (CLR) is the execution engine that handles running applications. It provides services like thread management, garbage collection, type-safety, exception handling, and more.
- The Class Library provides a set of APIs and types for common functionality. It provides types for strings, dates, numbers, etc. The Class Library includes APIs for reading and writing files, connecting to databases, drawing, and more.
Summarize, .NET (dotnet) applications are written in the C#, F#, or Visual Basic programming language. Code is compiled into a language-agnostic Common Intermediate Language (CIL). Compiled code is stored in assemblies—files with a .dll or .exe file extension.
At the end, when an app runs, the CLR takes the assembly and uses a just-in-time compiler (JIT) to turn it into machine code that can execute on the specific architecture of the computer it is running on.
Implementing the Inversion of Control Pattern in C#
Implement the inversion of control pattern is linked with the Dependency Injection Principle states. Here we analyse a simple implementation
How to generate a random password
These code samples demonstrate how to generate a strong random password, which does not contain ambiguous characters (such as [1,l,I] or [O,0]). A strong password must be at least eight characters long and contain a combination of lower- and upper-case letters, numbers, and special characters. /////////////////////////////////////////////////////////////////////////////// // SAMPLE: Generates random password, which complies with the strong password // rules and does not contain ambiguous characters. // // To run this sample, create a new Visual C# project using the Console // Application template and replace the contents of the Class1.cs…
How to use REPLACE() within NTEXT columns in SQL Server
SQL has an incredibly useful function, REPLACE(), which replaces all occurrences of a specified string with another string, returning a new string. It works great with all forms of NCHAR and NVARCHAR fields. It does not, however, work with NTEXT fields. Fear not — there’s an easy workaround, thanks to type-casting and SQL 2005’s NVARCHAR(max) datatype. Here’s the process in an nutshell. Cast the NTEXT field to the NVARCHAR(max) datatype using the CAST function. Perform your REPLACE on the output of #1. Cast the output of #2 back to NTEXT.…
Using iTextSharp to generate pdf file in asp.net
One of the common requirement of web applications is to provide users a way to download some contents. In case of a report, almost all of the reporting tools have the export to pdf kind of function available. But sometime, it is not a report that needs to be generated in pdf. But it could be simple web page or content of a page or sometimes a plain text needs to be generated in pdf format. There are many third party tools are available for this task. We can import…
Happy 60th Birthday Bill Gates
The founder of Microsoft and wealthiest man in the world turns 60 years old today. William Henry Gates III was born October 28th, 1955 in Seattle, Washington where he still resides in his post Microsoft years. He has much to celebrate as he turns 60. After leading Microsoft for decades it must be quite rewarding to see the company he founded grow in such a bold direction this year with a booming commercial cloud computing division, new category defining hardware that is leading the competition, and an incredibly fast adoption…
Write C#. Run JavaScript.
Open Source C# to JavaScript Compiler and Frameworks. Run Your App On Any Device Using JavaScript. Use Bridge.NET to build platform independent applications for mobile, web and desktop. Run on iOS, Windows, Mac, Linux and billions of other devices with JavaScript support. Compile your C# code into native JavaScript and deploy on Billions of devices. Try it on bridge.net or fork it on GitHub
How do I get a Unique Identifier for a Device within Windows 10 Universal?
If you google a bit about this problem, you can’t find a right solution because all people are speaking about Hardware Token. Unfortunately this functionality doesn’t exists for Universal Windows Application. There are at the moment only a way. You have to add the Extension reference “Windows Desktop Extensions for the UWP” or “Windows Mobile Extensions for the UWP“, then you can use the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Windows.Security.ExchangeActiveSyncProvisioning; using Windows.System.Profile; namespace PSC.Code { public sealed class DeviceInfo { private static…
How can I know when SQL Full Text Index Population is finished?
When you execute some queries on your SQL Server, are you sure the catalog is being imported? With this simple script you can know which is the Index status. DECLARE @CatalogName VARCHAR(MAX) SET @CatalogName = ‘TEST_FullIndex’ SELECT FULLTEXTCATALOGPROPERTY(@CatalogName,’ItemCount’) as NumberOfItems, FULLTEXTCATALOGPROPERTY(@CatalogName,’ImportStatus’) as ImportStatus, DATEADD(ss, FULLTEXTCATALOGPROPERTY(@CatalogName, ‘PopulateCompletionAge’), ‘1/1/1990′) AS LastPopulated, (SELECT CASE FULLTEXTCATALOGPROPERTY(@CatalogName,’PopulateStatus’) WHEN 0 THEN ‘Idle’ WHEN 1 THEN ‘Full Population In Progress’ WHEN 2 THEN ‘Paused’ WHEN 3 THEN ‘Throttled’ WHEN 4 THEN ‘Recovering’ WHEN 5 THEN ‘Shutdown’ WHEN 6 THEN ‘Incremental Population In Progress’ WHEN 7 THEN ‘Building…
How to remove HTML tags from data with SQL
The purpose of this article is to provide a way of cleaning up of HTML tags within the data. When we use various styles or tabular format data in UI using Rich Text Editor/ Rad Grid etc, it will save data in database with HTML tags. When you save in database this kind of field you have: An HTML element starts with a start tag (<p>) and ends with end tag (<p/>) and everything between Start tag and End tag is HTML element. e.g. <b>Following are the popular databases: <br…
SQL SERVER – Find Current Location of Data and Log File of All the Database
As I am doing lots of experiments on my SQL Server test box, I sometime gets too many files in SQL Server data installation folder – the place where I have all the .mdf and .ldf files are stored. I often go to that folder and clean up all unnecessary files I have left there taking up my hard drive space. I run following query to find out which .mdf and .ldf files are used and delete all other files. If your SQL Server is up and running OS will…
How to strip all HTML tags and entities and get clear text?
I was encouraged to write this Tip/Trick because of so many questions received for this issue. Suppose you’re having a bunch of HTML strings, but you just want to remove all the HTML tags and want a plain text. You can use Regex to come to the rescue. The Regex I had developed before was more cumbersome, then Chris made a suggestion, so I will now go further with the regex suggested by Chris that is a "\<[^\>]*\>". I have tested it for many cases. It detects all types of…
Templated Razor Delegates
What’s that? I’ll let the code do the speaking. @{ Func<dynamic, object> b = @<strong>@item</strong>; } <span>This sentence is @b(“In Bold”).</span> That could come in handy if you have friends who’ll jump on your case for using the bold tag instead of the strong tag because it’s “not semantic”. Note that the delegate that’s generated is a Func<T, HelperResult>. Also, the @item parameter is a special magic parameter. These delegates are only allowed one such parameter, but the template can call into that parameter as many times as it needs.…
Creating reusable HTML components in ASP.NET MVC using Razor
Whilst working on a side project I started to notice I was using a lot of the same HTML to create floating boxes. Whilst these boxes looked the same, the content of them changed quite dramatically; for instance, some of the content boxes contained forms, others contained straight text, like so: <div class="panel"> <div class=panel-inner"> <h2 class="panel-title">Panel Title</h2> <div class="panel-content"> /* Can I pass content to be rendered in here here? */ </div> </div> </div> </div> As my side project progressed and grew, I found myself making more and…
Design, Source and Split tabs are missing in Visual Studio 2015?
If the HTML file is in Solution Explorer, then right-click and select “Open With”. Otherwise open it with Open File dialog, but click the small dropdown arrow in the Open button, then select “Open With”. Then select “HTML (Web Forms) Editor with Encoding”. Then you should see the Design, Split and Source buttons. Click Design.
ASP.NET: The data protection operation was unsuccessful
the data protection operation was unsuccessful. this may have been caused by not having the user profile loaded for the current thread’s user context, which may be the case when the thread is impersonating. If you receive this error from one of your application, you resolve the problem in this way: Open IIS Manager Select Applications Pools, and go ahead and select the App Pool used by your app Right-click on it, and select Advanced Settings, Go to the Process Model Section and Find the “Load User Profile” Option and…
Visual Studio 2015: upgrade all NuGet packages at one time
Open the Package Manager Console and use the Update-Package cmd-let to update all packages. If this doesn’t work, you have other two solution. Always in Package Manager Console you type one of those: First solution $list = Get-package -project {Add project name here} for($i=0; $i -lt $list.Length;$i ++ ) { Update-Package -project {Add project name here} $list[$i].Id } Replace {Add project name here} with your project name without braket Second solution foreach ($p in get-project -all) { update-package -ProjectName $p.ProjectName } Happy coding!
How to truncate log file in SQL Server
In SQL Server data is stored using two physical files: (.mdf) extension which contains the data. (.ldf) extension which contains log. Log file size increases very rapidly and depend on the operation performed on the data. After a long time period this file becomes too large. When log file is too large it takes time to perform some operations like (attach, de-attach, backup, restore… etc ). Step 1. Copy/type the below given SQL. Step 2. Change @DBName to <Database Name>, @DBName_log to <Log File Name> Step 3. Execute the SQL.…
UWA: This application can only run in the context of an AppContainer
Run it from VS (with or without debugging). This will actually install unpackaged version of your app, so you will see it in the start screen. Create a package to use locally. You can do this in VS by going to Store → Create App Package → Build a package to use only locally. This will create a bunch of files, including a command-line script that will actually install the app. You probably could use this method to distribute the app, but it would work only on developer-enabled computers. Publish…
Console Progress Bar with C#
The progress of these applications with a simple incremental percentage display. I’d create a generic method which would display an ASCII progress bar
Universal Windows app samples
On GitHub Microsoft have published a lot of examples for Universal Apps: the link is https://github.com/Microsoft/Windows-universal-samples This repo contains the samples that demonstrate the API usage patterns for the Universal Windows Platform (UWP) in the Windows Software Development Kit (SDK) for Windows 10. These code samples were created with the Universal Windows templates available in Visual Studio, and are designed to run on desktop, mobile, and future devices that support the Universal Windows Platform. Universal Windows Platform development These samples require Visual Studio 2015 and the Windows Software Development Kit…
Windows 10: Changing Paradigms
Windows 10 is the main discussion topic in the online development communities. This new operating system that is currently in the technical preview (and available through the Microsoft insider program) is a milestone in the platform unification journey that Microsoft embarked upon with starting with Windows Phone and Windows 8 operating systems. With Windows 10, developers and users are introduced to one development kit, one store, one application and one binary distribution package. Introducing Windows Core With Windows 10, developers are introduced to the new Windows Core concept. Windows Core…
ASP.NET MVC 3: Razor’s @: and syntax
Razor minimizes the number of characters and keystrokes required when writing a view template, and enables a fast, fluid coding workflow. Unlike most template syntaxes, you do not need to interrupt your coding to explicitly denote the start and end of server blocks within your HTML. The Razor parser is smart enough to infer this from your code. This enables a compact and expressive syntax which is clean, fast and fun to type. For example, the Razor snippet below can be used to iterate a list of products: When run,…
Using the UpdateProgress to lock down controls in the browser
If it takes awhile for the server to process the postback (e.g. complex rules or badly written code ), the user may not realize that the server is processing the request. This can lead to all kinds of issues with users that are not savvy or familiar with web applications (multiple clicks, moving off the page, etc.). Consequently, I want to tell the user that the server is processing the request and disable the controls on the page. Let’s break this down into two steps: show a message, and disable…
Download ReportViewer 2010, ReportViewer 11 and SQLSysClrTypes
Have you tried to install ReportViewer on a server? If you as me receive a similar error, I have a solution. When you have to install the Report Viewer on a server, it’s quite difficult to find the install file and a reference for Report Viewer 11 (SQL System Clear Tyle). Here you can download the last ReportViewer with its dependencies. SQLSysClrTypes.zip (1.4MB)ReportViewer.zip (6.1MB)ReportViewer2010.zip (4.5MB)