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

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: 460
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: 460
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: 460
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: 460
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: 460
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.

Mohitvermaji51
Posts: 1
Joined: 03 Dec 2020, 10:59

Re: DLL change path

Post by Mohitvermaji51 »

Go to project properties (Alt+F7)
Under Debugging, look to the right
There's an Environment field.
Add your relative path there (relative to vcproj folder) i.e. ..\some-framework\lib by appending PATH=%PATH%;$(ProjectDir)\some-framework\lib or prepending to the path PATH=C:\some-framework\lib;%PATH%
Hit F5 (debug) again and it should work.

paulritik_09
Posts: 1
Joined: 14 Jun 2021, 11:07

Re: DLL change path

Post by paulritik_09 »

Once it's in a path directory, use the where command to verify windows can find the right one.But downloading random dll files and letting your programs load them is usually a bad idea.
In your Project properties(Right click on project, click on property button) ▶ Configuration Properties ▶ Build Events ▶ Post Build Events ▶ Command Line. Edit and add one instruction to command line. for example copy botan. dll from source path to location where is being executed the program.
Last edited by paulritik_09 on 14 Jun 2021, 11:11, edited 1 time in total.

bezjosh99
Posts: 2
Joined: 27 Oct 2021, 13:54

Re: DLL change path

Post by bezjosh99 »

your relative path there (relative to vcproj folder) i.e. ..\some-framework\lib by appending PATH=%PATH%;$(ProjectDir)\some-framework\lib or prepending to the path PATH=C:\some-framework\lib;%PATH%

Post Reply