Visual CSharp .NET - Registrar DLL

 
Vista:
sin imagen de perfil

Registrar DLL

Publicado por Francisco (1 intervención) el 26/08/2022 00:55:30
Espero me puedan ayudar ya que estoy batallando con registrar una DLL que esta hecha en C# (.NETFRAMEWORk 4.5) pero al ejecutar el archvo .BAT y registrar la DLL me sale el siguiente error: RegAsm : error RA0000 : Failed to load 'C:\Users\Hecto\Desktop\Debug\PDFGenerador.dll' because it is not a valid .NET assembly

anexo la imagen con el error que me sale al querer registrar la DLL asi como lo que contiene el archivo .bat para registrar la DLL


regasm


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@echo off
pushd "%~dp0"
color 30
echo ==================================
echo = =
echo = Inicio de Instalacion 	 =
echo = =
echo ==================================
echo.
echo.
regasm /tlb /codebase PDFGenerador.dll
echo.
echo.
pause
gacutil /i PDFGenerador.dll
echo.
echo.
pause
regasm /tlb /codebase itextsharp.dll
echo.
echo.
pause
gacutil /i itextsharp.dll
echo.
echo.
pause
iisreset
echo.
echo.
echo =================================================================
echo = =
echo = Proceso finalizado con exito presione una tecla para terminar =
echo = =
echo =================================================================
popd
pause
exit[/quote]


tambien anexo mi codigo C# por si va tambien el error por ahi


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.Net;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
 
namespace PDFGenerador
{
    public class PDFGenerador
    {
        public byte[] Generar(string rutaReporte)
        {
            string[] remplaceOld = new string[]{};
            string[] remplace = new string[] { };
            string URL_Servidor = rutaReporte.Substring(0, rutaReporte.LastIndexOf("?"));
            string reporte = URL_Servidor.Substring(URL_Servidor.LastIndexOf("/")+1);
            URL_Servidor = URL_Servidor.Substring(0, URL_Servidor.LastIndexOf("/"));
            if (reporte == "Edocta_Detalle_2013.asp")
            {
                remplaceOld = new string[]{    "class=\"Tabla1\"",
                                       "class=\"renglon\"",
                                       "class=\"Tabla2\"",
                                       "class=\"Tabla3\"",
                                       "class=\"RenglonT\""};
 
                remplace = new string[] { "style=\"FONT-FAMILY: 'Verdana'; font-size: 7pt; COLOR: white;\"",
                                "style=\"FONT-FAMILY: 'Verdana'; font-size: 7pt;\"",
                                "style=\"FONT-FAMILY: 'Verdana'; FONT-SIZE: 6.5pt;\"",
                                "style=\"FONT-FAMILY: 'Verdana'; FONT-SIZE: 6.5pt;border-bottom: 1px solid;\"",
                                "style=\"FONT-FAMILY: 'Verdana'; font-size: 8pt; COLOR: white; \""};
            }
            else if (reporte == "Rep_EdoctaCedul_2013.asp")
            {
                remplaceOld = new string[] {    "class=\"Tabla1\"",
                                       "class=\"renglon\"",
                                       "class=\"renglon_1\"",
                                       "class=\"Tabla2\"",
                                       "class=\"Tabla3\"",
                                       "class=\"RenglonT\"",
                                       "class=\"Space\"",
                                        "imagenes/Img_Seguros.gif"};
 
                remplace = new string[] { "style=\"font-size:7pt;\"",
                                    "style=\"font-size:7pt; line-height:8px;\"",
                                    "style=\"font-size:7pt; line-height:14px;\"",
                                    "style=\"font-size:7pt;\"",
                                    "style=\"font-size:7pt; \"",
                                    "style=\"font-size:7pt; \"",
                                    "style=\"FONT-FAMILY: 'Verdana'; font-size:	7pt; COLOR:	white;\"",
                                URL_Servidor + @"/Imagenes/Img_Seguros.jpeg"};
            }
 
            return ObtienePDF(rutaReporte, remplaceOld, remplace);
        }
 
        private byte[] ObtienePDF(string rutaReporte, string[] remplaceOld, string[] remplace)
        {
            string html = ReadURL(rutaReporte);
 
            if (html.IndexOf(@"imagenes/btnNoExiste.gif") != -1)
                return new byte[] { };
 
            Document document = new Document(PageSize.LETTER, 50, 50, 30, 65);
 
            try
            {
                MemoryStream stream = new MemoryStream();
                PdfWriter writer = PdfWriter.GetInstance(document, stream);
                document.Open();
 
                for (int i = 0; i < remplaceOld.Length; i++)
                    html = html.Replace(remplaceOld[i], remplace[i]);
 
                foreach (IElement E in HTMLWorker.ParseToList(new StringReader(html), new StyleSheet()))
                {
                    if (E is PdfPTable)
                    {
                        PdfPTable table = (PdfPTable)E;
 
                        table.WidthPercentage = 110;
                        table.LockedWidth = false;
                        Console.WriteLine(table.Size + "");
                    }
                    document.Add(E);
                }
 
                document.Close();
                return stream.ToArray();
            }
            catch (Exception )
            {
               try
                {
                    document.Close();
                    return new byte[] { };
                }
                catch (Exception)
                {
                    return new byte[] { };
                }
            }
        }
 
        private string ReadURL(String URL)
        {
            //Stream objStream;
            string strResponse = "";
 
            HttpWebRequest wrquest = (HttpWebRequest)WebRequest.Create(URL);
            wrquest.Timeout = 10000;                //Tiempo de espera 10 segundos.
            wrquest.ReadWriteTimeout = -1;          //TIempo de lectura infinito.
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            HttpWebResponse getresponse = null;
            getresponse = (HttpWebResponse)wrquest.GetResponse();
            System.Text.Encoding encode = System.Text.Encoding.GetEncoding(getresponse.CharacterSet);
            using (StreamReader objSR = new StreamReader(getresponse.GetResponseStream(), encode, false))
            {
                strResponse = objSR.ReadToEnd();
                objSR.Close();
            }
            return strResponse;
 
        }
    }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder