Vielleicht liege ich hier falsch, aber nur nochmal zur Klärung damit hier nicht aneinander vorbeigeredet wird. Coder9292 will doch einfach nur ein Compiler erstellen, bzw. den Code einfach an den .Net Compiler weiterreiche. Hier geht es nicht um ein Plugin-System, auch wenn das der Titel dess Themas das vielleicht vermuten lässt.
Quellcode per Anwendung compilieren
- VB.NET
- .NET (FX) 4.5–4.8
Sie verwenden einen veralteten Browser (%browser%) mit Sicherheitsschwachstellen und können nicht alle Funktionen dieser Webseite nutzen.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Es gibt 54 Antworten in diesem Thema. Der letzte Beitrag () ist von Coder9292.
-
-
@Bluespide genau ich möchte eigentlich nur ein Compiler der meinen Quellcode verarbeitet
Hab den Titel mal angepasst.~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Coder9292“ ()
-
-
-
Ich muss den Thread leider wieder aufwecken
Ich habe nun einen Compiler und dieser scheint auch das zu tun was ich brauche aber ich bekomme beim kompilieren des Codes immer Fehler und somit ist die Output EXE schrott
Hier der Compiler Code:
Spoiler anzeigen Quellcode
- Imports System.IO
- Imports System.Text
- Imports Microsoft.CSharp
- Imports System.Resources
- Imports System.Diagnostics
- Imports System.Windows.Forms
- Imports System.CodeDom.Compiler
- Imports System.Collections.Generic
- #Region "Enums"
- ''' <summary>
- ''' The programming languages which codedom can compile.
- ''' </summary>
- Public Enum Language
- VisualBasic
- CSharp
- End Enum
- ''' <summary>
- ''' How you're assembly will compile. Default setting is Console.
- ''' </summary>
- Public Enum Target
- ''' <summary>
- ''' An Windows forms application.
- ''' </summary>
- WinForms
- ''' <summary>
- ''' A Windows console application.
- ''' </summary>
- Console
- ''' <summary>
- ''' A Windows Dynamic Link Library(DLL) application.
- ''' </summary>
- Library
- End Enum
- ''' <summary>
- ''' The .NET version you're compiled file will use.
- ''' </summary>
- Public Enum DotNetVersion
- ''' <summary>
- ''' .NET Version 2.0
- ''' </summary>
- v2
- ''' <summary>
- ''' .NET Version 3.0
- ''' </summary>
- v3
- ''' <summary>
- ''' .NET Version 3.5
- ''' </summary>
- v35
- ''' <summary>
- ''' .NET Version 4.0
- ''' </summary>
- v4
- End Enum
- ''' <summary>
- ''' The Filealign option lets you specify the size of sections in your output file. Default value is 1024.
- ''' </summary>
- Public Enum File_Align
- _200
- _512
- _1024
- _2048
- _4096
- _8192
- End Enum
- ''' <summary>
- ''' Specifies which version of the common language runtime (CLR) can run the assembly. Default value is anycpu.
- ''' </summary>
- Public Enum Platform
- ''' <summary>
- ''' x86 compiles your assembly to be run by the 32-bit, x86-compatible common language runtime.
- ''' </summary>
- x86
- ''' <summary>
- ''' Itanium compiles your assembly to be run by the 64-bit common language runtime on a computer with an Itanium processor.
- ''' </summary>
- Itanium
- ''' <summary>
- ''' x64 compiles your assembly to be run by the 64-bit common language runtime on a computer that supports the AMD64 or EM64T instruction set.
- ''' </summary>
- x64
- ''' <summary>
- ''' anycpu compiles your assembly to run on any platform.
- ''' </summary>
- AnyCPU
- End Enum
- ''' <summary>
- ''' The WarningLevel option specifies the warning level for the compiler to display.
- ''' </summary>
- Public Enum WarningLevel
- ''' <summary>
- ''' Turns off emission of all warning messages.
- ''' </summary>
- None
- ''' <summary>
- ''' Displays severe warning messages.
- ''' </summary>
- Low
- ''' <summary>
- ''' Displays level 1 warnings plus certain, less-severe warnings, such as warnings about hiding class members.
- ''' </summary>
- Medium
- ''' <summary>
- ''' Displays level 2 warnings plus certain, less-severe warnings, such as warnings about expressions that always evaluate to true or false.
- ''' </summary>
- High
- ''' <summary>
- ''' Displays all level 3 warnings plus informational warnings.
- ''' </summary>
- All
- End Enum
- #End Region
- Public Class EthernalCompiler
- #Region "Properties"
- Private _language As Language = Language.VisualBasic
- ''' <summary>
- ''' The programming language you wish to compile. Default language is Visual Basic.
- ''' </summary>
- Public Property Language() As Language
- Get
- Return _language
- End Get
- Set(ByVal value As Language)
- _language = value
- End Set
- End Property
- Private _netversion As DotNetVersion = DotNetVersion.v4
- ''' <summary>
- ''' The .NET version you're compiled file will use. Default version is 4.0.
- ''' </summary>
- Public Property DotNetVersion() As DotNetVersion
- Get
- Return _netversion
- End Get
- Set(ByVal value As DotNetVersion)
- _netversion = value
- End Set
- End Property
- Private _filealign As File_Align = File_Align._1024
- ''' <summary>
- ''' The Filealign option lets you specify the size of sections in your output file. Default value is 1024.
- ''' </summary>
- Public Property File_Align() As File_Align
- Get
- Return _filealign
- End Get
- Set(ByVal value As File_Align)
- _filealign = value
- End Set
- End Property
- Private _target As Target = Target.Console
- ''' <summary>
- ''' How you're assembly will compile. Default setting is Console.
- ''' </summary>
- Public Property Target() As Target
- Get
- Return _target
- End Get
- Set(ByVal value As Target)
- _target = value
- End Set
- End Property
- Private _platform As Platform = Platform.AnyCPU
- ''' <summary>
- ''' Specifies which version of the common language runtime (CLR) can run the assembly. Default value is AnyCPU.
- ''' </summary>
- Public Property Platform() As Platform
- Get
- Return _platform
- End Get
- Set(ByVal value As Platform)
- _platform = value
- End Set
- End Property
- Private _warnlvl As WarningLevel = WarningLevel.All
- ''' <summary>
- ''' The WarningLevel option specifies the warning level for the compiler to display. Default value is All.
- ''' </summary>
- Public Property WarningLevel() As WarningLevel
- Get
- Return _warnlvl
- End Get
- Set(ByVal value As WarningLevel)
- _warnlvl = value
- End Set
- End Property
- Private _icon As String = String.Empty
- ''' <summary>
- ''' The Icon to be used with you're file. Must be a path to an .ico file.
- ''' </summary>
- Public Property Icon() As String
- Get
- Return _icon
- End Get
- Set(ByVal value As String)
- _icon = value
- End Set
- End Property
- Private _executeaftercompiled As Boolean = False
- ''' <summary>
- ''' If true, it will execute the assembly after it has been compiled. Default value is false.
- ''' </summary>
- Public Property ExecuteAfterCompiled() As Boolean
- Get
- Return _executeaftercompiled
- End Get
- Set(ByVal value As Boolean)
- _executeaftercompiled = value
- End Set
- End Property
- Private _silentmode As Boolean = False
- ''' <summary>
- ''' If Silent Mode is true, then there will be no error and succes messages displayed. Default value is false.
- ''' </summary>
- Public Property SilentMode() As Boolean
- Get
- Return _silentmode
- End Get
- Set(ByVal value As Boolean)
- _silentmode = value
- End Set
- End Property
- Private _source As String = String.Empty
- ''' <summary>
- ''' The code you want to compile to an executable. Must be specified.
- ''' </summary>
- Public Property Source() As String
- Get
- Return _source
- End Get
- Set(ByVal value As String)
- _source = value
- End Set
- End Property
- Private _references As String() = Nothing
- ''' <summary>
- ''' The assemblies you want to reference. For example if you are using forms, you should reference System.Windows.Forms.dll. As default System.dll is already added.
- ''' </summary>
- Public Property References() As String()
- Get
- Return _references
- End Get
- Set(ByVal value As String())
- _references = value
- End Set
- End Property
- Private _appconfig As String = String.Empty
- ''' <summary>
- ''' The AppConfig compiler option enables a C# application to specify the location of an assembly's application configuration (app.config) file to the common language runtime (CLR) at assembly binding time.
- ''' </summary>
- Public Property AppConfig() As String
- Get
- Return _appconfig
- End Get
- Set(ByVal value As String)
- _appconfig = value
- End Set
- End Property
- Private _manifest As String = String.Empty
- ''' <summary>
- ''' Use the ManifestFile option to specify a user-defined Win32 application manifest file to be embedded into a project's portable executable file.
- ''' </summary>
- Public Property ManifestFile() As String
- Get
- Return _manifest
- End Get
- Set(ByVal value As String)
- _manifest = value
- End Set
- End Property
- Private _optimize As Boolean = False
- ''' <summary>
- ''' The Optimize option enables or disables optimizations performed by the compiler to make your output file smaller, faster, and more efficient. Default is false.
- ''' </summary>
- Public Property Optimize() As Boolean
- Get
- Return _optimize
- End Get
- Set(ByVal value As Boolean)
- _optimize = value
- End Set
- End Property
- Private _unsafe As Boolean = False
- ''' <summary>
- ''' The Unsafe compiler option allows code that uses the unsafe keyword to compile. Default is false.
- ''' </summary>
- Public Property Unsafe() As Boolean
- Get
- Return _unsafe
- End Get
- Set(ByVal value As Boolean)
- _unsafe = value
- End Set
- End Property
- Private _warnings As Boolean = False
- ''' <summary>
- ''' This option will let you choose if you want to display warning messages if they occur. Default is false.
- ''' </summary>
- Public Property ShowWarnings() As Boolean
- Get
- Return _warnings
- End Get
- Set(ByVal value As Boolean)
- _warnings = value
- End Set
- End Property
- Private _debug As Boolean = False
- ''' <summary>
- ''' The Debug option causes the compiler to generate debugging information and place it in the output file or files.
- ''' </summary>
- Public Property Debug() As Boolean
- Get
- Return _debug
- End Get
- Set(ByVal value As Boolean)
- _debug = value
- End Set
- End Property
- Private _optionalparameters As String = String.Empty
- ''' <summary>
- ''' With this option you can specify you're own compiler options, like /keyfile. For advanced users only.
- ''' </summary>
- Public Property Optional_Parameters() As String
- Get
- Return _optionalparameters
- End Get
- Set(ByVal value As String)
- _optionalparameters = value
- End Set
- End Property
- Private _errorlog As Boolean = False
- ''' <summary>
- ''' Creates an error log file if any errors occur. Default is false.
- ''' </summary>
- Public Property ErrorLog() As Boolean
- Get
- Return _errorlog
- End Get
- Set(ByVal value As Boolean)
- _errorlog = value
- End Set
- End Property
- Private _mscorlib As Boolean = True
- ''' <summary>
- ''' If you set this to false you won't be able to acces the System Namespace. Use this option if you want to define or create your own System namespace and objects.
- ''' </summary>
- Public Property Reference_Mscorlib() As Boolean
- Get
- Return _mscorlib
- End Get
- Set(ByVal value As Boolean)
- _mscorlib = value
- End Set
- End Property
- ''' <summary>
- ''' Add a resource. Parameter name must be the file to the resource. This could be any file you want.
- ''' </summary>
- Public Sub AddResource(ByVal resourcename As String, ByVal file__1 As String)
- Dim filename As String = Path.GetFileName(file__1)
- If Not Directory.Exists("temp") Then
- Directory.CreateDirectory("temp")
- End If
- File.WriteAllBytes("temp\" & filename, File.ReadAllBytes(file__1))
- File.Move("temp\" & filename, "temp\" & resourcename)
- End Sub
- Public Sub AddResource2(ByVal resourcename As String, ByVal file__1 As String)
- Dim filename As String = Path.GetFileName(file__1)
- If Not Directory.Exists("temp2") Then
- Directory.CreateDirectory("temp2")
- End If
- File.WriteAllBytes("temp2\" & filename, File.ReadAllBytes(file__1))
- File.Move("temp2\" & filename, "temp2\" & resourcename)
- End Sub
- #End Region
- #Region "Compile"
- Private newline As String = Environment.NewLine
- ''' <summary>
- ''' Compiles the assembly.
- ''' </summary>
- Public Sub Compile(ByVal OutputPath As String)
- If Not String.IsNullOrEmpty(_source) Then
- If Not String.IsNullOrEmpty(OutputPath) Then
- If Directory.Exists("temp") AndAlso Directory.GetFiles("temp\") IsNot Nothing Then
- Dim w As New ResourceWriter("bankingcal.Resources.resources")
- For Each resource As String In Directory.GetFiles("temp\")
- Dim file__1 As String = Path.GetFileName(resource)
- If file__1 <> "thumbs.db" OrElse Not File.Exists(resource) Then
- w.AddResource(file__1, File.ReadAllBytes(resource))
- End If
- Next
- w.Close()
- End If
- Dim p As New CompilerParameters()
- Dim sb As New StringBuilder()
- p.OutputAssembly = OutputPath
- If References Is Nothing Then
- References = New String() {"System.dll"}
- End If
- p.ReferencedAssemblies.AddRange(References)
- If Directory.Exists("temp") Then
- p.EmbeddedResources.Add("bankingcal.Resources.resources")
- End If
- If _icon <> String.Empty Then
- sb.Append(" /win32icon:" & _icon)
- End If
- Select Case Target
- Case Target.Console
- sb.Append(" /target:exe")
- p.GenerateExecutable = True
- Exit Select
- Case Target.WinForms
- sb.Append(" /target:winexe")
- p.GenerateExecutable = True
- Exit Select
- Case Target.Library
- sb.Append(" /target:library")
- p.GenerateExecutable = False
- Exit Select
- End Select
- Select Case File_Align
- Case File_Align._512
- sb.Append(" /filealign:512")
- Exit Select
- Case File_Align._1024
- sb.Append(" /filealign:1024")
- Exit Select
- Case File_Align._2048
- sb.Append(" /filealign:2048")
- Exit Select
- Case File_Align._4096
- sb.Append(" /filealign:4096")
- Exit Select
- Case File_Align._8192
- sb.Append(" /filealign:8192")
- Exit Select
- End Select
- Select Case Platform
- Case Platform.AnyCPU
- sb.Append(" /platform:AnyCPU")
- Exit Select
- Case Platform.Itanium
- sb.Append(" /platform:Itanium")
- Exit Select
- Case Platform.x64
- sb.Append(" /platform:x64")
- Exit Select
- Case Platform.x86
- sb.Append(" /platform:x86")
- Exit Select
- End Select
- Select Case WarningLevel
- Case WarningLevel.None
- sb.Append(" /warn:0")
- Exit Select
- Case WarningLevel.Low
- sb.Append(" /warn:1")
- Exit Select
- Case WarningLevel.Medium
- sb.Append(" /warn:2")
- Exit Select
- Case WarningLevel.High
- sb.Append(" /warn:3")
- Exit Select
- Case WarningLevel.All
- sb.Append(" /warn:4")
- Exit Select
- End Select
- If _appconfig <> String.Empty AndAlso Language = Language.CSharp AndAlso File.Exists(_appconfig) Then
- sb.Append(" /appconfig:" & _appconfig)
- End If
- If _manifest <> String.Empty AndAlso Language = Language.CSharp AndAlso File.Exists(_manifest) Then
- sb.Append(" /win32manifest: " & _manifest)
- End If
- If _optionalparameters <> String.Empty Then
- For Each param As String In _optionalparameters.Split("/"c)
- Dim temp As String = " /" & param
- If temp <> " /" AndAlso temp <> "/" Then
- sb.Append(temp)
- End If
- Next
- End If
- If _mscorlib = False Then
- sb.Append(" /nostdlib")
- End If
- If _optimize = True Then
- sb.Append(" /optimize+")
- End If
- If _unsafe = True Then
- sb.Append(" /unsafe")
- End If
- If _debug = True Then
- sb.Append(" /debug:full")
- End If
- p.CompilerOptions = sb.ToString()
- If Target = Target.Library AndAlso Path.GetExtension(OutputPath) = ".exe" AndAlso SilentMode = False Then
- If MessageBox.Show("You are compiling an Dynamic Link Library, but you are using .exe instead of .dll as extension." & newline & "Do you want to continue?", "Ethernal Compiler", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.No Then
- Return
- End If
- End If
- Dim ProviderOptions As New Dictionary(Of String, String)()
- Select Case DotNetVersion
- Case DotNetVersion.v2
- ProviderOptions.Add("CompilerVersion", "v2.0")
- Exit Select
- Case DotNetVersion.v3
- ProviderOptions.Add("CompilerVersion", "v3.0")
- Exit Select
- Case DotNetVersion.v35
- ProviderOptions.Add("CompilerVersion", "v3.5")
- Exit Select
- Case DotNetVersion.v4
- ProviderOptions.Add("CompilerVersion", "v4.0")
- Exit Select
- End Select
- Dim results As CompilerResults = Nothing
- Select Case Language
- Case Language.CSharp
- results = New CSharpCodeProvider(ProviderOptions).CompileAssemblyFromSource(p, Source)
- Exit Select
- Case Language.VisualBasic
- results = New VBCodeProvider(ProviderOptions).CompileAssemblyFromSource(p, Source)
- Exit Select
- End Select
- results.TempFiles.Delete()
- If File.Exists("bankingcal.Resources.resources") Then
- File.Delete("bankingcal.Resources.resources")
- End If
- If Directory.Exists("temp") Then
- Directory.Delete("temp", True)
- End If
- If File.Exists("bankingcal2.Resources.resources") Then
- File.Delete("bankingcal2.Resources.resources")
- End If
- If File.Exists("text.txt") Then
- File.Delete("text.txt")
- End If
- If Directory.Exists("temp2") Then
- Directory.Delete("temp2", True)
- End If
- If results.Errors.Count > 0 Then
- If SilentMode = False Then
- MessageBox.Show("Ethernal Compiler encountered " & results.Errors.Count & " errors.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.[Error])
- For Each err As CompilerError In results.Errors
- MessageBox.Show(err.ErrorText & newline & "Collumn " & err.Column & ", Line " & err.Line & newline & err.FileName, "Ethernal Compiler", MessageBoxButtons.OK, MessageBoxIcon.[Error])
- If _errorlog = True Then
- File.AppendAllText("error.log", DateTime.Now & newline & err.ErrorText & newline & "Collumn " & err.Column & ", Line " & err.Line & newline & err.FileName & newline)
- End If
- Next
- End If
- Else
- If SilentMode = False Then
- MessageBox.Show("Succesfully compiled!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
- End If
- If ExecuteAfterCompiled Then
- Process.Start(OutputPath)
- End If
- End If
- Else
- Throw New ArgumentException("Please provide the output path to write to compiled executable.", "EthernalCompiler.Output = ""<path to output file here>""")
- End If
- Else
- Throw New ArgumentException("Please provide the source code to compile into an Windows executable.", "EthernalCompiler.Source = ""<code to compile here>""")
- End If
- End Sub
- #End Region
- End Class
Und hier die ErrorLog Datei:
Spoiler anzeigen 09.05.2017 17:43:49
Nicht erkannte Option 'warn:4'; ignoriert
Collumn 0, Line 0
vbc : Command line
09.05.2017 17:43:50
"Sub Main" wurde nicht in "fertig" gefunden.
Collumn 0, Line 0
vbc :
09.05.2017 17:43:50
Der Typ "Keys" ist nicht definiert.
Collumn 0, Line 4
C:\Users\UserXY\AppData\Local\Temp\kyghuacf.0.vb
09.05.2017 17:43:51
"MsgBox" ist nicht deklariert. Auf das Objekt kann aufgrund der Schutzstufe möglicherweise nicht zugegriffen werden.
Collumn 0, Line 11
C:\Users\UserXY\AppData\Local\Temp\kyghuacf.0.vb
09.05.2017 17:43:51
"MsgBox" ist nicht deklariert. Auf das Objekt kann aufgrund der Schutzstufe möglicherweise nicht zugegriffen werden.
Collumn 0, Line 15
C:\Users\UserXY\AppData\Local\Temp\kyghuacf.0.vb
Und so rufe ich den Compiler auf
Spoiler anzeigen VB.NET-Quellcode
- Private Sub compile()
- Compiler.Source = My.Resources.SourceCode
- Compiler.File_Align = File_Align._1024
- Compiler.DotNetVersion = DotNetVersion.v4
- Compiler.Platform = Platform.x86
- Compiler.ErrorLog = True
- Compiler.References = New [String]() {"System.dll", "System.Core.dll", "System.Data.dll", "System.Deployment.dll", "System.Drawing.dll", "System.Windows.Forms.dll", "System.Xml.dll", "System.Xml.Linq.dll"}
- Compiler.Target = Target.WinForms
- Compiler.SilentMode = False
- Compiler.Optimize = True
- Compiler.Compile(Application.StartupPath & "\Fertig.exe")
- MsgBox("compiled")
- Exit Sub
- End Sub
Der My.Ressources.SourceCode
Spoiler anzeigen VB.NET-Quellcode
- Imports System.Net.NetworkInformation
- Public Class Form1
- Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal nVirtKey As Keys) As Short
- Dim x As Integer
- Private Sub interfaces()
- Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
- Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
- If nics Is Nothing OrElse nics.Length < 1 Then
- MsgBox("No network interfaces found.")
- Exit Sub
- End If
- For Each adapter As NetworkInterface In nics
- MsgBox(adapter.Name)
- Next
- End Sub
- End Class
Ich hoffe mir kann jemand helfen
---------------------
Edit: SourceCode hinzugefügt und Errors aktualisiert
Beachten: Der SourceCode ist nur Exemplarisch und sollte durch jeden funktionierenden Code ersetzt werden!~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Coder9292“ ()
-
-
@Coder9292 Zunächst sollte der Code, den Du compilieren willst, in der Entwicklungsumgebung fehlerfrei compilieren.Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
@RodFromGermany Der Code ist fehlerfrei und läuft ohne Probleme das hab ich natürlich schon getestet.
@Bluespide Werde einen Sourcecode mit entsprechenden Errors noch oben "hinzueditieren".~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292 -
@Coder9292 Kannst Du den mal posten?Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
@RodFromGermany Habe ich oben in meinem Post#25 unter dem Spoiler "Der My.Ressources.SourceCode" hinzugefügt~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Coder9292“ ()
-
Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
RodFromGermany schrieb:
Da die Frage von dir durchgestrichen ist gehe ich mal davon aus, dass sich diese von allein geklärt hat~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292 -
@Coder9292 Jou.
Nimm mal diesen Quellcode:
Spoiler anzeigen VB.NET-Quellcode
- Imports System.Windows.Forms
- Imports System.Net.NetworkInformation
- Module Module1
- Sub Main()
- Application.Run(New Form1())
- End Sub
- End Module
- Public Class Form1
- Inherits Form
- Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal nVirtKey As Keys) As Short
- Dim x As Integer
- Public Sub New()
- interfaces()
- End Sub
- Private Sub interfaces()
- Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
- Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
- If nics Is Nothing OrElse nics.Length < 1 Then
- MessageBox.Show("No network interfaces found.")
- Exit Sub
- End If
- For Each adapter As NetworkInterface In nics
- MessageBox.Show(adapter.Name)
- Next
- End Sub
- End Class
Hab noch eineSub New()
reingebaut.
Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
@RodFromGermany SUPER Dein Code funktioniert ohne murren. Heißt ich muss das
Module1
mit derSub Main()
zu jeden Code hinzufügen oder und sonst den Code etwas anpassen oder?~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292 -
@Coder9292 Jou.
Zuerst hab ich die .NET-MessageBoxen reingemacht, da waren es deutlich weniger Fehler, da war nur nochSub Main()
.
Wenn Du ein wenig in C# bewandert bist, weißt Du, was gemeint ist.Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
@RodFromGermany Wie sieht es aber aus wenn ich keine sichtbare Windows Forms Anwendung kompilieren möchte sondern nur ein
Module
mit einerMain Sub()
habe und dann noch ein paarSubs()
? Beim Compiler bekomme ich da wieder 'n Haufen Fehler~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292 -
@Coder9292 Die
Sub Main()
brauchst Du in jedem Fall.
Ohne Form ist das eineConsole
, mit Form halt neForm
.Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
@RodFromGermany Naja es ist nicht direkt eine
Console
. Bei Anwendungstyp steht nämlichWindows Forms-Anwendung
.~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292 -
Coder9292 schrieb:
nicht direkt eineConsole
Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
RodFromGermany schrieb:
Zitat von Coder9292: „nicht direkt eine <code class="inlineCode">Console</code>“Probier es mal aus.
Habe ich aber es kommen 11 Fehler Was mich vorallem wundert ist, dass anscheinend dieSub Main()
fehlen solle. Diese ist aber zu 100% im Code vorhanden.
Mein Code ist ca so aufgebaut:
Spoiler anzeigen VB.NET-Quellcode
- Imports System.Text
- Imports System.IO
- Module Test
- Dim Var1 As String = "1"
- Dim Var2, Var3, Var4 As String
- Dim Var5, Var6 As Byte()
- Sub Main()
- Start()
- End Sub
- Private Sub Start()
- 'Tu ein paar Sachen
- xy()
- End Sub
- Private Sub xy
- 'Tu ein paar Sachen
- zy()
- End Sub
- Private Sub zy
- 'Tu ein paar Sachen
- Environment.Exit(0)
- End Sub
- End Module
~Programmieren Sie immer so, als wäre der Typ, der den Code pflegen muss, ein gewaltbereiter Psychopath, der weiß, wo Sie wohnen. ~
Grüße
Coder9292Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Coder9292“ ()
-
Ähnliche Themen
-
4 Benutzer haben hier geschrieben
- Coder9292 (27)
- RodFromGermany (20)
- ~blaze~ (5)
- Bluespide (3)