Windows Embedded Compact 7 application development with both managed and unmanaged code - silverlight-embedded

I'm about to write an application for a embedded device with an nvidia Tagra2 running Windows Embedded Compact 7. There are the following requirements:
Query data from an internet server via a REST-API using secured HTTPS communication.
Map this data to an object model.
Display these objects in a nice Embedded Silverlight GUI.
Do some measurements with extern sensors and transmit the measured data to the server via the REST-API and secured HTTPS.
I know that Embedded Silverlight needs unmanaged C++ code. But writing the whole application in unmanaged C++ only because of the Embedded Silverlight GUI would be nightmare for me. So I think of two alternatives:
Put the logic in a managed C# DLL and access it from the unmanaged C++ executable that hosts the Embedded Silverlight GUI.
Put the Embedded Silverlight GUI in an unmanaged C++ DLL and access it from a managed C# executable hosting the rest of the logic and controling the GUI.
My questions are:
Is one of the alternatives above even possible?
Which one would be preferable? I'm a mouch better in C# than in C++.
Could you point me to resources (books, tutorials, examples) covering one of the above alternatives?

Option #2 definitely works. Have a look at this site:
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2010/WEM309
Option #1 should be possible as well, although it seems like it might be more work to try to call the managed DLL from the unmanaged code.

Related

VB6 and ASP.NET interoperability

I am supporting an ASP.NET app, which is installed on a web server and a VB6 app installed on a different app server. There is code duplication in the VB6 app and the ASP.NET app. I want to use some of the code in the ASP.NET app in VB6. I believe I have three options:
Expose the required functionality in an ASP.NET web service. The VB6 app will consume the web service.
Rewrite a small section of the vb6 app in .NET and extend the asp.net app. This will eliminate some of the code duplication.
Setup a class library for the ASP.NET app. Install the vb6 app on the web server. Expose the required functionality from the class library in a type library.
Which option is best? I believe option 2 is best.
Option 1. That leaves your shared, already-tested code on the most modern platform.
This is very hard to answer, as it varies for each company and each situation.
As a general rule, I'm very much in favor of using web services where possible, especially if multiple applications are using the same logic for the following reasons:
If I have to change the logic, I can do it in one place and fix all apps that depend on it
The same can be said for database connection strings, etc.
A bug fix can also often be fixed in one place.
I've had difficulties with a particular database that I need to deal with, where the vendor's updates tend to break their .NET adapter. Twice I had to modify/recompile a ton of apps to resolve this. Since then, we made it a policy to connect to that DB only via web services, so I'll only need to update one app in the future.
When developing mobile apps, the simple fact that we already had all our code in web services makes it that much easier to write apps that are strictly UI and leaving the business/database access logic as-is in existing web services.
All of those are pretty much "Standard" arguments for the SOA approach.
All things considered, my first recommendation, not knowing your specifics would be option #1.
There is a fourth option - a total rewrite of the VB6 app, if it's feasible, and if you can convince those who control the budgets and time allotment. Even with that, you can use the Service Oriented Architecture and split much of the logic into web services.

What is the best approach to communicate with a thermal printer within an asp.net application?

I need to use a dll to print a barcode label on a thermal printer, within an asp.net application.
I'm considering using Silverlight 5 with PInvoke, but still do not know if this is the best strategy. The problem with this alternative is that the user will not have the dlls that I need to communicate with the printer (alternative solution: http://cureos.blogspot.com.br/2011/09/pinvoke-bundling-native-dlls-in.html).
I'm on the right track?
Suggestions?
You really don't need Silverlight to leverage PInvoke. I would use Silverlight to create a richer UI (without using 3rd party ASP.NET controls). If you use a generic ASP.NET web application, you won't have any of the Silverlight security issues and you'll get full access to the .NET Framework without having to build a WCF service to communicate with Silverlight.
In the code behind, or leveraging an MVC design pattern, you can setup all the code you need to invoke the printer remotely and send the data from the client. The users don't need any DLLs because the server would handle all the communication to and from the printer.

COM Interop from ASP.NET

I'm trying to use Internet Explorer 9's JavaScript engine from my .NET library using COM interop. Whilst working fine in test code, it's failing when run within ASP.NET (on IIS).
My library is using IE's JavaScript engine to load the CoffeeScript compiler. So ideally I'd like to load the compiler once, then reuse the single IE script engine instance. I have a lock around calls to the script engine, but I think I'm still getting threading issues related to COM.
Is it possible for a COM object to be called from different .NET threads? (i.e. threads for different IIS web requests).
I'm a total COM newbie, so any advice, links, etc would be great.
As I remember IIS doesn't allow you to operate with threads i.e. create or manage them. It's not safe in web applications. What you can to do is to store your compiler in server's variable: application or session
Many COM object that you might want to use from an ASP.NET application were designed for a desktop environment, not a server environment. They may not expect to be called from different threads, for instance, or may depend on a UI message pump for synchronization.

Make Desktop Application Web Interfaceable

Is there a way to make a desktop application easily interfaceable via Web ? Meaning, can you have a way to interface with a single desktop application as if you were remote desktop'd into the machine but not? I am looking at doing this in ASP.NET or Silverlight.
I'm not sure if this is exactly what you are looking for...
If you were able to create your entire application UI in Silverlight and host it properly (in IIS or whatever) it would then be accessible from anywhere on the web. If you needed the perception of a real desktop app when running locally, you could then just make some simple app (WinForms, WPF, whatever) which contains a web browser control that could also load up the hosted Silverlight app (and just be a transparent browser). Depending on what the application is doing, you would obviously need some sort of service layer (probably in WCF) do to all of the heavy lifting and data access.
I guess the main question would be: can you accomplish everything your application needs to do in Silverlight? Since Silverlight is meant to run in a browser, it can be very limiting.
There are many solutions based on plugins. Some of the popular ones:
Citrix
Spoon
If you're ok with plugins, but only if they're common ones (flash, java), there are various solutions:
http://www.wizhelp.com/flashlight-vnc/
http://www.tightvnc.com/doc/java/README.txt (bundled java applet with TightVNC)
If you don't want plugins at all, there's an experimental HTML5/javascript VNC viewer:
http://guacamole.sourceforge.net/

Looking for LAMP equivalent to ASP.NET

We have a fairly large system involving multiple applications running on Windows, written in .NET. These include a number of web applications using ASP.NET.
We have a number of unrelated web applications written in LAMP - Linux/Apache/MySQL/Php.
The greatest advantage we've seen in ASP.NET is the ease with which code can be shared between web applications, win-form applications, windows console applications, and windows services. We have signficant code in .NET assemblies that are shared across all of these environments.
Apache/Php has some significant advantages over ASP.NET as a web programming environment, but if there is anything in it that is equivalent to .NET when it comes to integrating code that is shared across non-web applications, I'm unaware of it.
So I'm asking. Are there any technologies that provide the same sort of easy and seamless integration of shared code modules between Apache/Php and non-web applications?
The only environment with most of what you are asking for is Java.
Take the same code, stick it in a swing app, servlet, applet, heck even throw it in a mobile device, it'll work. JDBC should be a nice abstraction over most databases, so you're clear in that area.
Other than that, requesting something similar over the LAMP stack is something I believe does not exist at the moment.
Not that I know of, but I do know that Mono has a runtime module that can be plugged into Apache, effectively running an ASP.NET application under it. See here on the blog on how to do this.
Edit: As per Robert's comment, the link on that blog is broken! Here's the official link to sourceforge.net. Sorry!
Hope this helps,
Best regards,
Tom.

Resources