2

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

Hopeless
  • 4,397
  • 5
  • 37
  • 64
kaharas
  • 597
  • 2
  • 17
  • 39

3 Answers3

2

Try changing the target framework from 4.0 to 3.5, that should do the trick.

William
  • 772
  • 7
  • 18
1

This usually indicates either an invalid assembly path or you are not admin.

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).

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I'm using an admin account on my win xp machine, so VS should run in admin mode,and I've already compiled using full path without success. ( dumb question, i should use double backslash, right? "c:\\mumble\\foo.dll" ) – kaharas Jan 07 '11 at 14:48
  • Yes. Or use @"c:\mumble\foo.dll". You'd usually use Assembly.GetEntryAssembly().Location to get the path to the EXE, the DLL is usually close. – Hans Passant Jan 07 '11 at 14:54
  • server returns a 504 error every time i try to update my first post, so, so i'll have to reply her. first of all, thanks. I've tried made the changes you suggested (@"I:\Documents and Settings\foo\Desktop\Hook Test\TestInject\bin\Debug\TestInject.dll") , but the error still appears. By the way, I'm using VS 2010, the project uses .Net framework 3.5 , and my OS is win xp, and both projects are signed with the same key. – kaharas Jan 07 '11 at 15:02
0

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.

DieDaily
  • 69
  • 1