|
9111
|
Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets)
|
en: 13 Mayo 2013, 07:40 am
|
Una class para combinar ejecutable de .NET con dependencias (dll's) en tiempo de ejecución... Se necesita la aplicación IlMerge#Region " IlMerge " ' [ IlMerge Functions ] ' ' // By Elektro H@cker ' ' Instructions: ' 1. Add the "IlMerge.exe" to the project ' 2. Add the "IlMerge" Class to the project ' ' Examples: ' IlMerge.Merge({"C:\Application.exe", "C:\Dependency.dll"}, "C:\Merged.exe") ' MsgBox(IlMerge.Merge({"C:\Application.exe", "C:\Dependency.dll"}, "C:\Merged.exe")) #Region " IlMerge class " Public Class IlMerge ''' <summary> ''' Set the location of IlMerge executable [Default: ".\IlMerge.exe"]. ''' </summary> Public Shared IlMerge_Location As String = ".\IlMerge.exe" ''' <summary> ''' Set the location of IlMerge log file [Default: ".\IlMerge.log"]. ''' </summary> Public Shared IlMerge_Log_Location As String = IlMerge_Location.Substring(0, IlMerge_Location.Length - 4) & ".log" ''' <summary> ''' Merge ''' </summary> Public Shared Function Merge(ByVal InputFiles As String(), ByVal OutputFile As String) As Boolean Dim FilesString As String = Nothing For Each File In InputFiles : FilesString += """" & File & """" & " " : Next Try : IO. File. Delete(IlMerge_Log_Location ) : Catch : End Try ' Deletes old log if exist Try Dim ResHacker As New Process() Dim ResHacker_Info As New ProcessStartInfo() ResHacker_Info.FileName = IlMerge_Location ResHacker_Info.Arguments = "/ndebug /log:" & """" & IlMerge_Log_Location & """" & " /out:" & """" & OutputFile & """" & " " & FilesString ResHacker_Info.UseShellExecute = False ResHacker.StartInfo = ResHacker_Info ResHacker.Start() ResHacker.WaitForExit() Try : IO. File. Delete(OutputFile. Substring(0, OutputFile. Length - 4) & ".pdb") : Catch : End Try ' Deletes Debug Generated File Return Check_Last_Error() Catch ex As Exception MsgBox(ex.Message) Return False End Try End Function ''' <summary> ''' Return the last operation error if any [False = ERROR, True = Ok]. ''' </summary> Private Shared Function Check_Last_Error() Try Dim Line As String = Nothing Dim Text As IO. StreamReader = IO. File. OpenText(IlMerge_Log_Location ) Do Until Text.EndOfStream Line = Text.ReadLine() If Line.ToString.StartsWith("An exception occurred") Then Process.Start(IlMerge_Log_Location) Return False End If Loop Text.Close() Text.Dispose() Return True Catch ex As Exception MsgBox(ex.Message) Return False End Try End Function End Class #End Region #End Region
|
|
|
9112
|
Programación / .NET (C#, VB.NET, ASP) / Re: Instalacion/Recuperacion
|
en: 13 Mayo 2013, 07:27 am
|
Todo eso pertenece al ÚNICO instalador del VS2010, los instaladores de los componentes de C# y SQL son instaladores secundarios, si no los has eliminado con una limpieza de CCLenaer los podrás encontrar aquí: C:\ProgramData\Package CachePero como son secundarios significa que la mayoría no te dejará instalarlos por si solos si no usas el instalador principal (el de VS2010). Lo que te aconsejo es que copies el contenido de la carpeta entera "C:\ProgramData\Package Cache" a una nueva carpeta llamada "packages", junto al instalador de VS, y así la próxima vez que quieras instalar VS no tendrá que descargar ningún componente, porque le estás indicando que ya dispones de los paquetes descargados. ...Por si no ha quedado claro, esta debe ser la estructura: C:\Carpeta\ C:\Carpeta\VS_Setup.exe C:\Carpeta\Packages\ EDITO: No lo he testeado con el instalador del VS2010 (lo hago así en vs2012). Saludos.
|
|
|
9113
|
Programación / .NET (C#, VB.NET, ASP) / MSBuild no me quiere compilar una class
|
en: 12 Mayo 2013, 23:25 pm
|
Tengo un proyecto que se compila perféctamente en VS2012, sin NINGÚN error ni aviso. Cuando intento compilar el mismo proyecto usando MSBuild 3.0 o 3.5 me sale un montón de errores en una class en concreto: Microsoft (R) Build Engine, versión 3.5.30729.5420 [Microsoft .NET Framework, versión 2.0.50727.5420] Copyright (C) Microsoft Corporation 2007. Reservados todos los derechos. Build started 12/05/2013 22:50:43. Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" on node 0 (default targets). Building solution configuration "Debug|Any CPU". Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" (1) is building "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Extractor.vbproj" (2) on node 0 (default targets). Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5". CoreResGen: No hay ningún recurso obsoleto con respecto a sus archivos de código fuente. Se omitirá la generación de recursos. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(24): error BC30124: La propiedad sin un especificador 'ReadOnly' o 'WriteOnly' debe proporcionar una instrucci¾n 'Get' y una instrucci¾n 'Set'. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30634: La instrucci¾n no puede aparecer dentro del cuerpo de una propiedad. Se supone el final de la propiedad. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30025: Falta 'End Property' en Property. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(57): error BC32035: El especificador de atributo no es una instrucci¾n completa. Utilice una continuaci¾n de lÝnea para aplicar el atributo a la instrucci¾n siguiente. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(61): error BC30456: 'Key' no es un miembro de 'Virtuosa_Game_Packer.Shortcut.HotKeyEventArgs'. Done Building Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Extractor.vbproj" (default targets) -- FAILED. Done Building Project "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" (default targets) -- FAILED. Build FAILED. "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Virtuosa Game Packer.sln" (default target) (1) -> "C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\Extractor.vbproj" (default target) (2) -> (CoreCompile target) -> C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(24): error BC30124: La propiedad sin un especificador 'ReadOnly' o 'WriteOnly' debe proporcionar una instrucci¾n 'Get' y una instrucci¾n 'Set'. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30634: La instrucci¾n no puede aparecer dentro del cuerpo de una propiedad. Se supone el final de la propiedad. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(25): error BC30025: Falta 'End Property' en Property. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(57): error BC32035: El especificador de atributo no es una instrucci¾n completa. Utilice una continuaci¾n de lÝnea para aplicar el atributo a la instrucci¾n siguiente. C:\Projects\game\WindowsApplication10 - copia\Extractor_backup\GlobalHotkeys.vb(61): error BC30456: 'Key' no es un miembro de 'Virtuosa_Game_Packer.Shortcut.HotKeyEventArgs'. 0 Warning(s) 5 Error(s) Time Elapsed 00:00:00.25
Es imprescindible para mi poder compilar dicho proyecto usando MSBuild. ¿Posible solución 1?: Un parámetro o algo parecido para usar en el msbuild para omitir errores? ¿o talvez crear una taréa de MSBuild? (Por más que he buscado información sobre las msbuild tasks no sé donde coño se debe hacer/colocar/crear ni como usar el archivo xml, y todo lo que encuentro es código para C#, tampoco sé si una task de msbuild me sirve para esto). ¿Posible solución 2?: Que alguna persona amable me ayude a corregir las líneas de la Class donde el MSBuild me marca ridículos errores de compilación. Esta es la class: #Region " GlobalHotkeys Class " Class Shortcut Inherits NativeWindow Implements IDisposable Protected Declare Function UnregisterHotKey Lib "user32.dll" (ByVal handle As IntPtr, ByVal id As Integer) As Boolean Protected Declare Function RegisterHotKey Lib "user32.dll" (ByVal handle As IntPtr, ByVal id As Integer, ByVal modifier As Integer, ByVal vk As Integer) As Boolean Event Press(ByVal sender As Object, ByVal e As HotKeyEventArgs) Protected EventArgs As HotKeyEventArgs, ID As Integer Enum Modifier As Integer None = 0 Alt = 1 Ctrl = 2 Shift = 4 End Enum Class HotKeyEventArgs Inherits EventArgs Property Modifier As Shortcut.Modifier Property Key As Keys End Class Class RegisteredException Inherits Exception Protected Const s As String = "Shortcut combination is in use." Sub New() MyBase.New(s) End Sub End Class Private disposed As Boolean Protected Overridable Sub Dispose(ByVal disposing As Boolean) If Not disposed Then UnregisterHotKey(Handle, ID) disposed = True End Sub Protected Overrides Sub Finalize() Dispose(False) MyBase.Finalize() End Sub Sub Dispose() Implements IDisposable.Dispose Dispose(True) GC.SuppressFinalize(Me) End Sub <DebuggerStepperBoundary()> Sub New(ByVal modifier As Modifier, ByVal key As Keys) CreateHandle(New CreateParams) ID = GetHashCode() EventArgs = New HotKeyEventArgs With {.Key = key, .Modifier = modifier} If Not RegisterHotKey(Handle, ID, modifier, key) Then Throw New RegisteredException End Sub Shared Function Create(ByVal modifier As Modifier, ByVal key As Keys) As Shortcut Return New Shortcut(modifier, key) End Function Protected Sub New() End Sub Protected Overrides Sub WndProc(ByRef m As Message) Select Case m.Msg Case 786 RaiseEvent Press(Me, EventArgs) Case Else MyBase.WndProc(m) End Select End Sub End Class #End Region
Gracias por leer.
|
|
|
9114
|
Media / Multimedia / Re: (consulta) Megui audio desincronizado x264+aac
|
en: 12 Mayo 2013, 22:55 pm
|
Coincido con lo de no usar packs de codecs, yo hace mas de 4 años que no uso uno, instalo lo mínimo necesario para la reproducción que es es FFDShow y Haali media splitter, el AC3 filter a veces lo instalo y a veces no, para mi es opcional ya que FFDShow incluye decodificador para AC3/DTS. Si instalas AC3 filter no olvides deshabilitar el decodificador de FFDShow. Sugerencia: Si instalas ffdshow lo que debes instalar es el AC3File como dije, no el Filter, así no necesitas desactivar nada. http://www.ac3filter.net/Un saludo!
|
|
|
9115
|
Media / Multimedia / Re: (consulta) Megui audio desincronizado x264+aac
|
en: 11 Mayo 2013, 16:14 pm
|
en que post te aclara eso? No lo recuerdo, creo que fue en un post de mi antiguo usuario, pregunté algo sobre el klite, pero no sé ni que pregunté, y luego la conversación fue tomando forma hacia que codecs eran necesarios y cuales no. Saludos.
|
|
|
9116
|
Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets)
|
en: 11 Mayo 2013, 11:45 am
|
Devuelve la dirección IP de un Host #Region " HostName To IP " ' [ HostName To IP Function ] ' ' // By Elektro H@cker ' ' Examples : ' ' MsgBox(HostName_To_IP("www.google.com")) ' Result: 173.194.41.6 Public Function HostName_To_IP(ByVal HotsName As String) As String Return System.Net.Dns.GetHostEntry(HotsName).AddressList(1).ToString() End Function #End Region
Devuelve el Hostname de una IP #Region " IP To HostName " ' [ IP To HostName Function ] ' ' // By Elektro H@cker ' ' Examples : ' ' MsgBox(IP_To_HostName("173.194.41.6")) ' Result: mad01s14-in-f6.1e100.net Public Function IP_To_HostName(ByVal IP As String) As String Return system.net.Dns.GetHostEntry(IP).HostName.ToString End Function #End Region
Valida si un nombre de archivo o ruta contiene caracteres no permitidos por Windows (Este snippet lo posteé hace tiempo pero tenía varios fallos, los he corregido.) #Region " Validate Windows FileName " ' [ Validate Windows FileName Function ] ' ' Examples : ' MsgBox(Validate_Windows_FileName("C:\Test.txt")) ' Result: True ' MsgBox(Validate_Windows_FileName("C:\Te|st.txt")) ' Result: False Private Function Validate_Windows_FileName(ByRef FileName As String) Dim Directory As String = Nothing Dim File As String = Nothing Try Directory = FileName.Substring(0, FileName.LastIndexOf("\")) & "\" File = FileName. Split("\"). Last Catch If Directory Is Nothing Then File = FileName End Try If Directory Is Nothing AndAlso File Is Nothing Then Return False If Not Directory Is Nothing Then For Each InvalidCharacter As Char In IO.Path.GetInvalidPathChars If Directory.Contains(InvalidCharacter) Then ' MsgBox(InvalidCharacter) Return False End If Next End If If Not File Is Nothing Then For Each InvalidCharacter As Char In IO.Path.GetInvalidFileNameChars If File. Contains(InvalidCharacter ) Then ' MsgBox(InvalidCharacter) Return False End If Next End If Return True ' FileName is valid End Function #End Region
|
|
|
9117
|
Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets)
|
en: 11 Mayo 2013, 08:28 am
|
Hacer Ping a una máquina: #Region " Ping " ' [ Ping Function ] ' ' // By Elektro H@cker ' ' Examples : ' MsgBox(Ping("www.google.com")) ' MsgBox(Ping("www.google.com", 500)) ' MsgBox(Ping("www.google.com", 500, New Byte(128) {}, False)) ' MsgBox(Ping("www.google.com", 500, System.Text.Encoding.ASCII.GetBytes("Hello"), True)) ' For X As Int32 = 1 To 10 : If Not Ping("www.google.com", 1000) Then : MsgBox("Ping try " & X & " failed") : End If : Next : MsgBox("Ping successfully") Public Function Ping(ByVal Address As String, _ Optional ByVal TimeOut As Int64 = 200, _ Optional ByVal BufferData As Byte() = Nothing, _ Optional ByVal FragmentData As Boolean = False, _ Optional ByVal TimeToLive As Int64 = 128) As Boolean Dim PingSender As New System.Net.NetworkInformation.Ping() Dim PingOptions As New System.Net.NetworkInformation.PingOptions() If FragmentData Then PingOptions.DontFragment = False Else PingOptions.DontFragment = True If BufferData Is Nothing Then BufferData = New Byte(31) {} ' Sets a BufferSize of 32 Bytes PingOptions.Ttl = TimeToLive Dim Reply As System.Net.NetworkInformation.PingReply = PingSender.Send(Address, TimeOut, BufferData, PingOptions) If Reply.Status = System.Net.NetworkInformation.IPStatus.Success Then ' MsgBox("Address: " & Reply.Address.ToString) ' MsgBox("RoundTrip time: " & Reply.RoundtripTime) ' MsgBox("Time to live: " & Reply.Options.Ttl) ' MsgBox("Buffer size: " & Reply.Buffer.Length) Return True Else Return False End If End Function #End Region
|
|
|
9118
|
Programación / .NET (C#, VB.NET, ASP) / Re: Ejecutar .vbs con Vb.net
|
en: 11 Mayo 2013, 08:10 am
|
@ TMarmol1. No es necesario que crees primero un bat y luego un vbs para ejecutar el bat oculto, pues no estás usando Batch, estás en un lenguaje de verdad, aquí puedes usar la Class Process para definir las opciones del proceso y ejecutar el bat oculto. (windowstyle.hidden) http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspxhttp://msdn.microsoft.com/en-us/library/system.diagnostics.processwindowstyle.aspx2. Debes tener en cuenta las comillas dobles y los nombres con espacio en los argumentos, como en Batch. ...Quizás eso es lo que te falla, si no muestras el código no lo sé, así que siguiendo el ejemplo de DanyFirex... sería así: Process.Start("wscript.exe", """" & "C:\ruta con espacios\Script.vbs" & """")
O así, como prefieras: Process.Start("wscript.exe", ControlChars.Quote & "C:\ruta con espacios\Script.vbs" & ControlChars.Quote)
De todas formas yo sólamente usaría la CMD si no hubiera otra alternativa, no sé exáctamente cuales son las intenciones de tu código Bat pero ...¿Has pensado en hacer ping usando los metodos del .NET?: Esto es lo más sencillo: If My.Computer.Network.Ping("www.google.com") Then MsgBox("success") Else MsgBox("no reply") End If
Si quieres algo más customizable aquí tienes una función que acabo de codear: #Region " Ping " ' [ Ping Function ] ' ' // By Elektro H@cker ' ' Examples : ' MsgBox(Ping("www.google.com")) ' MsgBox(Ping("www.google.com", 500)) ' MsgBox(Ping("www.google.com", 500, New Byte(128) {}, False)) ' MsgBox(Ping("www.google.com", 500, System.Text.Encoding.ASCII.GetBytes("Hello"), True)) ' For X As Int32 = 1 To 10 : If Not Ping("www.google.com", 1000) Then : MsgBox("Ping try " & X & " failed") : End If : Next : MsgBox("Ping successfully") Public Function Ping(ByVal Address As String, _ Optional ByVal TimeOut As Int64 = 200, _ Optional ByVal BufferData As Byte() = Nothing, _ Optional ByVal FragmentData As Boolean = False, _ Optional ByVal TimeToLive As Int64 = 128) As Boolean Dim PingSender As New System.Net.NetworkInformation.Ping() Dim PingOptions As New System.Net.NetworkInformation.PingOptions() If FragmentData Then PingOptions.DontFragment = False Else PingOptions.DontFragment = True If BufferData Is Nothing Then BufferData = New Byte(31) {} ' Sets a BufferSize of 32 Bytes PingOptions.Ttl = TimeToLive Dim Reply As System.Net.NetworkInformation.PingReply = PingSender.Send(Address, TimeOut, BufferData, PingOptions) If Reply.Status = System.Net.NetworkInformation.IPStatus.Success Then ' MsgBox("Address: " & Reply.Address.ToString) ' MsgBox("RoundTrip time: " & Reply.RoundtripTime) ' MsgBox("Time to live: " & Reply.Options.Ttl) ' MsgBox("Buffer size: " & Reply.Buffer.Length) Return True Else Return False End If End Function #End Region
Saludos
|
|
|
|
|
|
|