Handling missing or incompatible dll's at startup in a winform app RRS feed

  • Question

  • I made several earlier posts about an application that would not launch here and here . As suggested, I'm cross-posting the specific questions here.

    1. What is the best way to detect and report back (informatively and hopefully in a way the user can fix it on their own) when a Winform application does not have a compatible version of its referenced dlls available at execution time? Would the approach matter if any of the dll's were installed in GAC?

    2. Is always using the "specific version" option a good idea?

    3. What is the best way to detect that an application does not have the needed security permissions to launch? (e.g., launched off a network share).

    VS2008, C#, targeting FW 2.0...

    Thanks in advance...
    Friday, February 26, 2010 6:36 PM


  • I'm sorry you haven't received feedback on this earlier. The simplest errors are always the hardest to find.

    1. When the runtime cannot find the propriate assembly to be loaded you can handle the AppDomain.AssemblyResolve event to get information about the assembly and possible point to where the runtime can find it. The runtime follows a specific path when it looks for an assembly. If I recall the GAC is the last place to be looked.
    As for DLL:s that you P/Invoke they are "loaded" in pretty much the same way, that is when members inside are first referenced. The runtime will not fail to start your program if any referenced DLL:s aren't there, unless they are used during startup.

    2. Unless the interface to referenced DLL:s have changed between revisions I see no good in using the specific version feature.

    3. There are programs that can be used to check what permissions a .net application requires to run, but in order for them to work the application must declare security permissions on assembly level. Using attributes you can inform the runtime that the application must have x permissions in order to run.

    Did setting the reference for MySql.Data.dll to a specific version solve the startup issue?

    - Still confused, but on a higher level -
    Sunday, February 28, 2010 12:44 PM