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 - Dynamic load of assembly problem

Reply
 
Old 09-27-2007   #1 (permalink)
Kostadin Georgiev


 
 

Dynamic load of assembly problem

I'm writing a cmdlet that communicates with a web service. I have generated a
web service proxy dll and a serialization assembly for it. But when the
cmdlet tries to load that dlls at runtime it fails. This is because the
loader believes that its Appbsae directory is the powershell one -
file:///C:/WINDOWS/system32/windowspowershell/v1.0/
As far I've found two "bad" solutions for that problem:
1. GAC the assemblies
2. Copy them to the powershell directory

Is there a better solution for that problem, maybe some way to change the
directories being searched?

Thanks,
Kostadin

My System SpecsSystem Spec
Old 09-28-2007   #2 (permalink)
Marco Shaw


 
 

Re: Dynamic load of assembly problem

Kostadin Georgiev wrote:
Quote:

> I'm writing a cmdlet that communicates with a web service. I have generated a
> web service proxy dll and a serialization assembly for it. But when the
> cmdlet tries to load that dlls at runtime it fails. This is because the
> loader believes that its Appbsae directory is the powershell one -
> file:///C:/WINDOWS/system32/windowspowershell/v1.0/
> As far I've found two "bad" solutions for that problem:
> 1. GAC the assemblies
> 2. Copy them to the powershell directory
>
> Is there a better solution for that problem, maybe some way to change the
> directories being searched?
>
> Thanks,
> Kostadin

I hate to see something go unanswered. Are you able to share your code?

(Perhaps check http://www.thescripts.com/forum/thread248203.html)

Marco

--
----------------
PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 09-28-2007   #3 (permalink)
RichS


 
 

RE: Dynamic load of assembly problem

How are you loading the assemblies? have you tried

[reflection.assembly]::LoadFile(path_to_dll)
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Kostadin Georgiev" wrote:
Quote:

> I'm writing a cmdlet that communicates with a web service. I have generated a
> web service proxy dll and a serialization assembly for it. But when the
> cmdlet tries to load that dlls at runtime it fails. This is because the
> loader believes that its Appbsae directory is the powershell one -
> file:///C:/WINDOWS/system32/windowspowershell/v1.0/
> As far I've found two "bad" solutions for that problem:
> 1. GAC the assemblies
> 2. Copy them to the powershell directory
>
> Is there a better solution for that problem, maybe some way to change the
> directories being searched?
>
> Thanks,
> Kostadin
My System SpecsSystem Spec
Old 09-29-2007   #4 (permalink)
Oisin Grehan


 
 

Re: Dynamic load of assembly problem

On Sep 27, 8:40 am, Kostadin Georgiev
<KostadinGeorg...@xxxxxx> wrote:
Quote:

> I'm writing a cmdlet that communicates with a web service. I have generated a
> web service proxy dll and a serialization assembly for it. But when the
> cmdlet tries to load that dlls at runtime it fails. This is because the
> loader believes that its Appbsae directory is the powershell one -
> file:///C:/WINDOWS/system32/windowspowershell/v1.0/
> As far I've found two "bad" solutions for that problem:
> 1. GAC the assemblies
> 2. Copy them to the powershell directory
>
> Is there a better solution for that problem, maybe some way to change the
> directories being searched?
>
> Thanks,
> Kostadin
This is a confusing and difficult area to get to grips with at times;
even when you _do_ get your assembly loaded, there may be additional
constraints. I recommend you digest some of the inimitable Suzanne
Cook's (a CLR dev) excellent blog entries on the subject:

"LoadFile vs. LoadFrom"
http://blogs.msdn.com/suzcook/archiv...-loadfrom.aspx

"Binding Contexts"
http://blogs.msdn.com/suzcook/archiv.../29/57143.aspx

"Switching to the Load Context"
http://blogs.msdn.com/suzcook/archiv.../13/57180.aspx

To be read in roughly that order. ;-)

Hope this helps,

- Oisin / x0n

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Can't load assembly Software
Exception: Could not load file or assembly or one of its dependenc PowerShell
Problem loading an assembly referencing a non-.NET dll 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