"The path is not of a legal form" after obfuscating using SA 7
AOF
Posts: 1 New member
Hello all,
My non-obfuscated applications has different DLLs, and some of them execute statements similar to the ones below
_localPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
_location = Path.Combine(_localPath, SyncLogFolder);
where SyncLogFolder is a static readonly string.
The resulting obfuscated assembly embeds different DLLs, and when it executes I get the following error:
The path is not of a legal form.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.InternalGetDirectoryName(String path)
at GreenlineDataSync.GLDataSync..ctor(SyncType sType, ManualResetEvent exitEvent)
at GLService.RunThread.(SyncType , SyncOrigin )
at GLService.RunThread.()
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.InternalGetDirectoryName(String path)
at GreenlineDataSync.GLDataSync..ctor(SyncType sType, ManualResetEvent exitEvent)
at GLService.RunThread.(SyncType , SyncOrigin )
at GLService.RunThread.()
Has anybody seen this error with SA 7? What is the fix? In once instance I moved the Path.* statements around and that fixed the error, but in this case I cannot move the code w/o major refactoring.
Any suggestions?
Thanks,
Armando
Tagged:
Answers
It looks like you have a support ticket open with my colleague Alex, so I'm just copying over the details here:
The problem there is that if the method calling
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
is inside one of the embedded assemblies, thenAssembly.GetExecutingAssembly().Location
will return an empty string (because the embedded assembly is loaded from memory).This should be fixed by using
Assembly.GetExecutingAssembly().CodeBase
orAssembly.GetEntryAssembly().Location
- or not embedding the dependency.Can you please give this a try?
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?