You are viewing limited content. For full access, please sign in.

Question

Question

Unable to find RepositoryConnection when trying to grab an existing session from the Client using the SDK

SDK
asked on August 7, 2014 Show version history

// Retrieve the LFSO connection for a client connection
public static LFDatabase LFSODB()
{
	ClientManager lfclient = new ClientManager();

        // Find an existing client instance that is logged in to the repository
        IEnumerable<ClientInstance> clients = lfclient.GetAllClientInstances();
        foreach (ClientInstance _client in clients)
	{
	        IEnumerable<RepositoryConnection> repos = _client.RepositoryConnections;
		foreach (RepositoryConnection repo in repos)
	        {
		// Retrieve the serialized connection string and use it to initialize the LFSO connection object
		        string strSerializedConnection = repo.GetConnectionString();
			LFConnection lfsoconn = new LFConnection();
                        lfsoconn.CloneFromSerializedConnectionString(strSerializedConnection);
			LFDatabase lfdb = lfsoconn.Database;
		        return lfdb;
		}
	}
	return null;
}

 Above is the code I am using. I have an opened client and I am logged in. I am using ClientAutomation & LFSO91Lib. I am trying to do this in a service application. It runs perfectly fine when I am running it in a console application. What is going wrong?

0 0

Replies

replied on September 20, 2014

Hi Mohammad -

When using Client Access, we have found that you have to run Visual Studio as an administrator (ie. Run As...), otherwise the LF Windows are not visible to the IDE. If you launch the LF window manually, that also have to be as an administrator.

Bill

2 0
replied on August 7, 2014

Your service doesn't have access to the client because a process running as a service has its own window session that is separate from the window session that the client is running in. In other words, there could be multiple people logged into the machine, which session's client would the service be accessing? You need to use a different method like a helper process to retrieve the serialized connection string and pass it to your service.

0 0
replied on August 7, 2014

It needs to be connected to the current windows user. So GetAllClientInstances() is only looking under the scope of service's own session?

0 0
replied on August 7, 2014

I think my previous post is incorrect. Does it work if your service is running as the same user as LF.exe? Internally, CAT uses the IRunningObjectsTable service to register each instance of the client.

0 0
replied on August 7, 2014

It still doesn't detect the session.

0 0
replied on August 7, 2014

I tried it myself with a sample service and it looks like you need to write a helper process that uses CAT to retrieve the serialized connection string.

0 0
replied on August 15, 2014

Hi Mohammad, 

 

If your question has been answered, please let us know by clicking the "This answered my question" button on the response.

 

If you still need assistance with this matter, just update this thread. Thanks!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.