.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.DLL current folder VS .DWG current folder = MESSED UP PATH

3 REPLIES 3
Reply
Message 1 of 4
TTIII
465 Views, 3 Replies

.DLL current folder VS .DWG current folder = MESSED UP PATH

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

 

3 REPLIES 3
Message 2 of 4
khoa.ho
in reply to: TTIII

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)

Message 3 of 4
dgorsman
in reply to: TTIII

Rather than going through all those gymnastics, just create a few registry keys to manage the search paths.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 4
khoa.ho
in reply to: TTIII

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.

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost