Execute code at runtime with ASP.Net 5 - roslyn

I am using Asp.Net 5 CTP6.
I need to execute some c# code at runtime. I know there is some solution and I used some of them but I want to know how can I do this by Roslyn because of platform independency?
By the old solution that I found may be exists some problems about multi platform independency. In fact I want to run the web app on windows and Ubuntu.
Thanks

Please see the following code :
string s = #"
using .....
string a=""this is a test :)""
";
SomeMethodToRunTheCode(s);
In asp.net webform I can attach the code to an .ascx (at runtime I create a file with .ascx extension and I append the code to the file ) file then with LoadControl method I will be able to run the codes at runtime. but in the asp.net 5 ( vNext ) I do not know how can I do this.

Take a look at how razor does it https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs

Related

Logging into a specific file in Tizen?

Before asking this question I searched a lot about Logging (the terminal Debug Log) into a file for Tizen Application. I figured out some other ways to implement using several alternatives a bit complex pathway for this problem. But I want something straightforward, simple and builtin for Tizen Applications.
So here is what I want -
I will run a Tizen application written in C/C++. It will generate response logs on the terminal based on the several queries I ask to the app.
I want to save those logs into a specific file like file_name.log .
That file_name.log will be saved somewhere within my PC. Developer can change the location as my own.
Is there any command or an existing system for Tizen apps ?
Thank you in advance.
Read https://developer.tizen.org/development/guides/native-application/error-handling/system-logs about Tizen's built-in logging system.
As stated in the page, the logs can be also retrieved from the command line using sdb shell dlogutil [options...] [TAG], or simply sdb dlog [options...] [TAG]. So if you want to save the output as a file, simply do sdb dlog [-d] MY_APP > file_name.log. If this is not what you are searching for, please be more specific in your question.

How to generate Data Matrix Barcode from Nav 2015?

I searched a lot regarding the Data Matrix Code generation from Nav 2015 but could not get any proper solution for that though, i got some code from below link but still, some of the automation variables is not there in Navision, so I need you guys help on this, is there any Code Unit or any object or any other way in Nav..
http://www.barcode-soft.com/dynamics-nav-barcode.aspx
It depends on how much time you have to get the barcode.
If it's a back end job, like a report, you can call a command line tool to create the barcode and import the generated image file into a BLOB of a table variable. This table field is then printable within the report.
Another way I use in production is running a web service that creates the barcode and then let Navision create a web page that is opened in a browser window..
I suggest using a dll (written in C# with ZXING.NET) to generate it and then importing it in NAV.

Outputting SQL statements in Console app

We have our code instrumented so that in our MVC5 application, we can see the actual executed SQL. We show the information using #MiniProfiler.RenderIncludes() on our _layout.cshtml file. We configure miniprofiler as below
MiniProfiler.Settings.SqlFormatter = new InlineFormatter();
MiniProfiler.Start();
We want to use miniprofiler in our batch console applications to show the actual executed SQL. We were looking at using Windows.Miniprofiler nuGet package, but it won't work with the current miniprofiler version of 3.2.0.157.
When we try to look at the results using below code, the SQL statements are not shown.
var friendlyString = MiniProfiler.Current.Render();
Any suggestions on how to do this?

Good approach for using C++ dll for Testing

Testing team got a C++ dll from the DEV team. The methods in that dll has to be tested by passing input parameters. The expected output is already available in SQL DB.
What is the better way to test that dll and verify&validate the results ?
Few suggested to use WebService using WSDL(from dll). Once that is done, then compare the results from the webservice with existing data in SQL.
Is this a better approach or any simple approach ?
Please help.
Thanks
Ramm
Depending how you got the DLL:
In case you have the DLL header file and .LIB create a new project and LINK to the DLL
if you don't have the LIB and the header: Load the library using appropriate Windows API
The second approach uses LoadLibraryEx/GetProcAddress - http://msdn.microsoft.com/en-US/library/ms684179%28v=vs.85%29.aspx and http://msdn.microsoft.com/en-US/library/ms683212%28v=vs.85%29.aspx and assumes you have plain methods in your DLL ... If this is not the case you might need to fall back to 1.
then
Write code to execute the methods in the DLL
Write code to load the expected output from the SQL DB (whatever that might be)
Write code to compare the output of those two...
Basically these are the steps, of course you can refine.

Building a Native Client app from nothing

What does it take to build a Native Client app from scratch? I have looked into the documentation, and fiddled with several apps, however, I am now moving onto making my own app and I don't see anything related to creating the foundation of a native client app.
Depending on the version of the SDK you want to use, you have a couple of options.
Pepper 16 and 17: use init_project.py or use an example as a starting point
If you are using pepper_16 or pepper_17, you will find a Python script init_project.py in the project_templates in the SDK. It will setup up a complete set of files (.cc, .html, .nmf) with comments indicating where you need to add code. Run python init_project.py -h to see what options it accepts. Additional documentation can be found at https://developers.google.com/native-client/pepper17/devguide/tutorial.
Pepper 18 and newer: use an example as the starting point
If you are using pepper_18 or newer, init_project.py is no longer included. Instead you can copy a very small example from the examples directory (e.g., hello_world_glibc or hello_world_newlib for C or hello_world_interactive for C++) and use that as a starting point.
Writing completely from scratch
If you want to write your app completely from scratch, first ensure that the SDK is working by compiling and running a few of the examples. Then a good next step is to look at the classes pp::Module and pp:Instance, which your app will need to implement.
On the HTML side, write a simple page with the EMBED element for the Native Client module. Then add the JavaScript event handlers for loadstart, progress, error, abort, load, loadend, and message and have the handlers write the event data to, e.g., the JavaScript console, so that it's possible to tell what went wrong if the Native Client module didn't load. The load_progress example shows how to do this.
Next, create the manifest file (.nmf). From pepper_18 and onwards you can use the generate_nmf.py script found in the tools/ directory for this. If you want to write it from scratch, the examples provide examples both for using newlib and glibc (the two Standard C librares currently supported). See hello_world_newlib/ and hello_world_glibc/, respectively.
If you haven't used a gcc-family compiler before, it is also a good idea to look at the Makefile for some of the examples to see what compiler and linker flags to use. Compiling both for 32-bit and 64-bit right from the beginning is recommended.
Easiest way is to follow the quick start doc at https://developers.google.com/native-client/pepper18/quick-start, in particular steps 5-7 of the tutorial ( https://developers.google.com/native-client/pepper18/devguide/tutorial ) which seems to be what you are asking about.