This topic contains 3 replies, has 2 voices, and was last updated by
December 1, 2015 at 2:38 am #32434
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.
December 1, 2015 at 5:19 am #32438MemberTopics: 9Replies: 2322Points: 0Rank: Member
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:
[Environment]::CurrentDirectory = $fileDirectory
December 1, 2015 at 8:40 pm #32480
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.
December 4, 2015 at 1:29 am #32619
Thanks Dave for suggestion fix. It worked.
Earlier error was due to some other cause
The topic ‘PowerShell - loading dll’s and their dependent components’ is closed to new replies.