Posts

Showing posts from 2012

The Horror: Uninstalling SQL Server 2008 R2 and his friends

Spanish version / Versión en Español It's common knowledge that even though Microsoft claims it's possible to have multiple versions of SQL Server Express side by side , that's generally considered a bad idea . So I set out to remove every trace of SQL Server in order to later install the latest R2 version. After many visits to Control Panel->Add or Remove Programs , in which I removed anything which had SQL Server in its name, four (4) creatures were left standing: Microsoft SQL Server 2008 Microsoft SQL Server 2008 Setup Files Microsoft SQL Server 2008 R2 Microsoft SQL Server 2008 R2 Setup Files If I tried to remove the setup files, I was told that I had to remove 2008 or 2008 R2 before. If I tried removing one of those, after running the whooooooole process without a hitch, the entry was still there. On a closer examination, R2 was always saying it was going to delete Microsoft Sync Framework , but it didn't do so (silently). So I tried nuking

Horror: Desinstalando SQL Server Express 2008 y sus amigos

Versión en inglés / English version Es sabido que esto siempre trae problemas. En mi caso, me vi obligado a meterme en este infierno porque no podía hacer restore de una base de datos porque el backp había sido hecho con una versión más nueva de SQL Server 2008 Express R2 SP1 (10.50.sarasa, yo tenía 10.0.sarasa). Es sabido también que aunque Microsoft dice que es posible tener varias versiones de SQL Server Express side by side , eso está conceptuado como una mala idea . Así que me dispuse a eliminar todo rastro de todo SQL Server para luego instalar la última versión del 2008 R2. Luego de varias visitas a Panel de Control->Agregar o quitar Programas , durante las cuales fui eliminando todo lo que tuviera SQL Server en su nombre, quedaron cuatro (4) criaturas en pie: Microsoft SQL Server 2008 Microsoft SQL Server 2008 Setup Files Microsoft SQL Server 2008 R2 Microsoft SQL Server 2008 R2 Setup Files Si intentaba eliminar los setup files, me decía que debía elim

C++: Parse enums and convert them to other types elegantly

Spanish version / Versión en Español Quite often, we need to to read a value from some source (file, socket, database) and convert it to an enum. In order to define the conversion in a single place, in C++, we usually define a function like this one: enum MyEnum{ VALUE_A, VALUE_B, VALUE_C }; MyEnum ParseMyEnum( const std::string& sMyEnum ){ //Conversion } But where do we define this function? Our first idea is to make it a private method of the class which uses the enum, but this is not possible if the enum is used by more than one class. In those cases, we have no choice but to define the function as a free function inside a namespace. C#'s enums can have methods and extension methods, which would be the most natural and object oriented solution. Nevertheless, since we're talking C++ now, we can use templates to solve this problem in a generic way, for every enum, and use template specialization to define the specific mapping for each enum. This can be

C++: Parsear enums y convertirlos a otros tipos de forma elegante

Versión en inglés / English version Muchas veces queremos leer algún valor de cierta fuente (archivo, socket, base de datos) y convertirlo a un enum. Para no andar repitiendo el código de esa conversión, típicamente creamos una función de este estilo: enum MyEnum{ VALUE_A, VALUE_B, VALUE_C }; MyEnum ParseMyEnum( const std::string& sMyEnum ){ //Conversion } ¿Y dónde ponemos esta función? La primera idea es ponerla como método privado de la clase que usa el enum, pero esto no sirve si el enum es usado por más de una clase. En esos casos, no nos queda más alternativa que definir la función fuera de toda clase, dentro de un namespace. Los enums de C# pueden tener métodos, lo cual sería la solución más natural y orientada a objetos. Sin embargo, en C++ podemos usar templates para resolver este problema de forma genérica para todo enum, y usar especialización de templates para definir el mapeo específico de cada enum. Para ello, definimos el siguiente template: #prag

Remote Debug with Visual Studio 2010

Image
Spanish version / Versión en Español Disclaimer: This tutorial was successfully tested with two Windows XP SP3 32 bits boxes (both with the latest updates), and also with a Windows 7 Professional 32 bits box together with a Windows XP 32 bit box. Other combinations might not work, or might need extra configuration. Both machines were hosts of the same organizational intranet (LAN). I guess it's possible to do this across networks, but it's a quite more complex scenario, mainly security-wise; firewall configuration and VPN establishment are the minimum hurdles I can think of. Therefore, we'll stick to a LAN this time. To make things shorter, let: VS : Computer where we'll run Visual Studio in order to perform remote debugging. RE : The remote machine, where the program to debug will run. With all this in mind, the steps are the following: Both boxes must have a user account with the same user name and password. In VS , we'

Debug remoto con Visual Studio 2010

Image
Versión en inglés / English version Ante todo, valgan las siguientes aclaraciones: Este procedimiento fue probado exitosamente con Windows XP SP3 de 32 bits con los últimos updates en ambas máquinas, y también con una máquina de debug con Windows 7 Professional de 32 bits y una máquina remota con Windows XP SP3 de 32 bits. Otras combinaciones pueden no funcionar. Ambas máquinas estaban dentro de la misma red interna de la organización. Supongo que es posible hacer debug remoto a una máquina en otra red, pero es un escenario más complejo que requerirá, mínimamente, configurar firewalls y establecer alguna especie de VPN o túnel. No consideraremos este escenario. Para abreviar, se define: VS : Máquina donde correremos el Visual Studio. RE : Máquina remota, donde se ejecuta el programa a depurar. Con todo esto en mente, los pasos a realizar son: Ambas máquinas deben tener una cuenta de usuario con el mismo nombre y contraseña. En VS , correremo

Team City and Powershell

Image
Spanish version / Versión en Español Say we need Team City to perform certain actions but we don't want to add another script to source control. In my case, I needed Team City to create a file if it didn't exist, and delete some others if they did. I couldn't use MSBuild for this because I needed this to be done before building any project. Though there are workarounds for that, they implied adding MSBuild scripts to source control. To avoid further cluttering the repo, Powershell is a good choice here. Using Team City's jargon, we can add a Build Step with a Powershell Build Runner , and write the script directly in its configuration page. Said script will be stored by Team City, leaving our repo intact. First of all, we need to have Powershell installed in our build server machine. It's usually bundled with Visual Studio and SQL Server installs, so most likely you already have it. Nevertheless, you can check if it so by opening a terminal and typing

Team City y Powershell

Image
Versión en inglés / English version Supongamos que necesitamos que Team City realice cierta acción sin tener que poner un script en control de código. En mi caso, necesitaba que Team City creara un archivo si no existía, y borrara otros si existían. No podía resolver esto con MSBuild porque necesitaba que se hiciera antes de compilar cualquier proyecto. Para no llenar aún más el repositorio, Powershell es una buena opción. Usando la jerga de Team City, podemos agregar un Build Step con un Build Runner de tipo Powershell, y escribir el contenido del script directamente en su configuración. Dicho script será almacenado por Team City, sin tocar nuestro repo. Si vamos a implementar esto, para empezar necesitamos que Powershell esté instalado en el servidor de integración continua. Típicamente, viene con Visual Studio y SQL Server, así que es casi seguro que ya está. De todas formas, para verificarlo, se puede abrir una consola, escribir powershell y darle a Enter. Si Powersh