4

このコードを使用すると、プログラムが応答しなくなります。

Assembly assembly = Assembly.LoadFrom(@"C:\test\test.exe");
Type[] typesInAssembly = assembly.GetTypes();

デバッグ モードでは、このコードは 2 行目の実行時に応答を停止します。

test.exe空の WindowsformApplication.exeに変更したところ、動作しました。で動作しない理由がわかりませんtest.exe。ブレークポイントを配置し、Locals セクションのデバッグで Locals をチェックしたところ、いくつかのエラー アイコンが表示され、以下に貼り付けました。誰かがこれについて私を助けてくれることを願っています。

    DefinedTypes    Function evaluation timed out.  System.Collections.Generic.IEnumerable<System.Reflection.TypeInfo>
    EntryPoint  Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. System.Reflection.MethodInfo
    EscapedCodeBase Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. string
    Evidence    Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. System.Security.Policy.Evidence
    ExportedTypes   Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. System.Collections.Generic.IEnumerable<System.Type>
    FullName    Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. string
    GlobalAssemblyCache Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. bool
    HostContext Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. long
    ImageRuntimeVersion Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. string
    IsDynamic   Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. bool
    IsFullyTrusted  Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. bool
    Location    Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. string
    ManifestModule  Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. System.Reflection.Module
    Modules Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. System.Collections.Generic.IEnumerable<System.Reflection.Module>
    PermissionSet   Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. System.Security.PermissionSet
    ReflectionOnly  Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. bool
    SecurityRuleSet Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation. System.Security.SecurityRuleSet
4

1 に答える 1

0

これは以前にも私を悩ませました。私が抱えていた問題は、あなたの問題と同じかもしれませんが、検査していた実行可能ファイルが別の環境のデバッガーで実行されていたことです。これにより、ファイルがロックされました。ファイルをリフレクションのみのコンテキストにロードすることはできましたが、タイプを照会しようとするとハングしました。

したがって、次のことを確認してください。

  • ロードしている実行可能ファイルでプロセスが開いていません
  • おそらくデバッガーによって一時停止された、実行可能ファイルが他の場所にロードされていません
  • リフレクションを使用するプログラムには、ファイルにアクセスするための十分な権限があります

これらのことを確認したら、コンピューターを再起動して、もう一度やり直してください。動くなら資源獲得の問題でした。そうでない場合は、可能であれば実行ファイルをアップロードしてください。問題の再現を試みます。

于 2013-11-08T17:02:27.633 に答える