Easyhook 引发“无法在 GAC 中安装程序集”错误vs2010上报错
我仍在尝试进行我的 easyhook 练习。现在,我收到此错误:
System.ApplicationException: Unable to install assembly in the GAC. This usually indicates either an invalid assembly path or you are not admin.
at EasyHook.NativeAPI.GacInstallAssembly(IntPtr InContext, String InAssemblyPath, String InDescription, String InUniqueID)
at EasyHook.Config.Register(String InDescription, String[] InUserAssemblies)
at HookTest.Program.Main()
问题似乎源于此:
Config.Register(
"Easy hook test",
"Hook Test.vshost.exe",
"TestInject.dll");
我尝试构建的解决方案由两个项目组成,一个库和一个应用程序。构建解决方案后,我将 testinject.dll 复制到 hooktest 调试文件夹,然后在调试模式下运行它。 也许我应该使用绝对路径来指示 testinject.dll 的位置?或者在某个地方添加库?
更新 1
"Easy hook test",
@"Hook Test.vshost.exe",
@"I:\Documents and Settings\foo\Desktop\Hook Test\TestInject\bin\Debug\TestInject.dll");
即使进行了此更改,我仍然遇到相同的错误
I'm still trying to run my easyhook exercize. right now, i get this error:
System.ApplicationException: Unable to install assembly in the GAC. This usually indicates either an invalid assembly path or you are not admin.
at EasyHook.NativeAPI.GacInstallAssembly(IntPtr InContext, String InAssemblyPath, String InDescription, String InUniqueID)
at EasyHook.Config.Register(String InDescription, String[] InUserAssemblies)
at HookTest.Program.Main()
and the problem seems to originate here:
Config.Register(
"Easy hook test",
"Hook Test.vshost.exe",
"TestInject.dll");
The solution I'm trying to build is composed by two projects, a library and an application. Once I build the solution, i copy testinject.dll to the hooktest debug folder, and then I run it in debug mode.
Maybe I should use an absolute path to indicate where testinject.dll is? or add the library somewhere?
UPDATE 1
"Easy hook test",
@"Hook Test.vshost.exe",
@"I:\Documents and Settings\foo\Desktop\Hook Test\TestInject\bin\Debug\TestInject.dll");
Even with this change, I get the same error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将目标框架从 4.0 更改为 3.5,应该可以解决问题。
Try changing the target framework from 4.0 to 3.5, that should do the trick.
正如您所期望的,这是一条很好的错误消息。该路径可能是错误的,因为您没有指定程序集的完整路径(即 c:\mumble\foo.dll)。由于 UAC,您通常没有管理员权限。使用清单获取权限提升或在管理模式下运行 Visual Studio(更改桌面快捷方式)。
That's as good an error message as you can expect. The path could be wrong because you don't specify the full path of the assembly (i.e. c:\mumble\foo.dll). You commonly don't have admin rights because of UAC. Use a manifest to get the privilege elevation or run Visual Studio in admin mode (change the desktop shortcut).
即使您自己是管理员,但这并不意味着您运行的应用程序将被提升为管理员。事实上,VS 2010 不会,大多数其他人也不会。您实际上必须右键单击“以管理员身份运行...”。实际上,我将 VS 开始菜单快捷方式的属性设置为“以管理员身份运行”,这样我就永远不会忘记,因为我也对此感到困惑。
Even though you yourself are an Admin, it does not mean that apps that you run will be elevated to admin. In fact, VS 2010 will NOT be, nor will most others. You actually have to right-click "Run as Admin...". I actually set my VS start menu shortcut's properties to "Run as Administrator" so that I never forget, as I was burned on this too.