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…
Google Launches Android Studio 2.0 With Improved Android Emulator And New Instant Run Feature
Google today launched version 2.0 of its Android Studio integrated development environment (IDE) for writing apps for its mobile operating system. Android Studio, which is based on IntelliJ, launched back in 2013 and came out of beta a year ago. It includes everything a developer needs to build an app, including a code editor, code analysis tools, emulators for all of Google’s Android platforms, and more. The new version is now available as a preview in the Canary release channel of Android Studio. With version 2.0, as Google’s group product…
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…
Microsoft’s new Windows 10 build allows you to text from your PC, but it’s the bug fixes that impress
Unfortunately, it requires an upgrade from Windows Phone 8.1 – again. Microsoft launched build 10572 of Windows 10 Mobile to its insiders, together with a few nifty improvements on the messaging fronts. But, as before, you’ll still need to first downgrade to Windows Phone 8.1 to take advantage. Microsoft did say, however, that this two-steps-back, one-step-ahead approach will soon stop, and users in the Windows Insider program will once again be able to upgrade from Windows 10 preview builds without having to downgrade first. But the new build offers several…
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 Enable SQL Full Text Indexing
The following steps will tell you if your database version supports full text searching and if so how to enable it. Open SQL server management console Right click on the database and select properties On the left select files If “Full-Text Indexing” is greyed out it means that full-text indexing is not enabled. NOTE: If you are using SQL Server 2012 Please see the SQL Server 2012 notes at the bottom of this article. How to enable Full Text Searching Click on the New Query button top left of the…
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…
Microsoft Announces Office 2016 Will Arrive September 22
Microsoft announced this morning the official launch date for the long-anticipated new version of Microsoft Office: Office 2016 will be broadly available starting on September 22, the company says. Meanwhile, Office Customers with volume licensing agreements will be able to download the software on October 1st. The updated version of Office includes a number of new features for desktop customers, including the ability to co-edit documents at the same time, sync files to OneDrive in the cloud, and more. Alongside the announcement of the launch date, Microsoft noted a few…
Print a table structure in SQL Server
I was wondering how it’s possible to get the structure of one or more table(s) in a database, using possibly a SELECT; I need to retrieve the composition of the DB I’m working onto to attach it in some docs about the webapp I’m currently developing. SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_NAME
Track events for Google Analytics and Piwik
After my post of yesterday, I’ve worked for creating a script to integrate Google Analytics (new version with analytics.js) and Piwik (Piwik is the leading open-source analytics platform similar to Google Analytics. You can download it from its site or directly in your IIS with WebMatrix). With this code you have only one function to call in every part of your page. Automatically the function detects download, email, phone number, external links and tracks them. You can insert in an anchor a code like: <a href=”https://puresourcecode.com/” onclick=”TrackEvent(‘Link to my site’, ‘PSC’,…
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…
Microsoft’s Windows 95 is 20-years-old today
When Microsoft kicked off work on Windows 95 way back at the beginning of the 90s, the company wasn’t to know how much of an impact it would have on our lives two decades on. In one fell swoop the new version of Microsoft’s OS brought a swish graphical user interface (GUI) to desktops for the first time and the much vaunted Start menu began life inside the mid-1995 edition of the OS. You only need look at the disquiet that surrounded its removal from Windows 8 and subsequent return…
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.…