gpt4 book ai didi

.net - .NET Reflector 指令的命名空间

转载 作者:行者123 更新时间:2023-12-04 16:58:11 24 4
gpt4 key购买 nike

在 .NET Reflector 的先前版本中,我能够获取函数内指令的命名空间,但现在我不能并且文档不存在。

Red Gate 的 .NET Reflector 6.8.2.5(最后一个免费版本)

这一行正在工作,但现在不行:instruction.Value.declaringtype.namespace.ToString

如何获取指令的命名空间?

谢谢

Private Sub DesassamblerDLL(ByVal strDLLFile As String)
Dim serviceProvider As New Reflector.ApplicationManager(Nothing)
Dim assemblyManager As Reflector.CodeModel.IAssemblyManager
Dim objAssembly As Reflector.CodeModel.IAssembly
Dim objMod As Reflector.CodeModel.IModule
Dim typeDeclaration As Reflector.CodeModel.ITypeDeclaration
Dim methodDeclaration As Reflector.CodeModel.IMethodDeclaration

assemblyManager = serviceProvider.GetService(GetType(Reflector.CodeModel.IAssemblyManager))
objAssembly = assemblyManager.LoadFile(strDLLFile)

For Each objMod In objAssembly.Modules
For Each typeDeclaration In objMod.Types
For Each methodDeclaration In typeDeclaration.Methods
Dim methodBody As Reflector.CodeModel.IMethodBody = methodDeclaration.Body
If Not methodBody Is Nothing Then
Dim instruction As Reflector.CodeModel.IInstruction
For Each instruction In methodBody.Instructions
str = instruction.Value.declaringtype.namespace.ToString
Next
End If
Next
Next
Next
End Sub

最佳答案

我是在 http://forums.reflector.net/questions/2226/namespace-of-an-instruction-net-reflector 的克莱夫的帮助下完成的.

Imports system.Reflection.Emit

Select Case instruction.Code
Case OpCodes.Call.Value, OpCodes.Calli.Value, OpCodes.Callvirt.Value
Dim targetMethodReference As Reflector.CodeModel.IMethodReference = instruction.Value
Dim method As Reflector.CodeModel.IMethodDeclaration = targetMethodReference.Resolve
Dim typeReference As Reflector.CodeModel.ITypeReference = method.DeclaringType
...
End Select

关于.net - .NET Reflector 指令的命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10192687/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com