Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PSSnapin Assembly .config file

21 views
Skip to first unread message

Hayato Iriumi

unread,
Mar 25, 2008, 5:03:56 PM3/25/08
to
Hello, folks. I have a question regarding a PSSnapin assembly .config
file.

What I want to be able to do is to make a call to a Web Service from
my custom Cmdlet via Service Reference, but I haven't been able to so
far.

So I'm developing a custom Cmdlet that makes calls to a Web Service. I
created a Service Reference to the Web Service in VS 2008. At that
point, VS 2008 creates app.config that has all kinds of settings for
the proxy. When I compile it, obviously VS 2008 copies the file to bin
directory and names it after the Assembly name such as
MyCmdlet.dll.config.

I was able to add my custom Cmdlet to PowerShell and tried to execute
it. I got the following error message even before I was able to make a
call to the Web Service.

"Could not find endpoint element with name 'TestServiceSoap' and
contract 'TestService.TestServiceSoap' in the ServiceModel client
configuration section. This might be because no configuration file was
found for your application, or because no endpoint element matching
this name could be found in the client element."

This means MyCmdlet.dll.config was not loaded by PowerShell, so I
tried something like this....

Configuration _conf =
ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExecutingAssembly().Location);

I could get values from <appSettings> section using the Configuration
class, but that's how far I could go. None of the
<system.servicesModel> was loaded so I could make a call to the Web
Service.

My question is how could I load the whole MyCmdlet.dll.config so that
I can make a call to the Web Service via Service Reference?

Hayato Iriumi

unread,
Mar 25, 2008, 6:16:34 PM3/25/08
to
I haven't been able to resolve the issue when I use Services
Reference, but when I use Web Reference, since it doesn't depend on
settings in .config file, it works fine.

On Mar 25, 2:03 pm, Hayato Iriumi <hiri...@gmail.com> wrote:
> Hello, folks. I have a question regarding a PSSnapin assembly .config
> file.
>
> What I want to be able to do is to make a call to a Web Service from
> my custom Cmdlet via Service Reference, but I haven't been able to so
> far.
>
> So I'm developing a custom Cmdlet that makes calls to a Web Service. I
> created a Service Reference to the Web Service in VS 2008. At that
> point, VS 2008 creates app.config that has all kinds of settings for
> the proxy. When I compile it, obviously VS 2008 copies the file to bin
> directory and names it after the Assembly name such as
> MyCmdlet.dll.config.
>
> I was able to add my custom Cmdlet to PowerShell and tried to execute
> it. I got the following error message even before I was able to make a
> call to the Web Service.
>
> "Could not find endpoint element with name 'TestServiceSoap' and
> contract 'TestService.TestServiceSoap' in the ServiceModel client
> configuration section. This might be because no configuration file was
> found for your application, or because no endpoint element matching
> this name could be found in the client element."
>
> This means MyCmdlet.dll.config was not loaded by PowerShell, so I
> tried something like this....
>
> Configuration _conf =

> ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExe­cutingAssembly().Location);

Hayato Iriumi

unread,
Mar 25, 2008, 6:18:14 PM3/25/08
to
Crap, my English was bad in my previous post. I was saying that it
works when I set Web Reference instead of Services Reference becuase
Web Reference doesn't depend on settings in dll.config file.

Just FYI

Karl Mitschke

unread,
Mar 26, 2008, 9:49:09 AM3/26/08
to
Hello Hayato,

I understood you both ways :)

Karl


Oisin (x0n) Grehan [MVP]

unread,
Mar 26, 2008, 10:12:15 AM3/26/08
to
> > settings in .config file, it works fine.- Hide quoted text -
>
> - Show quoted text -

I'm pretty sure there's no way to load a custom configuration file for
WCF (like you could do for 2.0 remoting), but I'd say that's something
that will be added in the future. If you hoist your service into a new
appdomain, you can specify an AppConfigSetup path, but this is a bit
ugly. However, this guy:

http://weblogs.asp.net/cibrax/archive/2007/10/19/loading-the-wcf-configuration-from-different-files-on-the-client-side.aspx

...has an answer for you.

Hope this helps,

- Oisin

Hayato Iriumi

unread,
Apr 11, 2008, 6:09:32 PM4/11/08
to
Hi, Oisin.
Hmm, having to create a separate AppDomain sounds quite ugly as you
pointed out. I guess I will just go with the traditional Web Reference
then.

Thanks!

On Mar 26, 7:12 am, "Oisin (x0n) Grehan [MVP]" <ois...@gmail.com>
wrote:


> On Mar 25, 6:18 pm,HayatoIriumi<hiri...@gmail.com> wrote:
>
> > Crap, my English was bad in my previous post. I was saying that it
> > works when I set Web Reference instead of Services Reference becuase
> > Web Reference doesn't depend on settings in dll.config file.
>
> > Just FYI
>

> > On Mar 25, 3:16 pm,HayatoIriumi<hiri...@gmail.com> wrote:
>
> > > I haven't been able to resolve the issue when I use Services
> > > Reference, but when I use Web Reference, since it doesn't depend on
> > > settings in .config file, it works fine.- Hide quoted text -
>
> > - Show quoted text -
>
> I'm pretty sure there's no way to load a custom configuration file for
> WCF (like you could do for 2.0 remoting), but I'd say that's something
> that will be added in the future. If you hoist your service into a new
> appdomain, you can specify an AppConfigSetup path, but this is a bit
> ugly. However, this guy:
>

> http://weblogs.asp.net/cibrax/archive/2007/10/19/loading-the-wcf-conf...

0 new messages