14
votes

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

2
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

2 Answers

29
votes

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

0
votes

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.