Hello,
I have my .dll on a network share, it has a configuration file it reads from in the same folder it resides in.
EG:
\\server\share\plugins\me.dll
\\server\share\plugins\me.ini
When I debug it (on the local machine with VS 2010) everything is fine.
Howver now that Its been released and I test it, the path is scrwed up.
For example, I open a .DWG it gives that path plus the dll path.
EG:
C:\stuff\mydrawing.dwg
Path Im given:
C:\stuff\server\share\plugins\me.ini
How can I get ONLY the dll path?
I'm using
Dim basePath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
T
Instead of using CodeBase, use Location for network shared drive as it is UNC (Universal Naming Convention) path. Write your test results to log file if you cannot debug after releasing.
Dim basePath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
Rather than going through all those gymnastics, just create a few registry keys to manage the search paths.
Here is the quick code I used for testing assembly path:
[CommandMethod("GetPluginPath")] public static void GetPluginPath() { string location = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string codebase = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
System.Windows.Forms.MessageBox.Show(string.Format("Location = {0}\nCodeBase = {1}", location, codebase)); }
If I put the DLL in a network shared folder, then load it into AutoCAD, run the command GetPluginPath and still see both Location and CodeBase get the same path. CodeBase you need to get substring. Not sure why you cannot get the DLL path after opening a DWG file.