14

I'm trying to merge two assemblies into a single assembly, which works quiet fine. Yet, when I try to merge the *.pdb files too, I get an error:

Access to the path "F:\Fentec\Businessplan\trunk\Ausgabe\Debug\modules\Planrechnung\Planrechnung.pdb" is denied.

If I use the /ndebug option in order to skip merging the *.pdb files, it works fine. But of course the symbols can't be loaded while debugging. At first I thought when calling ILMerge in the postbuild event, that Planrechung.pdb was in use and locked. I also tried closing VS2010 and call ILMerge from the command line, but the result remained the same. I checked with ProcessExplorer and there is no handle on the file.

This is how I call ILMerge:

E:\XP\Tools\ILMerge\ilmerge /targetplatform:v4,"D:\WINDOWS\Microsoft.NET\Framework\v4.0.30319" /lib:"F:\Fentec\Businessplan\trunk\Ausgabe\Debug\bin" /out:Planrechnung.dll "F:\Fentec\Businessplan\trunk\Ausgabe\Debug\modules\Planrechnung\Planrechnung.dll" "F:\Fentec\Businessplan\trunk\Ausgabe\Debug\modules\Mandantenverwaltung\Mandantenverwaltung.dll"

Have I missed something? If there are any additional infos you need, just ask.

Greetings,
Skalli

Skalli
  • 2,707
  • 3
  • 27
  • 39
  • possible duplicate of [Is there a way to merge pdb files with ilmerge?](http://stackoverflow.com/questions/1439721/is-there-a-way-to-merge-pdb-files-with-ilmerge) – Preet Sangha Sep 06 '11 at 10:44
  • No, I've read that question. But it only handles how to deal with the /ndebug option, not the problem that I have here. – Skalli Sep 06 '11 at 10:47

2 Answers2

29

I've found the solution to the problem and it's a bit embarrassing.

The output name mustn't be the same name of one of the merged pdb files. Otherwise this problems occurs. When I changed the name of an assembly it worked great. It's also no problem to overwrite a assembly in the process, but you can't overwrite an existing pdb file.
I didn't expect this and stumbled across it by accident. Sorry for all the trouble

Greetings,
Skalli

Skalli
  • 2,707
  • 3
  • 27
  • 39
  • Did the same mistake. +1 for this – yas4891 Feb 03 '12 at 15:00
  • I also did the same, and you kinda saved my life. Such a dumb stuff. Dont be sorry, you providing a nice question with an life saving answer which is one of the first entries in google. – JoshuadV Nov 19 '15 at 10:21
  • 2
    If you specify some other \output directory, no such error occurs and you do not have to change names. – Vlad Gonchar Feb 07 '17 at 18:06
0

It sounds to me like the .pdb file is locked, probably because it is in use in a debugger (such as Visual Studio).

Try closing both Visual Studio and your application (if you already haven't).

If that doesn't work then use a tool like Process Explorer to search for processes that have that file open. In process explorer you can do this using the Find -> Find Handle or Dll...:

Screenshot of the Process Explorer Search dialog

Enter the name of the file / pdb you are searching for and it will list all processes that have that file open - either close the individual handles or kill / close those applications and try again.

Justin
  • 84,773
  • 49
  • 224
  • 367
  • Hello Justin, I've tried that already. There are no handles using Planrechnung.pdb. But I figured out, that ILMerge itself is causing the problem. ILMerge can overwrite an assembly, but not a pdb file. I've changed the name of the assembly and now it seems to work. – Skalli Sep 06 '11 at 14:02