|
|
Line 1: |
Line 1: |
| [[Category:Language]]{{NoTitle}} | | #REDIRECT [[Language - C Sharp]] |
| {|
| |
| |style="vertical-align:middle; width: 60%;"|
| |
| <font size=6>'''Language - C#'''
| |
| | |
| '''MacOS with Mono'''</font>
| |
| | |
| Welcome to using Phidgets with C#! By using C#, you will have access to the complete Phidget22 API, including events.
| |
| | |
| Mono is an open-source programming environment that aims to make Microsoft .NET applications available across all operating systems.
| |
| |{{TOC limit|2}}
| |
| |}
| |
| | |
| {{Language_-_C_Sharp_Intro|macOS|Mono}}
| |
| | |
| *You will also need to download and install [http://www.mono-project.com/download/ Mono] for macOS, if you haven't already. You can do this by entering the following command in the terminal:
| |
| | |
| *Lastly, you will need a copy of [{{SERVER}}/downloads/phidget22/libraries/windows/Phidget22-windevel.zip Phidget22.NET.dll].
| |
| | |
| {{Finding Code Samples|C#|CSharp}}
| |
| | |
| ==Using the Code Samples==
| |
| To use the code sample from the [{{server}}/?view=code_samples&lang=CSharp Code Samples] page, you can click the '''Download Example''' button to download a CS file with the sample code.
| |
| | |
| [[Image:CSharp_Sample_Code_Download.png|link=|center|800px]]
| |
| | |
| | |
| Once you have the example, you can compile and run your code:
| |
| | |
| ==Setting up a New Project==
| |
| Whether you are running our examples or adding Phidget functionality to an existing project, you'll need to configure your development environment to properly link the Phidget .NET library.
| |
| | |
| The easiest way to allow Mono to access the Phidgets .NET library is to place a copy of [{{SERVER}}/downloads/phidget22/libraries/windows/Phidget22-windevel.zip Phidget22.NET.dll] in the same folder as your program.
| |
| | |
| Finally, you need to create a configuration file. Create a new file in the same directory and name it Phidget22.NET.dll.config. Copy the content below to the file.
| |
| | |
| <syntaxhighlight lang='xml'>
| |
| <configuration>
| |
| <dllmap dll="phidget22.dll" target="/Library/Frameworks/Phidget22.framework/Versions/Current/Phidget22" />
| |
| </configuration>
| |
| </syntaxhighlight>
| |
| | |
| Your project directory should now look like this:
| |
| | |
| | |
| [[Image:Csharp_macos_mono_folder.png|link=|center]]
| |
| | |
| ==Compile and Run==
| |
| Once you are ready to run your program, open the ''Terminal'' and navigate to your project folder. Next, enter the following command:
| |
| <syntaxhighlight lang='bash'>
| |
| mcs Program.cs -r:Phidget22.NET.dll
| |
| </syntaxhighlight>
| |
| | |
| This will create an executable file called ''Program.exe''. Type in the following command to run your program:
| |
| <syntaxhighlight lang='bash'>
| |
| mono Program.exe
| |
| </syntaxhighlight>
| |
| | |
| Success! The project is now using Phidgets.
| |
| | |
| {{Language Page What's Next}}
| |