Resolved CodeBase returns the .dll file. I need an .exe file.

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
112
Programming Experience
10+
This is what I did in 4.8

Dim exePath As String = System.Reflection.Assembly.GetExecutingAssembly.CodeBase
p = Process.Start(New ProcessStartInfo(exePath) With {.Verb = "runas"})

4.8 produced a .exe file and CodeBase above returned it.

5.0 produces both an .exe and a .dll file and CodeBase returns the .dll file. So the above in Net5 fails.

It just occurred to me that I could try replacing the dll string with exe but that seems a little kluged.

Is there a good Net5.0 way to do the above?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,557
Location
Norway
Programming Experience
10+
Process.GetCurrentProcess().MainModule.FileName
 
Solution

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,557
Location
Norway
Programming Experience
10+
It not a big deal to change extension either: IO.Path.ChangeExtension(Reflection.Assembly.GetExecutingAssembly.Location, ".exe") (notice also Location is used instead of CodeBase that is obsolete)
 
Top Bottom