DLL change path

Here you can find everything you need to know about Dll-Files. You can also share your knowledge regarding the topic.

Moderators: DllAdmin, DLLADMIN ONLY

Post Reply
Erjen

DLL change path

Post by Erjen »

Hello,

Nice forum! Hope you can answer my question.
I have a DLL file that points to C:\map and I can changed that directory (with Reflexil, plug-in for Reflector) and that works fine. But what I actually want is that it points to its current directory without defining C:\ etc.

Is that possible?

I really hope so!

Thanks!

DllAdmin
Site Admin
Posts: 407
Joined: 17 Mar 2011, 12:32
Contact:

Re: DLL change path

Post by DllAdmin »

Try to change the C:\map to . (dot only, nothing else) usually . (dot) means the current directory.

Try that and let us know if that worked.


C:\map => .

Erjen

Re: DLL change path

Post by Erjen »

Thanks for your reply!

I changed it but it doesn't point to the current directory.
It points to:
C:\Windows\SysWOW64\inetsrv\

Do you know how to solve this?

Thanks again!

Erjen

Re: DLL change path

Post by Erjen »

And maybe this helps you a little:


private void InitialiseCatalogName()
{
string filename = Path.Combine(".", "settings.xml");
XmlDocument document = new XmlDocument();
document = this.Load(filename);
XmlNode node = document.SelectSingleNode(this.GetXmlLocationCatalogName());
if (node == null)

Thats the piece of code and as you can see I replaced C:\map with the dot.

DllAdmin
Site Admin
Posts: 407
Joined: 17 Mar 2011, 12:32
Contact:

Re: DLL change path

Post by DllAdmin »

Try this in

string filename = Path.Combine(Environment.CurrentDirectory, "settings.xml");

Erjen

Re: DLL change path

Post by Erjen »

Pfft now it proudly points to
'C:\Windows\SysWOW64\inetsrv\Environment.CurrentDirectory\settings.xml'

Unbelievable right.

I did exactly what you said:
string filename = Path.Combine("Environment.CurrentDirectory", "settings.xml");

Are there any other options or am I still doing something wrong?

Thank you very much again for your reply!

DllAdmin
Site Admin
Posts: 407
Joined: 17 Mar 2011, 12:32
Contact:

Re: DLL change path

Post by DllAdmin »

Hi again,

Do not put quotes in Environment.CurrentDirectory , this is the Environment variable, there is no need for " " (quotes) around that!

Just copy and paste it like this:

Path.Combine(Environment.CurrentDirectory, "settings.xml");

Erjen

Re: DLL change path

Post by Erjen »

I am trying to remove them but with Reflexil it’s impossible. And the dll file is compiled so when I decompile it with Visual Studio and the Reflector plug-in, I can change it like you said but impossible to compile again I think.

Are you sure that the problem is the quotes? Because if that’s what you think it is I will do everything to remove them.

Thank you very much again! I appreciate your replies

DllAdmin
Site Admin
Posts: 407
Joined: 17 Mar 2011, 12:32
Contact:

Re: DLL change path

Post by DllAdmin »

I think the problem is in the quotes because if you put a string in quotes that means that the path is that one in between quotes.

But what you need to do is add a variable instead of string. The variable Environment.CurrentDirectory is the dynamic variable for the current directory (obviously). If you can make it work without the quotes that I think would be a solution.

You can also try to leave the path empty like this "" but I doubt this will work.

Erjen

Re: DLL change path

Post by Erjen »

I changed it but didn't work either :(

I solved it now but used a workaround.

Thanks for all your replies and your help!!

DllAdmin
Site Admin
Posts: 407
Joined: 17 Mar 2011, 12:32
Contact:

Re: DLL change path

Post by DllAdmin »

Hi Erjen,

It would be the best if you could tell what was the workaround! Other people might find it useful. :)

Thanks.

ExtraCoder
Posts: 1
Joined: 13 Nov 2020, 16:54

Re: DLL change path

Post by ExtraCoder »

Erjen wrote:
> I am trying to remove them but with Reflexil it’s impossible. And the dll
> file is compiled so when I decompile it with Visual Studio and the
> Reflector plug-in, I can change it like you said but impossible to compile
> again I think.

Usually DLLs that I decompile with http://Decompiler.com/ are compilable back. This decompiler produces a project structure that can be then imported into any IDE.

Post Reply