Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - using external assemblies in Powershell scripts

Reply
 
Old 08-10-2007   #1 (permalink)
Romu


 
 

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.

My System SpecsSystem Spec
Old 08-10-2007   #2 (permalink)
Oisin Grehan


 
 

Re: using external assemblies in Powershell scripts

On Aug 10, 6:14 am, Romu <R...@discussions.microsoft.com> wrote:
> 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.


This may help: http://blogs.msdn.com/junfeng/archiv...31/423340.aspx

- Oisin

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Powershell Assemblies PowerShell
Powershell scripts not working with Vista powershell PowerShell
Powershell assemblies PowerShell
Powershell and loading dependent assemblies PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46