title: C# late binding and File exceptions
body: <p>Simple host app searching for assemblies by special Interface and importing from them list of delegates, now it's <code>Func&lt;string,string&gt;</code>. 
  Then it can execute any <code>Func&lt;T,T&gt;</code> and there's no problem. 
  Problems starts when any of this <code>Func</code> tries to access file, which doesn't exist. </p>
  
  <p>No try-catch block, no <code>File.Exists</code> doesn't helps — when function tries to access a file (anyway, read, get stream, check, etc) — whole app just fails with <code>FileNotFound</code> in <code>mscorlib</code>. </p>
  
  <p>How this can be fixed? App is really critical, and I can't perform file check in app, only just in assemblies. </p>
  
  <p>UPD: Yes, that delegates contains <code>async</code> logic.</p>
  
  <p>UPD2: Parts of code: </p>
  
  <pre><code>    try
      {
          if(!File.Exists(filePath)) return null;
  
                  using (StreamWriter writer = new StreamWriter(destinationFilePath))
                  {
                      using (StreamReader reader = new StreamReader(filePath))
                      {
                      //some logic there
                      }
                   }
       }
      catch 
      {
  
      }
  </code></pre>
  
  <p>Exception thrown at File.Exists().</p>
  
  <p>This code used to import assemblies. </p>
  
  <pre><code>Commands = new Dictionary&lt;string, Func&lt;string, string&gt;&gt;(); 
  foreach (string f in fileNames)
                  {
  
                      Assembly asm = Assembly.LoadFrom(f);
                      var types = asm.GetTypes();
                      foreach(Type t in types)
                      {
  
                          if (t.GetInterface("IMountPoint") != null)
                          {
  
                              var obj = Activator.CreateInstance(t);
                              var cmds = ((IMountPoint)obj).Init(EntryPoint);
                              foreach (var cmd in cmds)
                              {
                                  if (!Commands.ContainsKey(cmd.Key.Trim().ToUpper()))
                                  {
                                      Commands.Add(cmd.Key.Trim().ToUpper(), cmd.Value);
                                  }
  
                              }
                          }
                      }
                  }
  </code></pre>
  
  <p>And this code to run delegates: </p>
  
  <pre><code>string input = Console.ReadLine();
  string res = Commands[command_key](input);
  </code></pre>