0

I added these lines into app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas?microsoft?com:asm.v1">
      <dependentAssembly>
        <codeBase version="1.0.0.0"
          href= ".\libs\CrashReporter.dll"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

But my console application crashes and exception says that:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 
'CrashReporter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
The system cannot find the file specified.
at TestConsoleApplication.Program.Main(String[] args)

CrashReporter.dll is a managed code in c# that I have referenced in my consol application. But in properties tab of dll reference I have set Copy Local to false. Because in installer I want to copy it in .\libs\CrashReporter.dll folder and that would not be in the same folder as .exe file.

How can I tell the .net that i places the dll file in ../libs/ folder relative to the .exe file?

a.toraby
  • 3,232
  • 5
  • 41
  • 73
  • Did you add it through references? Is this you dll? is this managed dll? Is this library available through nuget? if so you, you should consider installing it by nuget – Piotr Aug 02 '17 at 11:05
  • @Piotr this is a dll of mine. and it is managed code. If i copy it to bin folder everything works fine. but I need it to be in a different folder. – a.toraby Aug 02 '17 at 11:15
  • 1
    You mustn't copy it yourself. Just add reference to it using References-> Add reference -> Browse -> Click Browser button and locate this dll (in lib folder) – Piotr Aug 02 '17 at 11:20
  • @Piotr I have created a setup file and in that setup i copy the crashreporter to a shared folder which other applications can use. So I do not want to copy the .dll in each application bin folder. therefore I need to refer to a single .dll file from several application. Is it clear now? Every naive programmer knows how to add a reference in vs! Anyway thank you for your participation. – a.toraby Aug 02 '17 at 11:29
  • This app.config you've posted. Where is it located? – Piotr Aug 02 '17 at 11:32
  • I do not want to copy the .dll in each application bin folder. Doesnt this mean you need it in global cache? – Hameed Syed Aug 02 '17 at 11:48

0 Answers0