Skip to content

Commit 7c4922e

Browse files
committed
Fix the not loading OpenAL32.dll issue
1 parent f74f8da commit 7c4922e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Source/Contrib/TrackViewer/Program.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2014, 2018 by the Open Rails project.
1+
// COPYRIGHT 2014, 2018 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -15,10 +15,11 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
1717
using System;
18+
using System.IO;
1819
using System.Diagnostics;
20+
using System.Reflection;
1921
using System.Windows.Forms;
2022

21-
2223
namespace ORTS.TrackViewer
2324
{
2425
static class Program
@@ -31,6 +32,11 @@ static void Main(string[] args)
3132
{
3233
using (TrackViewer trackViewer = new TrackViewer(args))
3334
{
35+
//enables loading of dll for specific architecture(32 or 64bit) from distinct folders, useful when both versions require same name (as for OpenAL32.dll)
36+
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Native");
37+
path = Path.Combine(path, (Environment.Is64BitProcess) ? "X64" : "X86");
38+
Orts.NativeMethods.SetDllDirectory(path);
39+
3440
// code below is modified version from what is found in GameStateRunActivity.cs
3541
if (Debugger.IsAttached) // Separate code path during debugging, so IDE stops at the problem and not at the message.
3642
{

Source/RunActivity/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131
namespace Orts
3232
{
33-
static class NativeMethods
33+
public static class NativeMethods
3434
{
3535
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)]
36-
internal static extern bool SetDllDirectory(string pathName);
36+
public static extern bool SetDllDirectory(string pathName);
3737
}
3838

3939
static class Program

0 commit comments

Comments
 (0)