Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Testing for the presence of a .dll
Message
From
13/04/2015 09:42:48
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Testing for the presence of a .dll
Environment versions
Environment:
C# 5.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01618300
Message ID:
01618300
Views:
49
I have a winform app with some isolated modules that access remote MySQL tables.
I want to test for its presence and signal the user that those modules can't be used on the workstation, if the user tries to access one of them and the MySQL.Data.dll is not installed on the workstation running it.
As it stands now, the app just crashes if that happens,

I could probably use try.. catch, but I wanted something more elegant.

So, after searching the web for ideas, I wrote this test program:
       static void Main(string[] args)
        {
            MySqlConnection conn = new MySqlConnection("server=myurluserid=hillary;password=clinton;"); 
            AppDomain currentDomain = AppDomain.CurrentDomain;

            
            Assembly[] assems = currentDomain.GetAssemblies();
            //List the assemblies in the current application domain.
            Console.WriteLine("List of assemblies loaded in current appdomain:");
            foreach (Assembly assem in assems)
            {
                Console.WriteLine( System.IO.Path.GetDirectoryName(assem.Location));
            }
        } 
 
The results show the MySQL.Data.dll as residing in the GAC_MSIL folder- not the programsX86, etc folder where it really resides.

I get the idea that GAC_MSIL is an artifact pointing at the "real" file, etc., but here's my question:

If I find it in GAC_MSIL, can I be sure that it's in "real" folder and that the app will be OK?
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Reply
Map
View

Click here to load this message in the networking platform