C# WinRT component fails in UserControl constructor calling from WinJS - multithreading

We are building a WinRT application with JavaScript (WinJS) that accesses REST/JSON web services via C# WinRT Component library. In the component library we have a Logon control (much like WebAuthenticationBroker) that allowes us to use ACS logon with our REST services.
Application Layers:
Client (JS)
WinRT component dll (C#)
C# ClassLibrary dll (C#)
UserControl (Xaml/C#, contains WebView)
The problem: When trying to create the logon control, the WinRT throws "HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)" exception (when entering the UserControl's constructor) even if I call it via Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher (recommended in MSDN article I found about WinJS/C++ component).
If I call it from a Xaml/C# client, the code works with or without the Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher.RunAsync().
I've tried to google this and also read all the UserControl, Dispatcher and WinJS documentation but I have not found anything relevant. Is this a known problem and could someone suggest a workaround?
Since I'm a first time poster, please be gentle :-) Any help is extremely welcome!

Xaml-based WinRT controls cannot be used in Javascript-based WinRT projects. You can use any WinRT class library, but not Xaml controls inside them.
If you still want to combine HTML-Javascript with Xaml, I would recommend creating a Xaml-based project, and wrapping your HTML UI in a WebView control.

I wouldn't expect it to be possible to use WinRT/XAML UI in an HTML/WinJS app. You would probably need to use some callbacks to request the UI to be created in a WinJS app/component library instead of the XAML one.

Related

ServiceStack Self-Hosted app and NotifyIcon

I have a working Windows Service (on Windows 10, .Net471) that implements ServiceStack AppSelfHost Base and provides a number of (so far) simple REST APIs. I'd like to add NotifyIcon type of functionality, so that the service displays an icon in the Windows Notification Area for all users on the machine, and right-clicking that icon displays a context menu of actions. I've tried implementing the NotifyIcon WinForms component in the AppHost.Configure method, naively following the instructions here NotifyIcon. This naive implementation does not work; when the System.Windows.Forms.Application.Run() is called, the NotifyIcon functionality works, but the .Run() call (in AppHost.Configure) does not return, and then no ServiceStack REST APIs work; if I comment out the call to .Run(), the ServiceStack code works, but NotifyIcon functionality does not. Can anyone please point me towards links or examples that show a self-hosted ServiceStack implementation that provides an icon in the Windows Notification area, and a context menu of functions that appear when the icon is right-clicked? TIA!

Open new window in WinJS Universal App

I am trying to figure out how to open a new window from within my WinJS Universal Windows app.
I've found plenty of examples of how to do this in a XAML Universal App using Windows.ApplicationModel.Core.CoreApplication.CreateNewView, but I can't seem to find a reference to that method within the WinJS or Windows namespaces in my Javascript. According to code-hints when I am writing my Javascript, I am able to see that there is a Windows.ApplicationModel.Core namespace, but the only class that appears in it is AppListEntry. No CoreApplication or any of the other classes that the documentation suggests should be there.
I've been digging around trying to find out if this is possible. I haven't been able to find any resources that specifically say you can't perform this action in a WinJS app, but I haven't found any examples that show how to do this either.
I downloaded the Universal Windows App Samples, and they do have a MultipleViews project there, but it doesn't include a JS build.
Does anyone know if it is possible to open a new window from within a WinJS app?
What happens when you do:
window.open("http://www.w3schools.com");
Or set target as "_blank" as you would do for an HTML window?
Visit W3Schools
There is tool written for the Intel XDK (A Cordova product), which can work around some of the limitations of JS running on Windows. Here is a link: https://github.com/xmnboy/xdk-win8x-compat.js . It may resolve some of these issues.
When I was writing Win8 JS apps, I know that I could wrap a function in:
MSApp.execUnsafeLocalFunction(unsafeFunction);
(documentation), which would allow me to inject JS to the DOM. You may be able to write a function that creates a new window with that.

Xpages Starter Kit Server.jss

I have a lot of SSJS codes on many NSF, most of the NSF use the same functions code.
So I tried to make a Library with all the common functions, I'm trying to use the Xpages Starter Kit, because it claims to have SSJS Library Provider and implicit global SSJS.
There theres a Server.jss file that says "//your SSJS library code goes here".
I put some simple code there just to test it, but I couldn't figure out how it works.
print("Hello World");
function hello(){
print("hello");
}
How it works?
I made and install the update site, put the <openntf:canvas/> on a xpage. The canvas tag is created, but nothing seems to happen with the SSJS. Nothing on server console, and if a try to call hello function an error is raised.
How can I access SSJS functions on the library?
The library id - org.openntf.xsp.starter - is defined various places in the Starter Kit. It's also there with "/" instead of "." for some contexts.
Also, double-check the library has been enabled in Xsp Properties for your application.
It's also worth looking at the Domino Debug Plugin on OpenNTF to debug your code directly in Eclipse. Also check the Help > Support > Trace and Help > Support > Log in Domino Designer for any errors for your class.

Web based Oracle Scene Builder analog

I want to provide an ability to create simple java and javafx applications to the users on my website. I've found excellent code editor (Ace) but I don't know how to provide FXML design tool to the Web users.
Is there any options?
ADD I want the users to use this interface builder without any additional requirements like Java 8 or something
How to host SceneBuilder in a web page (requires Java 8):
Build SceneBuilder from it's source.
Package it as a Browser Embedded Application.
Host your packaged application on the Internet and direct web users to its URL.
Other than using a fork of SceneBuilder for your project, I don't know of any other feasible way to provide visual FXML editing capabilities. I would certainly not recommend trying to create from scratch your own FXML visual editor written in either Java or JavaScript.

Implementing dialogs from resource

I'm currently trying to port an application from owl to vcl.
In my old projekt-file I was able to load dialogs with something like
TBatchAcDialog(TWindow* parent) : TAPDialog(parent, BATCH_DIALOG)
However, using TTaskDialog instead it doesn't support the second argument.
I have found an explanation for the user interface designer that when rightclicking on a menu you can load the first declared menu from a rc-file.
However, I don't really know how to load those dialogs as dialogs in this IDE and linking them to my classes again.
Does anyone of you know about this or could link me to an article about a similar problem? I seem to have failed finding a proper solution although implementing rc-dialogs seems to be a common problem to me.
I'm currently trying to port an application from owl to vcl.
What is your exact goal? To be able to build the application with C++ Builder, or to use VCL instead of OWL?
If you want to use VCL for the dialogs, then you cannot port them, you need to rewrite all the UI from scratch, as VCL is very different from the standard Windows dialogs.
If you want just to build the application with C++ Builder, then you can do so by upgrading to OWLNext - it is an open-source upgrade for the OWL framework and works with the modern compilers like C++ Builder and Visual C++.
You can also use OWLNext for a gradual migration to VCL - as VCL and OWL can co-exist in the same application, so you can migrate your old OWL application to C++ Builder, write any new UI in VCL, and gradually rewrite the old UI in VCL - it might be easier and safer than rewriting the whole application with VCL.
C++Builder does not have any native functionality that wraps resource dialogs in classes. You have to set that up manually in your own code if you need it. Otherwise, just use Win32 API functions like CreateDialog() when working with resource dialogs, or else redesign your UI to make use of VCL TForm windows instead of resource dialogs.
TTaskDialog is not what you think it is. It is just a wrapper for the Win32 API TaskDialogIndirect() function (Vista and later only), which is not related to what you are attempting to accomplish.

Resources