This is my Errormessage:
Could not load file or assembly 'file:///C:\Windows\system32\Rule.dll'. The system cannot find the file specified.
The problem is that the same exe works in my development environment but not on productive server. The program is a tool that should run as a Scheduled Task on Windows Server 2008. It consists of an exe, one so called Database.dll and the Rule.dll. The exe should load the Rule.dll dynamically in codebehind but it fails with the above error only when started from Task Scheduler. Why is it looking in System32 folder and not in the Application folder? Is it an UAC-issue?
'Load the rule engine into memory
Dim asmRule As System.Reflection.Assembly = Nothing
Try
asmRule = System.Reflection.Assembly.LoadFrom("Rule.dll") 'fails on productive system
Catch ex As System.Exception
HistoryLog.writeLog("SysLog", ex, "Cannot find Rule.dll in Application Folder")
End Try
Have you tried:
asmRule = Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Rule.dll"));
The method LoadFrom
will use Environment.CurrentDirectory
to build the full path to the assembly that will be loaded. The current directory is not the same as the application base path.
You should provide the full path to LoadFrom
method, you can build it using AppDomain.CurrentDomain.BaseDirectory
if the file is located in the same folder then the executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With