本文整理汇总了VB.NET中System.BadImageFormatException类的典型用法代码示例。如果您正苦于以下问题:VB.NET BadImageFormatException类的具体用法?VB.NET BadImageFormatException怎么用?VB.NET BadImageFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BadImageFormatException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: DLL
' Windows DLL (non-.NET assembly)
Dim filePath As String = Environment.ExpandEnvironmentVariables("%windir%")
If Not filePath.Trim().EndsWith("\") Then filepath += "\"
filePath += "System32\Kernel32.dll"
Try
Dim assem As Assembly = Assembly.LoadFile(filePath)
Catch e As BadImageFormatException
Console.WriteLine("Unable to load {0}.", filePath)
Console.WriteLine(e.Message.Substring(0, _
e.Message.IndexOf(".") + 1))
End Try
' The example displays an error message like the following:
' Unable to load C:\WINDOWS\System32\Kernel32.dll.
' The module was expected to contain an assembly manifest.
开发者ID:VB.NET开发者,项目名称:System,代码行数:14,代码来源:BadImageFormatException
示例2: exceptionList
Public Module StringLib
Private exceptionList() As String = { "a", "an", "the", "in", "on", "of" }
Private separators() As Char = { " "c }
Public Function ToProperCase(title As String) As String
Dim isException As Boolean = False
Dim words() As String = title.Split( separators, StringSplitOptions.RemoveEmptyEntries)
Dim newWords(words.Length) As String
For ctr As Integer = 0 To words.Length - 1
isException = False
For Each exception As String In exceptionList
If words(ctr).Equals(exception) And ctr > 0 Then
isException = True
Exit For
End If
Next
If Not isException Then
newWords(ctr) = words(ctr).Substring(0, 1).ToUpper() + words(ctr).Substring(1)
Else
newWords(ctr) = words(ctr)
End If
Next
Return String.Join(" ", newWords)
End Function
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:28,代码来源:BadImageFormatException
示例3: Main
' 导入命名空间
Imports System.Reflection
Module Example
Public Sub Main()
Dim title As String = "a tale of two cities"
' Load assembly containing StateInfo type.
Dim assem As Assembly = Assembly.LoadFrom(".\StringLib.dll")
' Get type representing StateInfo class.
Dim stateInfoType As Type = assem.GetType("StringLib")
' Get Display method.
Dim mi As MethodInfo = stateInfoType.GetMethod("ToProperCase")
' Call the Display method.
Dim properTitle As String = CStr(mi.Invoke(Nothing, New Object() { title } ))
Console.WriteLine(properTitle)
End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:17,代码来源:BadImageFormatException 输出:
Unhandled Exception: System.BadImageFormatException:
The format of the file 'StringLib.dll' is invalid.
示例4: Example
' 导入命名空间
Imports System.IO
Imports System.Reflection
Module Example
Public Sub Main()
Dim args() As String = Environment.GetCommandLineArgs()
If args.Length = 1 Then
Console.WriteLine()
Console.WriteLine("Syntax: PlatformInfo <filename> ")
Console.WriteLine()
Exit Sub
End If
Console.WriteLine()
' Loop through files and display information about their platform.
For ctr As Integer = 1 To args.Length - 1
Dim fn As String = args(ctr)
If Not File.Exists(fn) Then
Console.WriteLine("File: {0}", fn)
Console.WriteLine("The file does not exist.")
Console.WriteLine()
Else
Try
Dim an As AssemblyName = AssemblyName.GetAssemblyName(fn)
Console.WriteLine("Assembly: {0}", an.Name)
If an.ProcessorArchitecture = ProcessorArchitecture.MSIL Then
Console.WriteLine("Architecture: AnyCPU")
Else
Console.WriteLine("Architecture: {0}", an.ProcessorArchitecture)
End If
Catch e As BadImageFormatException
Console.WriteLine("File: {0}", fn)
Console.WriteLine("Not a valid assembly.\n")
End Try
Console.WriteLine()
End If
Next
End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:40,代码来源:BadImageFormatException
注:本文中的System.BadImageFormatException类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论