Jump to content
Welcome to our new Citrix community!
  • 0

Error SDK Citrix Cloud Connector From Visual C#


Henrry Ortiz

Question

Hi, I'm trying to make a little script in visual c# to get sessions on a c# console , but when i execute this from visual:

 

                using (Runspace runspace = RunspaceFactory.CreateRunspace())

                {

                    runspace.Open();

                    PowerShell ps = PowerShell.Create();

                    ps.Runspace = runspace;

                    PSSnapInException psex;

                    runspace.RunspaceConfiguration.AddPSSnapIn("Citrix.Broker.Admin.V2", out psex);

                    Pipeline pipeline = runspace.CreatePipeline();

 

                    Command getSession = new Command("Get-BrokerSession");

                    pipeline.Commands.Add(getSession);

 

                    //This line below is where the exception occurs.

                    Collection<PSObject> output = pipeline.Invoke();

 

                    foreach (PSObject x in output)

                    {

                        Console.Write(x.ToString());

                    }

                }

 

I have this error:

 

Unhandled Exception: System.Management.Automation.CmdletInvocationException: Failed to connect to back-end server 'localhost' on port 80 using binding WSHttp. The server may be off-line or may not be running the appropriate service ---> Citrix.Broker.Admin.SDK.SdkOperationException: Failed to connect to back-end server 'localhost' on port 80 using binding WSHttp. The server may be off-line or may not be running the appropriate service ---> System.ServiceModel.CommunicationException: Failed to connect to back-end server 'localhost' on port 80 using binding WSHttp. The server may be off-line or may not be running the appropriate service ---> System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://localhost/Citrix/BrokerAdminService/v2 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---

 

I have installed the SDK http://download.apps.cloud.com/CitrixPoshSdk.exe

I have installed Visual Studio on Cloud Connector and run on cloud connector.

 

If i run the commands from powershell, no problem, just only from visual generating the execuatble and running.

Link to comment

4 answers to this question

Recommended Posts

  • 0

This question was posted quite a long time ago but I am facing the same problem with Citrix Cloud today. Can anyone know the reason? I am seriously failing because of this issue. With the Citrix Cloud I am having Cloud API Key and Secret. Moreover I am leveraging that profile to authenticate (XDAuthenticate). The final command (Get-BrokerSession) is working well with that through PowerShell ISE but not with the .net (C#) RunSpace and Automation module. I am getting same above error message.

 

Link to comment
  • 0
On 2/22/2020 at 5:23 PM, Brijesh Shah1709161754 said:

This question was posted quite a long time ago but I am facing the same problem with Citrix Cloud today. Can anyone know the reason? I am seriously failing because of this issue. With the Citrix Cloud I am having Cloud API Key and Secret. Moreover I am leveraging that profile to authenticate (XDAuthenticate). The final command (Get-BrokerSession) is working well with that through PowerShell ISE but not with the .net (C#) RunSpace and Automation module. I am getting same above error message.

 

Hey @Brijesh Shah1709161754, Did you resolve this? I've got the same issue. I might rebuild my project for x64 instead of any CPU, but that will take quite a bit of work to address, Was hoping to find a quick and easy solution. Using Citrix.Broker.Admin.V2 and the cmdlets from Studio works, but when you remove that and use the ones from Cloud Remote SDK, it fails for Get-BrokerSession, even if it successfully does the Set-XDCredentials, Get-XDAuthentication, Get-XDCredentials. Cheers, Jeremy

Link to comment
  • 0

Yep, confirmation for anyone that finds this as @Henrry Ortiz points out that the solution is you must build your projects with the platform target set to x64 when using the Remote PowerShell SDK. For reference I am using version 7.30. Many hours of debugging and researching to trace that. Glad I came across this thread. Terrible documentation from Citrix too for those of us who are not developers.

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...