# 初始化

## 初始化

在使用 Game Chat 之前，您需要进行初始化。 请添加从控制面板确认的项目 ID。初始化 Game Chat 的方法如下：

1. 访问控制面板，并在设置菜单中确认项目 ID。
2. 要初始化实例，请使用以下代码：

* 导入 NBaseSDK 模块。

```csharp
using NBaseSDK;
```

* 创建 NBaseSDK Chat 实例。

```csharp
NBaseSDK.Chat nc = NBaseSDK.Chat.GetInstance();
```

* 使用项目 ID、区域和语言代码初始化 Game Chat。

```csharp
nc.initialize([PROJECT_ID], [REGION], [LANGUAGE]);
```

<table><thead><tr><th width="151">ID</th><th width="86">Type</th><th width="381">Description</th><th>Required</th></tr></thead><tbody><tr><td>PROJECT_ID</td><td>string</td><td>ID (Game Chat Dashboard Project ID)</td><td>O</td></tr><tr><td>REGION</td><td>string</td><td>区域（如果没有特别使用其他区域，请使用“kr”）</td><td>O</td></tr><tr><td>LANGUAGE</td><td>string</td><td>语言代码（例如 "en", "zh", "kr" 等）</td><td>O</td></tr></tbody></table>

## 错误处理

* 基本的错误处理可以通过将代码添加到以下的 try ... catch 结构中进行。

```csharp
try
{
    // 在此处编写可能会发生错误的代码。
    ...
} 
catch (InvalidOperationException e)
{
    // 在此处处理特定类型的错误。
    Console.WriteLine("InvalidOperationException: {0}", e.Message);
}
catch(Exception e)
{
    // 在此处处理一般错误。
    Console.WriteLine("Error: {0}", e.Message);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gamechat.me/basics/game-chat-v3/game-chat-zhong-wen/kai-shi-shi-yong-v3/chu-shi-hua.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
