---
product: Chilkat
product_version: 11.7.0
language: csharp
language_label: C#
document: language guide
---
> Chilkat 11.7.0 · language=csharp · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/classes/<Class>.md`

# Chilkat for C# — language guide — v11.7.0

## 1. Which Chilkat binding this is

This is **Chilkat for .NET** used from C#: namespace `Chilkat`, classes `Chilkat.Http`, `Chilkat.Zip`, `Chilkat.BinData`, … (no `Ck` prefix). The same assembly serves VB.NET and every other .NET language. Two packages exist for the two runtimes; the API is identical:

| Runtime | Package | Platforms |
|---|---|---|
| .NET 6 and later (.NET 6/7/8/9/10) | NuGet **`ChilkatDnCore`** | Windows, Linux, macOS, x64 and ARM64 |
| .NET Core 3.1 | NuGet `ChilkatDnCore31` | Windows, Linux, macOS |
| .NET Framework 2.0–4.8 | NuGet or ZIP, x64 or win32 to match the process | Windows only |

Do not confuse this with the Chilkat **ActiveX** (`Chilkat.Http` ProgID, used from VB6/VBScript/VBA): different distribution, COM-style usage. From C#, use the .NET assembly.

## 2. Install and requirements

```
dotnet add package ChilkatDnCore
```

Details, the .NET Framework packages and common errors: [https://www.chilkatsoft.com/dotnet.asp](https://www.chilkatsoft.com/dotnet.asp). No other dependencies: Chilkat does not use OpenSSL, libcurl or any system library.

## 3. Unlocking and object creation

```csharp
// Required once per process, before any other Chilkat object. Any string unlocks a 30-day trial.
Chilkat.Global glob = new Chilkat.Global();
bool success = glob.UnlockBundle("Anything for 30-day trial");
if (!success)
{
    Console.WriteLine(glob.LastErrorText);
    return;
}

Chilkat.Http http = new Chilkat.Http();
```

- Unlocking only sets a flag in memory: no license files, no network call, so the call is repeated each time the program runs. Extra calls are harmless no-ops; the `Global` object can be discarded afterwards.
- If a program forgets to unlock, Chilkat runs in trial mode and stops working when the trial expires — always include the call, and use the purchased unlock code in production.
- `UnlockBundle` unlocks every class; per-class `UnlockComponent` methods exist only in old code.

## 4. Error model

Chilkat methods **do not throw** for Chilkat-level failures. How a method reports failure depends on its return type and is stated in the note under each method on the class page:

| Return type | On failure |
|---|---|
| `bool` status method | returns `false`; `LastErrorText` says why |
| `string` | returns `null` |
| `byte[]` | returns an empty byte array |
| object (e.g. `HttpResponse`) | returns `null` |
| `int` | check `LastMethodSuccess` |

Every object has `LastErrorText` (multi-line diagnostic of the last call, also populated on success), `LastErrorXml`/`LastErrorHtml`, `LastMethodSuccess`, `VerboseLogging` and `DebugLogFilePath`. Properties are real .NET properties (`http.Port = 443;`). Exceptions do occur for .NET-level problems (a null argument, a missing native library).

Literals in C#: true is `true`, false is `false`, null/none is `null`.

## 5. Strings, bytes and encodings

- Strings are .NET `string`. A `charset` argument (`"utf-8"`, `"iso-8859-1"`) names the encoding of the *bytes* being produced or read, not of the .NET string.
- Binary data is `byte[]` in and out. Larger or reusable binary data goes through `Chilkat.BinData` (methods ending in `Bd`); text through `Chilkat.StringBuilder` (methods ending in `Sb`). Naming: `Str` → string, `Bd` → BinData, `Sb` → StringBuilder, `File` → a file path.
- Methods with `2`/`3` suffixes or `Quick*` prefixes are distinct members, not overloads.

## 6. Object lifetime and threading

Chilkat .NET objects are ordinary managed objects wrapping a native object. They are released by the garbage collector; for deterministic release (large `BinData`, open sockets) call `Dispose()` — see [https://www.chilkatsoft.com/csharp_dispose_chilkat.asp](https://www.chilkatsoft.com/csharp_dispose_chilkat.asp).

A Chilkat object may be used from any thread, but **one object must not be used by two threads at the same time**: create one object per thread or protect it with a lock. Objects are independent — there is no shared global state other than the unlock flag and the few `Global` settings.

## 7. Progress callbacks and async

Progress events are supported: see the "Events and callbacks" section of a class page for the event list and how to attach a handler in this binding (AbortCheck, PercentDone, ProgressInfo and TaskCompleted are the standard ones). Every method with an "Async variant" line also has an `XAsync` twin that returns a `Task` immediately; poll `Finished` or use the `TaskCompleted` event, then read the result from the task. No new Async methods are added from 11.7.0 on. .NET events are attached with `+=` on the object's event (`http.OnPercentDone += …`); the wiring differs slightly between .NET Framework and modern .NET — see [https://www.chilkatsoft.com/csharp_dotnet_core_event_callbacks.asp](https://www.chilkatsoft.com/csharp_dotnet_core_event_callbacks.asp). Chilkat's `*Async` methods return a Chilkat `Task`, not a .NET `System.Threading.Tasks.Task`; they are not awaitable — see [https://www.chilkatsoft.com/chilkat_async_csharp.asp](https://www.chilkatsoft.com/chilkat_async_csharp.asp).

## 8. Common mistakes an AI makes with this binding

1. Writing `CkHttp` / `chilkat.CkHttp` (that is the C++/Java/Python spelling) or ActiveX `CreateObject` code. In .NET it is `new Chilkat.Http()`.
2. Treating a Chilkat `Task` as an awaitable .NET `Task`.
3. Wrapping Chilkat calls in `try/catch` and expecting a Chilkat failure to throw — check the return value instead.
4. Omitting `Global.UnlockBundle` (the program runs in trial mode and stops working after 30 days).
5. Inventing members by analogy with other libraries. If a member is not on the class page, it does not exist — look it up rather than guessing.
6. Using deprecated members that older examples still show. The class page lists each one with its replacement; `deprecated.md` lists them all.
7. Ignoring the failure path. Every Chilkat method reports failure (see each method's note); `LastErrorText` says why, and printing it is the first debugging step.
8. Using one Chilkat object from two threads at the same time. Create one object per thread, or protect it with a lock.

## 9. Instructions block for coding agents

Paste into `CLAUDE.md`, `.cursor/rules`, or Copilot instructions:

```
This project uses Chilkat 11.7.0 from C# (the .NET assembly: NuGet ChilkatDnCore for .NET 6+, namespace Chilkat).
- Reference: https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/ — read guide.md once, then classes/<Class>.md for each class used.
- Call new Chilkat.Global().UnlockBundle(...) once at startup.
- Classes are Chilkat.Http, Chilkat.Zip, ... (no Ck prefix); properties are .NET properties.
- Chilkat methods never throw on failure: check the bool/null/empty result and print obj.LastErrorText.
- Never use a member that is not on the class page; never use members listed as deprecated.
```

## 10. Classes

[Class index for C#](https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/index.md)
