# TestCluster.TryGetGrainContext(GrainId, IGrainContext?)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L181-L193)

```csharp
public bool TryGetGrainContext(GrainId grainId, out IGrainContext? grainContext)
```

Attempts to find the [IGrainContext](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/) for the grain with the specified `grainId` by searching all silos in the cluster.

### Parameters

- `grainId` (`GrainId`): The ID of the grain to find.
- `grainContext` (`IGrainContext?`): When this method returns, contains the grain context if found; otherwise, `null`.

### Returns

`true` if the grain was found in one of the silos; otherwise, `false`.
