Enviar datos desde javascript hacia un controller con AJAX en MVC

Método #1: Enviar form como JSON y otros parametros

Llamado Ajax

            var f = $("#form_refin").serializeFormJSON();
            var send = { param1: "111", param2: "222", datos: JSON.stringify(f) };
            
            jqxhr2 = $.ajax({
                type: "POST",                
                data: send,
                dataType: "json",
                url: "@Url.Action("Supervision2", "RefinanciacionArrendamiento")",
                beforeSend: function () {
                    //l.start();
                }
            }).fail(function (jqXHR, textStatus) {
                //l.stop();
                alert("Error: " + "Status: " + jqXHR.status + " detalle: " + textStatus + " detalle: " + jqXHR.responseText);
            }).success(function (data) {
                $("#HashSup").val(data);
            });


    (function ($) {
        $.fn.serializeFormJSON = function () {

            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };
    })(jQuery);




Controller

using Newtonsoft.Json;
...
...
...

[HttpPost]
public ActionResult Supervision2(string param1, string param2, string datos)
{            

 var refin = JsonConvert.DeserializeObject<RefinanciacionArrendamientoVM>(datos);
}


Método #2: Definir el objeto que se va a enviar manualmente

Llamado Ajax

$("#Modificar").click(function() {
var user = {
Documento: $("#txtDocumento").val(),
Email: $("#txtCorreo").val(),
Nombre: $("#txtNombre").val(),
TipoDoc: $("#drpTipoDoc option:selected").val()
}

jqxhr2 = $.ajax({

type: "POST",
async: false,
data: user,
dataType: "json",
url: "@Url.Action("ModificarUsuarioCreado", "Usuario")",
beforeSend: function () {}
})
.fail(function (jqXHR, textStatus) {})
.success(function (data) {}
);
});


Controller

[HttpPost]
public ActionResult ModificarUsuarioCreado(Usuario user) { ... }


public class Usuario

{
    public string Documento { get; set; }
    public string Email { get; set; }
    public string Nombre { get; set; }
    public string TipoDoc { get; set; }
}


Método #3: Enviar el Modelo completo

De esta forma se puede enviar el modelo desde la vista hacia un controller, cualquiera sea su estructura y complejidad.
Funciona con POST y GET, en este ejemplo se utiliza POST.
*** Tener en cuenta que utilizando este método NO se envían los datos modificados manualmente en el formulario o los datos cargados mediante javascript. Para poder hacer esto, utilizar el método 3 ***

Código en la View

Formulario:

@using Creditos.ViewModels.Liquidaciones
@model RefinanciacionArrendamientoVM
...
...
...    

Llamado Ajax

var model = JSON.parse('@Html.Raw(Json.Encode(Model))');

jqxhr2 = $.ajax({
                type: "POST",
                data: model,
                dataType: "json",
                url: "@Url.Action("Contabilizar", "RefinanciacionArrendamiento")" 
            }).fail(function (jqXHR, textStatus) {
                $("#arrendContent").html(jqXHR.responseText);
            }).success(function (data) {
                $("#div_mensaje").html(data.MsgError);
            });



Controller

[HttpPost]
public ActionResult Contabilizar(RefinanciacionArrendamientoVM refin) 
...
...
...


Método #4: Enviar el form serializado
De esta forma se pasan todos los datos del formulario (no del modelo, aunque si no se modifican los campos del form, son los mismos)
Este método permite pasar los cambios que se hagan en el formulario (cosa que el método #2 no puede hacer)

Llamado Ajax


jqxhr2 = $.ajax({
        }).fail(function (jqXHR, textStatus) {
            if (data.MsgError == "Refinanciación contabilizada correctamente.") {

    type: "GET",
    data: $('form').serialize(),
    dataType: "json",
    url: "@Url.Action("Contabilizar", "RefinanciacionArrendamiento")", 
    beforeSend: function () {                    
                  $.blockUI({
                      message: 'Espere por favor...',
                      css: {
                          border: 'none',
                          padding: '15px',
                          backgroundColor: '#000',
                          '-webkit-border-radius': '10px',
                          '-moz-border-radius': '10px',
                          opacity: 0.5,
                          color: '#fff'
                      }
                  });
               }

            $.unblockUI();

            $("#arrendContent").html(jqXHR.responseText);
        }).success(function (data) {
            $.unblockUI();
            $("#div_mensaje").html(data.MsgError);

                $("#btn_contabilizar").attr("disabled", "disabled");

                $("#btn_calcular").attr("disabled", "disabled");
            }                
        });







Cuando se actualizan los datos del modelo en el controller los cambios no se reflejan en la vista

Problema:
Cuando en un action de un controller se modifican datos del modelo y se hace el return View, en la vista no aparecen actualizados dichos datos.

Solución: 
Es necesario hacer ModelState.Remove("nombre-del-atributo")

Por ejemplo:

public ActionResult Prueba(ElModelo m)
{
     m.Nombre = "el nuevo nombre";
     ModelState.Remove("Nombre");
}


Evitar que internet explorer pida confirmación al ejecutar un componente ActiveX

La clase debe implementar la interfaz IObjectSafety.

Para compilarlo:

Ir a prompt de visual studio 2013 (abrirlo como administrador)

Si no hay una strong key, generarla con:
      sn -k keyImpresora.snk

cls
call "%VS120COMNTOOLS%..\Tools\vsvars32.bat"
csc /t:library Impresora.cs /keyfile:keyImpresora.snk
regasm Impresora.dll /tlb:ImpresoraNet.dll /codebase


Código C#

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.IO;
using System.Collections.Generic;

namespace X
{
[ComImport()]
[Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IObjectSafety
{
[PreserveSig()]
int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions);

[PreserveSig()]
int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions);
}

public enum Estilo
{
Normal,
Bold,
Enlarged,
Condensed
}
public interface IImpresora
{
string Imprimir(string texto, string estilo);
void FormFeed();
void Log(string texto);
string Inicializar(string usuario);
void Agregar(string linea);
void Listar();
}

public class Linea
{
public string Texto {get; set;}
public string Estilo {get; set;}
}

[ProgId("X.Impresora")]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class Impresora : IObjectSafety
{
bool _fin = false;
string _pathImpresora = "";
List<Linea> lineas;

    private const int INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001;
    private const int INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002;
    private const int S_OK = 0;

    [ComVisible(true)]
    public int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions)
    {
        pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
        pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
        return S_OK;
    }

    [ComVisible(true)]
    public int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions)
    {
        return S_OK;
    }

[ComVisible(true)]
public void Agregar(string linea)
{
var l = new Linea();

l.Texto = linea;

lineas.Add(l);
}

[ComVisible(true)]
public void Listar()
{
File.Delete(Environment.GetEnvironmentVariable("TEMP") + "\\outLog.txt");

foreach (var l in lineas)
{
var xx = "";

xx = l.Texto;

xx = xx.Replace((char)13 + "" + (char)10, "");

if (xx.Contains(Convert.ToChar(27) + "(s3B") || xx.Contains(Convert.ToChar(27) + "(s0B"))
{
//evito estas lineas porque hacen bloquear la impresora.
xx = "";
} else
{
xx = xx.Replace( Convert.ToChar(27) + "E" + "", (char)27 + "" + (char)69 + "");
}

Log(xx);
}

EjecutarComando("type %TEMP%\\outLog.txt > " + _pathImpresora);
}

[ComVisible(true)]
public string Inicializar(string usuario)
{
var archivo = @"c:\X_imp\" + usuario + @"\XframePrinter.properties";
var host = "";
var nombreImp = "";


if (File.Exists(archivo))
{
var f = new StreamReader(archivo);
while (!f.EndOfStream)
{
var linea = f.ReadLine();

if (linea.Contains("XframeConnectorService.PrinterDriver.drivers"))
{
var v = linea.Split('=');

host = v[1];
host = host.Substring(0, host.IndexOf(","));

}

if (host != "")
{
if (linea.IndexOf("XframeConnectorService.PrinterDriver." + host + ".port", StringComparison.OrdinalIgnoreCase) >= 0)
{
var v = linea.Split('=');
nombreImp = v[1].Replace("\\", "");
}
}
}
} else
Log("NO EXISTE ARCHIVO DE CONFIG");

var ret = "";

if (host != "" && nombreImp != "")
{
_pathImpresora = @"\\" + host + @"\" + nombreImp;
ret = "OK";
}
else
{
_pathImpresora = "";
ret = "ERROR";
}

if (ret == "OK")
lineas = new List<Linea>();

return ret;
}

private void EjecutarComando(string comando) {
ProcessStartInfo processInfo;
Process proc;
_fin = false;
processInfo = new ProcessStartInfo("cmd.exe", (Convert.ToString("/c ") + comando));
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
processInfo.Verb = "runas";
proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo = processInfo;
proc.OutputDataReceived += OnOutputDataReceived;
proc.Exited += OnProcessExited;
proc.Start();
proc.BeginOutputReadLine();
while (!_fin) {
Thread.Sleep(1);
}

proc.Close();
}


private void OnProcessExited(object sender, EventArgs e) {
_fin = true;
}

private void OnOutputDataReceived(object sender, DataReceivedEventArgs e) {
}

[ComVisible(true)]
public void Log(string texto)
{
var f = new StreamWriter(Environment.GetEnvironmentVariable("TEMP") + "\\outLog.txt", true);

f.WriteLine(texto);

f.Close();
}
}
}

Invocar metodos de un objeto COM desde una página web con javascript - con ejemplo de impresion (call simple ActiveX object installed on the client)

Para compilarlo:

Ir a prompt de visual studio 2013 (abrirlo como administrador)

Si no hay una strong key, generarla con:
      sn -k keyImpresora.snk

cls
call "%VS120COMNTOOLS%..\Tools\vsvars32.bat"
csc /t:library Impresora.cs /keyfile:keyImpresora.snk
regasm Impresora.dll /tlb:ImpresoraNet.dll /codebase


Impresora.cs

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.IO;
using System.Collections.Generic;

namespace X
{
public enum Estilo
{
Normal,
Bold,
Enlarged,
Condensed
}
public interface IImpresora
{
string Imprimir(string texto, string estilo);
void FormFeed();
void Log(string texto);
string Inicializar(string usuario);
void Agregar(string linea);
void Listar();
}

public class Linea
{
public string Texto {get; set;}
public string Estilo {get; set;}
}

[ClassInterface(ClassInterfaceType.AutoDual)]
public class Impresora : IImpresora
{
bool _fin = false;
string _pathImpresora = "";
List<Linea> lineas;

public void Agregar(string linea)
{
var l = new Linea();

l.Texto = linea;

lineas.Add(l);
}

public void Listar()
{
var estilo = "normal";
var textoOk = "";

File.Delete("c:\\temp\\outLog.txt");

foreach (var l in lineas)
{
var xx = "";

xx = l.Texto;

xx = xx.Replace((char)13 + "" + (char)10, "");

if (xx.Contains(Convert.ToChar(27) + "(s3B") || xx.Contains(Convert.ToChar(27) + "(s0B"))
{
//evito estas lineas
} else
{
// var xx = l.Texto.Replace( Convert.ToChar(27) + "(s3B", "");
// xx = xx.Replace( Convert.ToChar(27) + "(s0B", "");
xx = xx.Replace( Convert.ToChar(27) + "E" + "", (char)27 + "" + (char)69 + "");
}

Log(xx);
}

EjecutarComando("type c:\\temp\\outLog.txt > " + _pathImpresora);
/*
foreach (var l in lineas)
{
textoOk = "";

for (int i=0; i<l.Texto.Length; i++)
{
if ((int)l.Texto[i] == 12)
{
textoOk += "[FORM FEED]";
i++;
}

if ((int)l.Texto[i] == 27)
{
i++;

if ((int)l.Texto[i] == 69)
{
estilo = "bold";
i++;
} else if ((int)l.Texto[i] == 70)
{
estilo = "normal";
i++;
}
}

textoOk += l.Texto[i];
}

//Log(textoOk + " - " + estilo );
}
*/
}

public string Imprimir(string texto, string estilo)
{
if (estilo == "normal")
ImprimirLinea(texto, Estilo.Normal);

if (estilo == "bold")
ImprimirLinea(texto, Estilo.Bold);

if (estilo == "enlarged")
ImprimirLinea(texto, Estilo.Enlarged);

if (estilo == "condensed")
ImprimirLinea(texto, Estilo.Condensed);

return texto;
}

public void FormFeed()
{
//para que funcione el form feed hay que poner algun caracter antes y despues (en este caso, el signo de menos)
EjecutarComando("echo -" + (char)12 + "- > " + _pathImpresora);
}

public string Inicializar(string usuario)
{
var archivo = @"c:\X_imp\" + usuario + @"\framePrinter.properties";
var host = "";
var nombreImp = "";


if (File.Exists(archivo))
{
var f = new StreamReader(archivo);
while (!f.EndOfStream)
{
var linea = f.ReadLine();

if (linea.Contains("frameConnectorService.PrinterDriver.drivers"))
{
var v = linea.Split('=');

host = v[1];
host = host.Substring(0, host.IndexOf(","));

}

if (host != "")
{
if (linea.IndexOf("frameConnectorService.PrinterDriver." + host + ".port", StringComparison.OrdinalIgnoreCase) >= 0)
{
var v = linea.Split('=');
nombreImp = v[1].Replace("\\", "");
}
}
}
} else
Log("NO EXISTE ARCHIVO DE CONFIG");

var ret = "";

if (host != "" && nombreImp != "")
{
_pathImpresora = @"\\" + host + @"\" + nombreImp;
ret = "OK";
}
else
{
_pathImpresora = "";
ret = "ERROR";
}

if (ret == "OK")
lineas = new List<Linea>();

return ret;
}

private void ImprimirLinea(string texto, Estilo estilo)
{

//(char)27 + (char)15 ---------------- condensado on
//(char)18 --------------------------- condensado off
//(char)27 + (char)87 + (char)49 ----- enlarged on
//(char)27 + (char)87 + (char)48 ----- enlarged off
//(char)27 + (char)69 ---------------- bold on
//(char)27 + (char)70 ---------------- bold off


if (texto.Trim() == "")
{
texto = "(";
estilo = Estilo.Normal;
}
else
texto = " " + texto;

switch (estilo)
{
case Estilo.Normal:
EjecutarComando("echo" + texto + " > " + _pathImpresora);
break;
case Estilo.Bold:
EjecutarComando("echo " + (char)27 + (char)69 + texto + (char)27 + (char)70 + " > " + _pathImpresora);
break;
case Estilo.Enlarged:
EjecutarComando("echo " + (char)27 + (char)87 + (char)49 + texto + (char)27 + (char)87 + (char)48 + " > " + _pathImpresora);
break;
case Estilo.Condensed:
EjecutarComando("echo " + (char)27 + (char)15 + texto + (char)18 + " > " + _pathImpresora);
break;
}
}

private void EjecutarComando(string comando) {
ProcessStartInfo processInfo;
Process proc;
_fin = false;
processInfo = new ProcessStartInfo("cmd.exe", (Convert.ToString("/c ") + comando));
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
processInfo.Verb = "runas";
proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo = processInfo;
proc.OutputDataReceived += OnOutputDataReceived;
proc.Exited += OnProcessExited;
proc.Start();
proc.BeginOutputReadLine();
while (!_fin) {
Thread.Sleep(1);
}

proc.Close();
}
 
private void OnProcessExited(object sender, EventArgs e) {
_fin = true;
}

private void OnOutputDataReceived(object sender, DataReceivedEventArgs e) {
}

public void Log(string texto)
{
var f = new StreamWriter("c:\\temp\\outLog.txt", true);

f.WriteLine(texto);

f.Close();
}
}
}


Version anterior:

Impresora.cs

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.IO;

namespace X

{
public enum Estilo
{
Normal,
Bold,
Enlarged,
Condensed
}
public interface IImpresora
{
string Imprimir(string texto, string estilo);
void FormFeed();
void Log(string texto);
}

[ClassInterface(ClassInterfaceType.AutoDual)]

public class Impresora : IImpresora
{
bool _fin = false;

public string Imprimir(string texto, string estilo)
{
if (estilo == "normal")
ImprimirLinea(texto, Estilo.Normal);

if (estilo == "bold")

ImprimirLinea(texto, Estilo.Bold);

if (estilo == "enlarged")
ImprimirLinea(texto, Estilo.Enlarged);

if (estilo == "condensed")
ImprimirLinea(texto, Estilo.Condensed);

return texto;
}

public void FormFeed()
{
EjecutarComando("echo " + "ABC" + (char)12 + "ABC" + " > \\\\X00762\\EPSON1");
}

private void ImprimirLinea(string texto, Estilo estilo)
{

//(char)27 + (char)15 ---------------- condensado on
//(char)18 --------------------------- condensado off
//(char)27 + (char)87 + (char)49 ----- enlarged on
//(char)27 + (char)87 + (char)48 ----- enlarged off
//(char)27 + (char)69 ---------------- bold on
//(char)27 + (char)70 ---------------- bold off


if (texto.Trim() == "")
{
texto = "(";
estilo = Estilo.Normal;
}
else
texto = " " + texto;

switch (estilo)
{
case Estilo.Normal: 
EjecutarComando("echo" + texto + " > \\\\X00762\\EPSON1");
break;
case Estilo.Bold: 
EjecutarComando("echo " + (char)27 + (char)69 + texto + (char)27 + (char)70 + " > \\\\X00762\\EPSON1");
break;
case Estilo.Enlarged:
EjecutarComando("echo " + (char)27 + (char)87 + (char)49 + texto + (char)27 + (char)87 + (char)48 + " > \\\\X00762\\EPSON1");
break;
case Estilo.Condensed:
EjecutarComando("echo " + (char)27 + (char)15 + texto + (char)18 + " > \\\\X00762\\EPSON1");
break;
}
}

private void EjecutarComando(string comando) {
ProcessStartInfo processInfo;
Process proc;
_fin = false;
processInfo = new ProcessStartInfo("cmd.exe", (Convert.ToString("/c ") + comando));
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
processInfo.Verb = "runas";
proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo = processInfo;
proc.OutputDataReceived += OnOutputDataReceived;
proc.Exited += OnProcessExited;
proc.Start();
proc.BeginOutputReadLine();
while (!_fin) {
Thread.Sleep(1);
}

proc.Close();
}
  
private void OnProcessExited(object sender, EventArgs e) {
_fin = true;
}

private void OnOutputDataReceived(object sender, DataReceivedEventArgs e) {
}

public void Log(string texto)
{
var f = new StreamWriter("c:\\temp\\outLog.txt", true);

if (texto.IndexOf('\f') >= 0)
f.WriteLine("FORM FEEED!!!!!!");
else
f.WriteLine(texto);

f.Close();
}
}
}

Tester.htm

<html>
<head>
<script language=JavaScript>
var imp = new ActiveXObject('X.Impresora');
alert(imp.Imprimir("Texto PRUEBA"));
</script>
</head>
 <body>
  <h1>Tester.htm</h1>
 </body>
</html>



Fuente: http://forums.asp.net/post/2204437.aspx

Enviar directo a la impresora desde C# (raw printing)



Código Html

<body>
    <object
        name="Hello World"
        classid="clsid:E86A9038-368D-4e8f-B389-FDEF38935B2F"
        codebase="http://localhost/bin/Debug/Test.ActiveX.dll">
    </object>  

    <script type="text/javascript">    
        var hw = new ActiveXObject("Test.ActiveX.PruebaX");
        
alert( hw.imprimir() );
    </script>    
</body>


Código C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.Reflection;
using System.Diagnostics; 

namespace PruebaX
{
    [Guid("E86A9038-368D-4e8f-B389-FDEF38935B2F")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [ComVisible(true)]
    public interface IHelloWorld
    {
        [DispId(0)]
        string Prueba();
        [DispId(1)]
        string Imprimir();

    }

    [ComVisible(true)]
    [ProgId("Test.ActiveX.PruebaX")]
    [ClassInterface(ClassInterfaceType.None)]
    [ComDefaultInterface(typeof(IHelloWorld))]
    public class HelloWorld : IHelloWorld    
    {
        [ComRegisterFunction()]
        public static void RegisterClass(string key)
        {
            // Strip off HKEY_CLASSES_ROOT\ from the passed key as I don't need it
            StringBuilder sb = new StringBuilder(key);
            sb.Replace(@"HKEY_CLASSES_ROOT\ ", ""); // <-- extra space to preserve prettify only.. not in the real code

            // Open the CLSID\{guid} key for write access
            using (RegistryKey k = Registry.ClassesRoot.OpenSubKey(sb.ToString(), true))
            {
                // And create the 'Control' key - this allows it to show up in 
                // the ActiveX control container 
                using (RegistryKey ctrl = k.CreateSubKey("Control"))
                {
                    ctrl.Close();
                }

                // Next create the CodeBase entry - needed if not string named and GACced.
                using (RegistryKey inprocServer32 = k.OpenSubKey("InprocServer32", true))
                {
                    inprocServer32.SetValue("CodeBase", Assembly.GetExecutingAssembly().CodeBase);
                    inprocServer32.Close();
                }

                // Finally close the main key
                k.Close();
            }
        }

        public string Prueba()
        {
            return "Prueba";
        }

        public string Imprimir()
        {
            EjecutarComando("dir c:\\temp > " + "\"" + "\\\\X00895\\Brother HL-2270DW series" + "\"");

            return "Impresion enviada";
        }


        private void EjecutarComando(string comando)
        {
            ProcessStartInfo processInfo;
            Process proc;

            processInfo = new ProcessStartInfo("cmd.exe", (Convert.ToString("/c ") + comando));
            processInfo.CreateNoWindow = true;
            processInfo.UseShellExecute = false;
            processInfo.RedirectStandardError = true;
            processInfo.RedirectStandardOutput = true;
            processInfo.Verb = "runas";
            proc = new Process();
            proc.EnableRaisingEvents = true;
            proc.StartInfo = processInfo;
            proc.Start();
            proc.BeginOutputReadLine();
            proc.Close();
        }
    }
}

Delay sign a DLL - Firmar una dll con SN y MsBuild desde linea de comando

call "%VS120COMNTOOLS%..\Tools\vsvars32.bat"

IF NOT EXIST "C:\temp\Generados\outGAC\Signed" mkdir "C:\temp\Generados\outGAC\Signed"

IF EXIST "C:\temp\Generados\outGAC\Signed\LibX.dll" del "C:\temp\Generados\outGAC\Signed\LibX.dll"

msbuild.exe "C:\crusso\X\fuentes\desarrollo\_DLL\LibX\LibX.vbproj" /p:TargetFrameworkVersion=v4.5.1;Configuration=Release /tv:4.0 /t:Rebuild /p:OutDir="C:\temp\Generados\outGAC" /p:PreBuildEvent= /p:PostBuildEvent= /p:SignAssembly=true /p:AssemblyOriginatorKeyFile="c:\crusso\X\fuentes\desarrollo\_KEYSTORE\Desarrollo\keyLibX.snk" /p:DelaySign=true

sn -R "C:\temp\Generados\outGAC\LibX.dll" "c:\crusso\X\fuentes\desarrollo\_KEYSTORE\Desarrollo\keyLibX.snk"

gacutil.exe /i "C:\temp\Generados\outGAC\LibX.dll" /f

Crear un drive USB bootable sin utilizar ningùn software


Step 1: Using DISKPART command


  1. Insert your USB flash drive to your running computer. As the first step, we need to run Command Prompt as administrator. To do this, we need to find cmd by typing 'cmd' in the search box on Windows Start Menu. After search result for 'cmd' appears, right click on it and select "Run as administrator".
  2. Type 'diskpart' on Command Prompt (without quotes) and hit Enter. Wait for a while until the DISKPART program run.
  3. Type 'list disk' to view active disks on your computer and hit Enter. There would be seen that the active disks shown as Disk 0 for hard drive and Disk 1 for your USB flashdrive with its total capacity.
  4. Type 'select disk 1' to determine that disk 1 would be processed in the next step then hit Enter.
  5. Type 'clean' and hit Enter to remove all of data in the drive.
  6. Type 'create partition primary' and hit Enter. Creating a primary partition and further recognized by Windows as 'partition 1'.
  7. Type 'select partition 1' an hit Enter. Choosing the 'partition 1' for setting up it as an active partition.
  8. Type 'active' and hit Enter. Activating current partition.
  9. Type 'format fs=ntfs quick' and hit Enter. Formatting current partition as NTFS file system quickly.
  10. Type 'exit' and hit Enter. Leaving DISKPART program but don't close the Command Prompt instead. We would still need it for next proces

Step 2: create the boot sector

Step 2: Creating Boot Sector

Let us assume that the flash / USB drive is the D: drive and the DVD installer located on drive F :. The first step, we will navigate Command Prompt to set installation DVD as its active directory.
  1. By default, Command Prompt's active directory for Administrator permission is on C:\Windows\System32>. We will navigate Command Prompt to set on DVD (F:) as its active directory. Just type 'f:' then hit Enter, and the active directory changed to F:.
  2. Type 'cd boot' and hit Enter. Active directory changed to F:\boot>.
  3. Type 'bootsect /nt60 d:' and hit Enter. Creating boot sector on D: drive (USB flash drive).
  4. Type 'exit' and hit Enter to close the Command Prompt. Until this step we have made a bootable USB drive sucessfully, and the flash drive is ready to be used as a boot media.

Step 3: Copying Installation Files

xcopy f:\*.* d:\ /E /H /F


Fuente: http://www.instructables.com/id/How-to-Create-a-Bootable-USB-Drive-Without-Using-A/?ALLSTEPS

Desinstalar assembly del GAC de .NET


Ejemplo:

Desinstalar la LibX de la carpeta GAC de .NET:



gacutil /u "LibX,Version=3.0.0.0, Culture=neutral, PublicKeyToken=2ebfdc71997c1f40"

la version a especificar en el gacutil es

        v4.0_3.0.0.0__2ebfdc71997c1f40

y el token:

        v4.0_3.0.0.0__2ebfdc71997c1f40