Skip to content

Commit 3992139

Browse files
committed
true, final fix for ActiveX Imports and dependencies
1 parent af6a19d commit 3992139

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

FlashpointSecurePlayer/FlashpointSecurePlayerGUI.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,32 +315,42 @@ private async Task ImportActiveX(ErrorDelegate errorDelegate) {
315315

316316
try {
317317
// fix for loading dependencies
318+
string fullPath = null;
319+
318320
try {
319-
Directory.SetCurrentDirectory(Path.GetFullPath(TemplateName));
321+
fullPath = Path.GetFullPath(TemplateName);
320322
} catch (Exception ex) {
321323
LogExceptionToLauncher(ex);
322324
errorDelegate(String.Format(Properties.Resources.GameIsMissingFiles, TemplateName));
325+
throw new ActiveXImportFailedException("The ActiveX Import failed because getting the Full Path failed.");
326+
}
327+
328+
try {
329+
Directory.SetCurrentDirectory(Path.GetDirectoryName(fullPath));
330+
} catch (Exception ex) {
331+
LogExceptionToLauncher(ex);
332+
errorDelegate(Properties.Resources.FailedSetWorkingDirectory);
323333
throw new ActiveXImportFailedException("The ActiveX Import failed because setting the Current Directory failed.");
324334
}
325335

326336
ActiveXControl activeXControl = null;
327337

328338
try {
329-
activeXControl = new ActiveXControl(TemplateName);
339+
activeXControl = new ActiveXControl(fullPath);
330340
} catch (InvalidActiveXControlException ex) {
331341
LogExceptionToLauncher(ex);
332342
errorDelegate(Properties.Resources.GameNotActiveXControl);
333343
throw new ActiveXImportFailedException("The ActiveX Import failed because the DLL is not an ActiveX Control.");
334344
} catch (Exception ex) {
335345
LogExceptionToLauncher(ex);
336-
errorDelegate(String.Format(Properties.Resources.GameIsMissingFiles, TemplateName));
346+
errorDelegate(String.Format(Properties.Resources.GameIsMissingFiles, fullPath));
337347
throw new ActiveXImportFailedException("The ActiveX Import failed because the DLL was not found.");
338348
}
339349

340350
BINARY_TYPE binaryType;
341351

342352
try {
343-
binaryType = GetLibraryBinaryType(TemplateName);
353+
binaryType = GetLibraryBinaryType(fullPath);
344354
} catch (Exception ex) {
345355
LogExceptionToLauncher(ex);
346356
errorDelegate(Properties.Resources.GameNotActiveXControl);
@@ -379,6 +389,15 @@ private async Task ImportActiveX(ErrorDelegate errorDelegate) {
379389

380390
ProgressManager.CurrentGoal.Steps++;
381391

392+
// Set Current Directory
393+
try {
394+
Directory.SetCurrentDirectory(Application.StartupPath);
395+
} catch (Exception ex) {
396+
LogExceptionToLauncher(ex);
397+
errorDelegate(Properties.Resources.FailedSetWorkingDirectory);
398+
throw new ActiveXImportFailedException("The ActiveX Import failed because setting the Current Directory failed.");
399+
}
400+
382401
try {
383402
try {
384403
await registryState.StartImportAsync(TemplateName, binaryType).ConfigureAwait(true);

0 commit comments

Comments
 (0)