background preloader

C#

Facebook Twitter

Patterns & practices

Using Microsoft Roslyn. Microsoft Roslyn is an API that exposes the C# compiler as a service or one can say now the entire compiler is exposed in a form of a library that can be included in your project or application, earlier you needed to write code in C# and build that code, if it is successful then you get the compiled code in the form of an assembly, but now you can actually build or compile the code dynamically from within your .Net applications.

You can now have Build process information or compile process information that was not available earlier. So now you can pass in your code as a string to the API and it will provide you with the code in Intermediate Language (IL) with syntactic and semantic information regarding your code. So the major advantage we get is one can do the Code Analysis using Roslyn. Roslyn API(s) are available as NuGet Packages; you can do something anytime, so one can install it very easily by the Package Manager. PM> Install-Package Roslyn.Compilers.Common And you are ready to go. First steps into the world of application security: My own C# trojan - remote shell command execution. In this post I will present you a simple "shell" I created using c#.NET. The trojan runs in the background, opens a listening port on the machine running it and allows any connected client to execute remote shell commands.

This application is for educational purposes only (mostly my own). how to use it? Simply run the trojan on the target machine and connect to it through port 13000 using telnet or netcat. After the connection had established, you may execute any shell command on the target machine: code: You may download the executable file from here.

Oh.. and don't forget to kill that process when you finish playing with it :) -herzel. C# - PrintScreen only active window. Simplifying Serialization and De-serialization Processes With XSD.EXE. Download demo project - 11.4 Kb Introduction XSD.EXE is an XML Schema Definition tool that generates XML schema or common language runtime classes from XDR, XML, and XSD files, or from classes in a runtime assembly. An XML-schema is a document that describes the valid format of an XML data-set. This definition includes what elements are (and are not) allowed at any point, what the attributes for any element may be, the number of occurrences of elements, etc.

Deserialization Process Let us assume you are building a web service, which takes XML (in the form of string) as input, and shown below is the schema of the data that is to be exchanged between the clients and your web service. To deserialize, first we need to build a class as below: Building such a class by seeing the XML schema is a time consuming and error prone process. First, build the class using the XSD.EXE tool provided by the .NET framework.

XSD.EXE file.xsd /classes /language:[language] The output class is as follows: How to improve your LINQ query performance by 5 X times? Download source code - 849 KB Table of contents Introduction and goal LINQ has been criticized by many early adopters for its performance issues. Well, if you are just going to drag and drop using a DBML code generator, I am sure you will land up in a mess. Try doing this, make a simple LINQ to SQL project using DBML and see your SQL profiler. In this article, we will first look into how LINQ queries are executed, and then we will touch base on how compiled LINQ queries can help us improve our application performance at least 5 times. Still new to LINQ? This article requires some pre-requisites, in case you are new to LINQ I would suggest you to go through the below links. Are you a complete newbie: LINQNewbie.aspxLINQ FAQ Part II: LINQFAQPart2.aspxWant to define 1-* and *-1 using LINQ: OneManyandOneOneLINQ.aspxIssues of multiple trips handled in this article: OptimizingLINQ.aspxDo not know how to call Stored Procedures using LINQ: 6stepsLINQ.aspx Deep dive into how LINQ queries work.

Printing In C# - C# Tutorials. Obteniendo cuentas de Whatsapp y Line como churros. Hace unos dias Yago me comentaba que le interesaba el tema de la telefonía VoIP. Le compartí algunas cosas sobre el tema que le gustaron y a raíz de esa conversación sale este post. Un poco de historia: el "phreaking" Realmente el "phreaking" (término que viene de "phone freak", monstruo de la telefonía) tuvo su momento glorioso en el pasado, y quien sea mas bien "30 añero" recordará haber leído en los ezines de los años 90 aquellas historias del mítico Joe Engressia, que podía marcar números de teléfono sin tocar el teclado, silbando; o de John Draper, conocido como "Capitán Crunch" porque utilizaba la misma técnica que Engressia, pero ayudado por un silbato sacado de una caja de cereales.

Hubo mucho más: se desarrollaron dispositivos muy variados, llamados todos ellos "boxes", y a los cuales se les asignaba un color en función de lo que hacian, hasta el punto en que fué posible manipular de mil y una formas las lineas telefónicas de la por aquel entonces hegemónica AT&T. Cuenta SIP.

Otros

BackgroundWorker Class Sample for Beginners. Download source - 27.27 KB Introduction This article presents a novice .NET developer to develop a multithreading application without being burdened by the complexity that comes with threading. Background A basic Windows application runs on a single thread usually referred to as UI thread. This UI thread is responsible for creating/painting all the controls and upon which the code execution takes place.

So when you are running a long-running task (i.e., data intensive database operation or processing some 100s of bitmap images), the UI thread locks up and the UI application turns white (remember the UI thread was responsible to paint all the controls) rendering your application to Not Responding state. Using the Code What you need to do is to shift this heavy processing on a different thread. Leave the UI thread free for painting the UI. .NET has made the BackgroundWorker object available to us to simplify threading. The steps are extremely simple: Create a BackgroundWorker object. Properties. OpenPop.NET - How to fetch all messages. Captura Teclas / Keylogger en C# independiente del foco de la aplicación | hvivani's website. Captura Teclas / Keylogger en C# independiente del foco de la aplicación Este es un capturador de teclas independiente de si la aplicación tiene el foco o no.

Trabaja en modo consola, pero puede adaptarse a diversas necesidades. Me gusta: Me gusta Cargando... Acerca de hvivani sysadmin, developer, RHCSA Esta entrada fue publicada en Uncategorized y etiquetada .NET, C#. OData and AtomPub - Building an AtomPub Server Using WCF Data Services. If you’re not familiar with it, the Open Data Protocol (OData) is a thing of beauty. OData (described in detail at odata.org) builds on the HTTP-based goodness of Atom for publishing data; AtomPub for creating, updating and deleting data; and the Microsoft Entity Data Model (EDM) for defining the types of data. If you have a JavaScript client, you can get the data back directly in JSON instead of Atom format, and if you’ve got something else—including Excel, the .Microsoft NET Framework, PHP, AJAX and more—there are client libraries for forming OData requests and consuming OData responses.

If you’re using the .NET Framework on the server side, Microsoft also provides an easy-to-use library called WCF Data Services for exposing .NET Framework types or databases supported by the Microsoft Entity Framework as OData sources. This makes it easy to expose your data over the Internet in an HTTP- and standards-based way. A Simple Blog Figure 1 A Post Entity Created in Visual Studio 2010 <? <? Enjoy! Domina fácilmente TypeScript. Hace unos días se presentó TypeScript y hemos podido leer varias cosas sobre este nuevo lenguaje creado por Microsoft que pretende integrarse en nuestros editores e IDEs de forma fácil. Principalmente se caracteriza por implementar las ventajas de un lenguaje orientado a objetos y las ventajas de JavaScript, permitiéndonos usar ambos a la vez (podríamos escribir la mitad en JavaScript y la otra en el lenguaje propio de TypeScript) y por supuesto el código que tuviésemos de JavaScript no se verá alterado, por lo que no hará falta modificar ninguna libreria.

Implementarlo Podemos usar TypeScript de varias formas muy sencillas: Instalar en Node.js: para instalarlo solo debemos de introducir el siguiente comando para instalar la extensión npm install -g typescript y posteriormente para compilarlo usaremos tsc [Nombre del archivo].ts. Primeros pasos Una de las cosas básicas que nos permite TypeScript es establecer el tipo de variable fácilmente. El uso de “interface” Class y JavaScript Conclusión. Using the Entity Framework 4.3 in .NET Development. Introduction This article describes how to use the Entity Framework for building applications through a tutorial. The Entity Framework enables developers to create data access applications by programming against a conceptual application model instead of programming directly against a relational storage schema. The goal is to decrease the amount of code and maintenance required for data-oriented applications.

The end product will be a group of unit tests that use the Entity Framework to query and update the database. This code can be used in your data-oriented application for data access and updates. No ADO.NET code is used to communicate with the database. The objects that are returned are enumerable types that can be traversed using LINQ.

Development Environment The following applications are required for this tutorial. The NuGet package manager is not required but it is highly recommended for installing external components like the Entity Framework. Setting up the Database.

WCF

Clicking a Button in Another Application. This article provides a simple sample of an application that clicks a button in another application. This article provides a simple sample of an application that clicks a button in another application. The technique could be used for other controls too. For the purpose of a simple sample the program is a console program. The sample will click the "=" button in the Windows Calculator Acesssory.

Note that I am using Windows 7; if the Windows Calculator Acesssory in Windows 8 is different and/or cannot be used in the manner it is used here then I hope you can find another program to use. The first thing to do is to determine what button to click and the circumstances of when to click it. The next thing to do is to determine the identity of the button to be clicked so our program can click it. Click on the "Find Window" icon; it is a binoculars with a window in the top-left; it looks like: That will open a "Find Window" dialog. Look for "Contol ID" near the botom of the first (General) tab. Documentation. Generación de Unit Tests con Visual Studio 2010 y C# 4.0 « Blog de Fernando Machado Piriz. Este es el segundo artículo de la serie sobre herramientas y técnicas de testing con Visual Studio 2010, Team Foundation Server 2010, Microsoft Test Manager 2010, y C# 4.0.

En el primer artículo mostraba cómo Visual Studio permite hacer test driven development. Visual Studio también genera automáticamente unit tests a partir del código a probar. En este vídeo verán cómo crear un unit test para un método Subtract de la clase Calculator. También pueden descargar el video. Publicaré más videos próximamente. Me gusta: Me gusta Cargando...

ActiveMQ

EF.