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

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
219
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?
 
Process.GetCurrentProcess().MainModule.FileName
 
Solution
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)
 
Back
Top