Language - C Sharp Linux Mono: Difference between revisions

From Phidgets Support
No edit summary
(Redirected page to Language - C Sharp)
 
Line 1: Line 1:
[[Category:Language]]{{NoTitle}}
#REDIRECT [[Language - C Sharp]]
{|
|style="vertical-align:middle; width: 60%;"|
<font size=6>'''Language - C#'''
 
'''Linux 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|Linux|Mono}}
 
*You will also need to download and install Mono, if you haven't already. You can do this by entering the following command in the terminal:
 
<syntaxhighlight lang='bash'>
apt-get install mono-complete
</syntaxhighlight>
 
*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. Your project folder should now look like this:
 
[[Image:Csharp_linux_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>
 
An executable file will be created. Run the program using mono with the following command:
 
<syntaxhighlight lang='bash'>
mono Program.exe
</syntaxhighlight>
 
Success! The project is now using Phidgets.
 
{{Language Page What's Next}}

Latest revision as of 16:35, 15 March 2021

Redirect to: