8

When trying to run regasm in Win2008 Server:

regasm "C:\Program Files\FooProg\Bar.dll" /tlb:"C:\Program Files\FooProg\Bar.tlb"

I get the following error:

RegAsm : error RA0000 : An error occurred while saving the exported type library: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

what does this mean

Vidar
  • 6,067
  • 22
  • 61
  • 93
  • Looks like you do not have access to write stuff to the global assembly cache. Are you running as a standard user? How about disk space? Previous install waiting to finish? – Craig Dec 04 '09 at 15:41
  • In my experience, if you're trying to develop something to run on a 2008 server, you should just give up before you start to save yourself time/money/and headaches because the security rights are off the charts on that OS. – Jrud Dec 04 '09 at 15:47
  • yep - I should have run cmd.exe as Adminstrator. duh! – Vidar Dec 04 '09 at 16:11

11 Answers11

13

That error mostlikely comes up because you can't delete a corresponding .tlb file. Two other suggestions:

  1. Stop IIS and attempt to register again:
  2. Stop IIS, remove .tlb files from wherever your DLL file is and then attempt to register again.
  3. Close all IE/IIS/DEV tools (they might be keeping some files in read-only state) and then attempt to register your DLL
Dominik Ras
  • 491
  • 5
  • 6
  • 1
    +1 This helped me find the issue. I accidentaly added a "\" after tlbfile name and it created a folder with the same name as tlb file. Removing the folder solved the issue. – surfen Oct 07 '12 at 13:23
  • Thanks for sharing that confirmation surfen. That additional folder would definately derail your execution. – Dominik Ras Nov 27 '12 at 03:36
9

The account under which you run regasm doesn't have rights to write to C:\Program Files\FooProg\ and that's why regasm fails to write the .tlb. Run regasm under an account with administrator priviledges.

sharptooth
  • 159,303
  • 82
  • 478
  • 911
3

The account you are using needs administrator privileges.

scottm
  • 26,493
  • 22
  • 102
  • 155
3

In my case both the .dll and .tlb file were ReadOnly removing the ReadOnly check worked for me, also i have closed the process that was using it like(Visual Studio IDE).

Shiva
  • 39
  • 1
  • +1 I didn't remove ready only in my case but just deleted the .tlb file but flipping read only would have probably done the same thing for me since I was running with administrative privileges already. – Chris Magnuson Jan 15 '12 at 01:51
1

You can also get this problem if you don't specify a full path in the /tlb argument.

It'll attempt to write to C:\windows\system32. Even if you run as Administrator, by default you don't have rights to write to that directory.

The solution is simply to provide a full path (to a directory you have rights to) in the /tlb argument.

Ryan Lundy
  • 187,365
  • 35
  • 174
  • 206
1

More than likely you are getting the error due to a process having hooks into the .dll or .tlb file that you are trying to register or copy. Restart your machine and try again or delete the .tlb file and rebuild it to be sure you can access it.

CDB
  • 19
  • 1
1

That error mostlikely comes up because you can't delete a corresponding .tlb file. Two other suggestions: 1. Stop IIS and attempt to register again: 2. Stop IIS, remove .tlb files from wherever your DLL file is and then attempt to register again.

Dominik Ras
  • 491
  • 5
  • 6
1

I had a stray dllhost.exe process. Killing it allowed me to delete the .tlb file and re-register. Other approaches (Stopping IIS, stopping application pools, closing all IDE's) had no effect.

MPelletier
  • 15,130
  • 14
  • 79
  • 128
1

For me, file was being used by other application

0

First I had to remove all spaces in the path to my dll before regasm found the dll file.

But when I tried with quotation marks around the targets it worked anyway.

0

Win 7 (if are already administrator) - You can enable permissions for the file by right clicking and accessing properties, security tab, click edit, check on the allow for the permissions, e.g. Full control.

Nasri Najib
  • 1,181
  • 10
  • 6