|
using external assemblies in Powershell scripts Hi all,
In my company, we develop some native DLLs written in C, and for these DLLs,
we also provide some .Net wrappers.
I stored the native DLLs and .Net ones in the same folder.
When I call:
[Reflection.Assembly]::LoadFrom($path + "dll1.dll")
[Reflection.Assembly]::LoadFrom($path + "dll2.dll")
I get:
GAC Version Location
--- ------- --------
False v1.1.4322 <path>\dll1.dll
False v1.1.4322 <path>\dll2.dll
We have some object factories, factories are in the dll1 and some objects
created by the factories are in the dll2.
When I create, with a factory, an object totally hold in the dll1, no
problem, it works.
But when I create, always with a dll1 factory, an object hold in the dll2, I
get a FileNotFoundException:
"Could not load file or assembly 'dll2' or one of its dependencies'.
The LogFusion gives me some interesting traces:
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Attempting download of new URL
file:///C:/WINDOWS/system32/WindowsPowerShell/v1.0/dll2.DLL.
LOG: Attempting download of new URL
file:///C:/WINDOWS/system32/WindowsPowerShell/v1.0/dll2/dll2.DLL.
LOG: Attempting download of new URL
file:///C:/WINDOWS/system32/WindowsPowerShell/v1.0/dll2.EXE.
LOG: Attempting download of new URL
file:///C:/WINDOWS/system32/WindowsPowerShell/v1.0/dll2/dll2.EXE.
I don't really know what happens here, it seems my assembly dll2 has been
unloaded a something similar.
Any help would be greatly appreciated. Thanks in advance. |