Compiling C# on the fly
#1
Posted 26 January 2011 - 08:57 AM
#2
Posted 26 January 2011 - 09:14 AM
#3
Posted 26 January 2011 - 09:47 AM
In addition to Chris' suggestion (externally running command line C# compiler csc.exe), you can also have a look at Microsoft Knowledge Base article 304655: How to programmatically compile code using C# compiler (includes 'button_click' sample code).I wonder if there's any (reliable) way to compile parts of C# code and then send the PE to feed the board, *without* having/using VS installed.
The PE file is produced from the source assembly (.dll or .exe) by MetaDataProcessor.exe, which is a part of .NET Micro Framework SDK. It has numerous command line parameters, you can build a sample solution in Visual Studio to see its usage in Output window, it is basically in form metadataprocessor.exe -loadhints {assembly reference} -endian {le|be} -parse {source assembly} -minimize -compile {target PE}.Once the user has finished writing, he should press a button that compiles the code in PE format.
In more advanced scenarios, you could also use/generate .sln or .proj file and invoke MSBuild.exe (part of .NET Framework) with appropriate parameters. If you are interested in build details, you can inspect *.targets files in %Program Files%\MSBuild\Microsoft\.NET Micro Framework\v4.1\ directory.
#4
Posted 26 January 2011 - 11:08 AM
#5
Posted 26 January 2011 - 11:48 AM
#6
Posted 26 January 2011 - 07:09 PM
By the way, I'm afraid about the potential consequences: if something's going wrong, will be the user able to rescue the board control?
As long as the user hasn't changed the USB configuration on the board (using the UsbClient feature of .NET MF) then there's an easy backup: just hold the pushbutton on your Netduino while plugging it in and you can ERASE the current app via MFDeploy. Worst case scenario, you can also erase the board completely and reflash .NET MF.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users