Facing an issue in PowerShell while loading dll’s and their dependent components.
I have loaded a .NET (C#) dll’s in PowerShell using Add-Type –Path as following, and this is working successfully.
Add-Type -Path ($fileDirectory + “Contracts.dll”)
This dll has a function FindImage, which in turn loads few C dll’s such as opencv_core300.dll, openCL.dll
What are the possible ways to load these dependent(C) dll’s.
You don’t really “load” unmanaged code into a .NET or PowerShell session, so far as I know. You just declare calls to them using .NET’s interop functionality, and the .NET framework will access those DLLs as needed.
If they’re not actually installed on the path somewhere, then perhaps you need to make sure the .NET framework finds them in your “current” folder (which is different from what PowerShell will be showing you). Try doing this before calling your DLL’s method, and see if it makes any difference:
Hi Dave,
Thanks for reply. Setting CurrentDirectory to $fileDirectory did not solved the issue. C/C++ dll’s(dependent dll’s) are not yet accessed by the .Net dll. If I place C/C++ dll’s in the same folder as powershell.exe, then they are accessible. I don’t want to disturb powershell.exe folder structure, so looking out for correct way so that these C/C++ dll’s are picked up by .Net dll while script is executing.