/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/standard/assembly/snippets/identify/visual-basic/ExampleAssemblyName.vb
28 строк
938 B
MSDN.WhiteKnight
Improve How to determine if a file is an assembly (#25329)
02 авг 2021, 22:54
Не верифицирован
02 авг 2021, 22:54
5c10176
Код
Авторство
О чём код?
'<SnippetAssemblyName> Imports System Imports System.IO Imports System.Reflection Imports System.Runtime.InteropServices Module ExampleAssemblyName Sub CheckAssembly() Try Dim filePath As String = Path.Combine( RuntimeEnvironment.GetRuntimeDirectory(), "System.Net.dll") Dim testAssembly As AssemblyName = AssemblyName.GetAssemblyName(filePath) Console.WriteLine("Yes, the file is an Assembly.") Catch ex As FileNotFoundException Console.WriteLine("The file cannot be found.") Catch ex As BadImageFormatException Console.WriteLine("The file is not an Assembly.") Catch ex As FileLoadException Console.WriteLine("The Assembly has already been loaded.") End Try End Sub End Module ' Output: ' Yes, the file is an Assembly. '</SnippetAssemblyName>