Using <codebase> element in app.config
Asked Answered
J

2

6

I intend to keep few dll's in a folder other than the bin folder for my .NET 3.5 Windows application. I am unsure of how would I use the codebase element or the probing element to specify the right path. This is what I have in the app.config file now,

<runtime>
 <assemblyBinding>
  <dependentAssembly>
    <assemblyIdentity name="CommonLib" publicKeyToken="f0b5026b59d5645e"   
     culture="neutral" />
    <codeBase version="1.0.0.0" href="SharedFolder\CommonLib.dll" />
  </dependentAssembly>
 </assemblyBinding>
</runtime>

I get, Could not load assembly error at runtime. It seems I am doing something wrong in the config file. The SharedFolder is a folder added to the project.

Jenaejenda answered 14/12, 2009 at 16:7 Comment(0)
M
8

It seems the codeBase element is for getting files with a URL, have you tried using the probing element?

<runtime>
 <assemblyBinding>
  <dependentAssembly>
    <assemblyIdentity name="CommonLib" publicKeyToken="f0b5026b59d5645e"   
     culture="neutral" />
  </dependentAssembly>
  <probing privatePath="SharedFolder"/>
 </assemblyBinding>
</runtime>
Morbific answered 14/12, 2009 at 16:15 Comment(1)
I thought so. Could you quickly edit the runtime element I have added to use the probing element in it? I tried that but probably I did not use it correctly.Jenaejenda
J
1

Thanks Yuriy. The problem was the path. the privatePath value needs to be a path which the .NET runtime can reach. I was trying to "SharedFolder" which was not inside the Debug folder, it was directly under the project folder.

Jenaejenda answered 16/12, 2009 at 17:59 Comment(1)
You should have marked an answer (and add a comment to it if you want) instead of creating another answer here...Rambort

© 2022 - 2024 — McMap. All rights reserved.