Skip to content


Repository files navigation


This project is an Astrodienst Swiss Ephemeris ( .Net portage from C (version 2.06) to C# in a PCL/.Net Core project for cross platform usage.

Since version, the nuget package includes 2 versions:

  • .Net 4.0
  • .Net Standard 1.0

The programs SweMini and SweTest are availables in 2 versions:

  • .Net 4.0
  • .Net Core App 1.0

These programs are available in the "" of each release.


A new repos was created containing lot of sample applications for using the library on different application types.

Works with async

For working with the async context read the this paragraph.

Breaking changes


Since .NETStandard are supported, this library is not compiled on PCL version. Only 2 version are available: .NET 4.0 for old legacy application, .NETStandard 1.0 for the new framework.

.NETStandard 1.0 is supported by VS 2015.3 and VS 2017, so PCL are not usefull.

The new repos of contains applications using only this version of the library.


Since some libraries don't supports the "Windows-1252" code page. In this case, the default encoding become "UTF-8".

You can change the default encoding by assigning the static property SwissEphNet.SwissEph.DefaultEncoding.

Thread Local Storage (TLS) support

Since version 2.03.00 the Swiss Ephemeris library supports the Thread-Local Storage (TLS), which allows to run several calculations simultaneously with multiple threads.

As SwissEphNet is build an object SwissEphNet.SwissEph, it always supports multiple calculations. You just need create one SwissEphNet.SwissEph per thread. On other hand it's still not thread-safe, so don't access the same SwissEphNet.SwissEph instance from multiple threads.

Projects splitted (2014-06-06)

From now the SweNet et SwephNet projects are moved to a new repos SwephNet.

SwephNet is the next version of SwissEph, with a better .Net implementation. The two projects will continue to exist in parallel :

  • SwissEphNet : is the direct C to C# portage of the Swiss Ephemeris.
  • SwephNet : is the full .Net implementation of the Swiss Ephemeris.


Now SwissEphNet is available as a Nuget package: Install-Package SwissEphNet

Or you can download the binaries in the last release.

SwissEphNet is a Portable Class Library with support for .Net 4+, Silverlight 5, Windows Phone 8, Windows Store apps, Xamarin.Android and Xamarin.iOS.

Create an instance

SwissEphNet.SwissEph is IDisposable so you can use it with an using statement.

using (var sweph = new SwissEphNet.SwissEph()) {
    // Use it

Loading files

SwissEphNet is a Portable Classe Library and we don't have file access.

As Swiss Ephemeris use some data files, an event exists for loading the files required.

using (var sweph = new SwissEphNet.SwissEph()) {
    sweph.OnLoadFile += (s, e) => {
        // Loading file
    // Use it

For more information read this page.

Continuous Integration in AppVeyor

The library is built and tested continuously with AppVeyor CI.

Current build status of the branch master : Build status

Beware the build version number in AppVeyor is not the same than the published library.

Firsts steps

Our first step is to convert the C source code to C#, and provide some conversions from C like string format.


We implements (x)printf base methods with the Richard Prinz project ( with somes updates.


We implements (x)scanf base methods with the Jonathan Wood project ( with some updates and unit tests.

C conversion

All C files are included in the partial class 'SwissEph' each in a specific file.

All exported constants are defined as public in the class.

All exported methods are defined as public in the class.

The other elements are declared as private.

The compilation configuration use pre-processor constants. We remove lot of them in our case. The other are converted as constants, not pre-processor.

Seconds steps

Now the portage is correct, so we create a new project ( with a new interface more adapted to the .Net guidelines.


The Swiss Ephemeris Programming Interface documentation :

Last code source of Swiss Ephemeris from

The NASA JPL resouces :,


Swiss Ephemeris for .Net. A Swiss Ephemeris portage for .Net.







No packages published