S
S
Sergey K2018-11-21 21:14:17
PowerShell
Sergey K, 2018-11-21 21:14:17

How to include a library in Powershell so that it uses its own config file?

Hello,
I can’t understand how you can connect the library to the script so that it uses its own config file.
There is this code:

$FBToolsShare = "<path_to_share>"
Import-Module($(Join-Path $FBToolsShare -ChildPath "<dll_name>"))
[appdomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $(Join-Path $FBToolsShare -ChildPath "<dll_name>.config"))

$CRMClient = New-Object CRMServiceClient -ArgumentList "<name_endpoint>"

It throws an error
New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find endpoint element with name '<name_endpoint>' and contract '<name_contract>' 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."

The library in the configuration file has the necessary endpoint, but it simply does not see this file, apparently.
I tried to do the same in C#, after replacing the contents of the configuration file with the contents from the library's configuration file, and it all worked.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
azarij, 2018-11-21
@AceLightning

Isn't this the same issue being discussed here ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question