Boy I'm really struggling with this one!
So I have a WinRT Metro application that has an HTML webpage embedded into a webview within the application. In the HTML page there is a div with an href to a localhost url. I'm using this localhost call to communicate with a .NET desktop application that is listening for this url on a localhost port.
When I build the application (as debug or release) in Visual Studio (2015, update 1 or 2), the application works as expected. I can click on the div, the url is fired, and the communication is successful.
However, when I package the application and sideload it on to my machine, the functionality does not work as expected. I can click on the div...but the url is never fired.
HTML Url Example ([...] = code removed):
<a href="http://localhost:8123/?Api [...] >Click here</a>
Codebehind Navigating to HTML Example:
this.webView.Navigate(new Uri("ms-appdata:///local/index.html"));
XAML Webview Instantiation:
<WebView x:Name="webView" Grid.Row="1" ScriptNotify="webView_ScriptNotify" Grid.Column="1" Visibility="Collapsed"/>
Here are the things I've tried:
I created a WinRT app that only contained the webview and the embedded HTML page. Functionality works when built, but not when packaged.
I created a UWP app that only contained the webview and the embedded HTML page. Functionality works when built, but not when packaged.
I tried packaging the app outside of Visual Studio using the command line as described here. The functionality does not work.
I tried using different versions of Visual Studio 2015. Same results.
I tried building/packaging on different machines. Same results.
I tried to navigate to google instead of the localhost. Works.
I tried to navigate to another html file instead of the localhost. Works.
Naturally, I tried the obvious things too like cleaning, changing package name, changing settings in the Visual Studio App Packager, reboots, removing references, etc.
Has anyone experienced this before? It seems to be some sort of bug with the packaging process. Any suggestions/tips/answers are welcome! Thanks!
And just in case you're wondering, this application is intended for enterprise use only within the company I work for and will not be uploaded to the Windows Store.
Normally, you can't open a loopback connection in a UWP store app. Full stop. If you're side loading, or in an enterprise environment, there is a workaround:
https://msdn.microsoft.com/en-us/library/windows/apps/dn640582.aspx
I had a problem similar enough to this for it to be worth sharing my experience.
My app is a Universal app with a WebView control. The WebView source is a file in the app package. I define my WebView in the XAML as follows.
<WebView x:Name="myWebview" Source="ms-appx-web:///Assets/www/mylocalwebpage.html"/>
In Debug mode this works perfectly. In the first run in Release mode it does not load the page. In all subsequent runs of the Release mode app it works perfectly. It's a reproducible and incredibly frustrating bug.
My workaround is simple but effective. I use a timer to set the Source of the webview after one second. I add the following line below this.InitializeComponent();
// this worksaround a bug: on first launch in release mode the webview doesn't load
loadWebviewTimer = new Timer(loadWebview, null, 1000, Timeout.Infinite);
And then another
private async void loadWebview(object state)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
myWebview.Navigate(new Uri("ms-appx-web:///www/mylocalwebpage.html"));
});
}
It's not a pretty fix, but it works. Of interest, mylocalwebpage.html has quite a lot of javascript in it; I suspect that this is related to the problem.
Related
Hi i have wpf desktop application. I am using cefsharp.wpf chromium browser to open web page. I added cefsharp from nuget pacakge manager (version 87.1.132). it does work very well in my system (Windows 10, 64 bit os).
But when i run my exe in client's environment (windows 2012 r2,64 bit os), strange thing happens, which is browser doesn't load only when i try first time. basically i have a button & on button click i do open one window which has cefsharp chromium browser in it. so when window opens first time browser doesn't load anything. now if i close window and open it again browser will redirect to my url . only first time browser doesnt load. after first time it does load everytime until i close exe and try again.
if i close exe and open it again and try to open that window, again browser will not load anything. then i close that window and try again browser will work perfectly.
What i am doing is very simple i have browser in xaml file in one window, and in cs file when window is loaded i am assigning one address to browser and that's it.
in xaml
<cefSharp:ChromiumWebBrowser x:Name="browser" />
in xaml.cs on window loaded
browser.address = url; // i am using www.xero.com login url (which i dont think should matter as it does work second time).
can anybody tell me what's happening here ?
I have debug.log file for cefsharp which says:
[0317/231700.441:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[0317/231700.442:ERROR:alloy_main_delegate.cc(539)] Could not load locale pak for en-US
[0317/231700.537:ERROR:viz_main_impl.cc(150)] Exiting GPU process due to errors during initialization
[0317/231700.542:ERROR:browser_gpu_channel_host_factory.cc(168)] Failed to launch GPU process.
[0317/232456.104:WARNING:resource_bundle.cc(1086)] locale resources are not loaded
[0317/232456.105:WARNING:resource_bundle.cc(1086)] locale resources are not loaded
[0317/232456.421:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[0317/232456.422:ERROR:alloy_main_delegate.cc(539)] Could not load locale pak for en-US
[0317/232458.805:INFO:CONSOLE(333)] "Refused to connect to 'https://analytics.google.com/g/collect?v=2&tid=G-Q622B96ZEQ>m=2oe330&_p=609855886&sr=1366x768&_gaz=1&ul=en-us&cid=1821054078.1615983899&_s=1&dl=https%3A%2F%2Flogin.xero.com%2Fidentity%2Fuser%2Flogin%3FReturnUrl%3D%252Fidentity%252Fconnect%252Fauthorize%252Fcallback%253Fresponse_type%253Dcode%2526client_id%253DC35C4505FBEA4D31A8E5A0404FDA9E0E%2526redirect_uri%253Dhttp%25253A%25252F%25252Flocalhost%2526scope%253Dopenid%252520profile%252520email%252520files%252520accounting.transactions%252520accounting.tra...2520accounting.journals.read%252520accounting.settings%252520accounting.settings.read%252520accounting.contacts%252520accounting.contacts.read%252520accounting.attachments%252520accounting.attachments.read%252520offline_access%252520payroll.employees%252520payroll.employees.read%2526state%253D108Sydney%2526code_challenge%253D3b5GLmW09QQB-C4Sq8ud0M0sEYpqFr5_KY20way8l1U%2526code_challenge_method%253DS256&dt=Login%20%7C%20Xero%20Accounting%20Software&sid=1615983898&sct=1&seg=0&en=page_view&_fv=1&_nsi=1&_ss=1' because it violates the following Content Security Policy directive: "default-src 'self' https://browsercheck.xero.com https://edge.xero.com https://js-agent.newrelic.com https://bam.nr-data.net https://telemetry.ext.platformdevelopment.xero.com https://api.mixpanel.com https://www.googletagmanager.com https://www.facebook.com https://connect.facebook.net https://p.adsymptotic.com https://*.fls.doubleclick.net https://*.linkedin.com https://www.google-analytics.com https://identity.xero.com https://login.xero.com https://go.xero.com https://static.xero.com 'unsafe-inline'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
", source: https://www.googletagmanager.com/gtag/js?id=G-Q622B96ZEQ&l=dataLayer&cx=c (333)
[0317/232458.806:INFO:CONSOLE(333)] "Refused to connect to 'https://stats.g.doubleclick.net/g/collect?v=2&tid=G-Q622B96ZEQ&cid=1821054078.1615983899>m=2oe330&aip=1' because it violates the following Content Security Policy directive: "default-src 'self' https://browsercheck.xero.com https://edge.xero.com https://js-agent.newrelic.com https://bam.nr-data.net https://telemetry.ext.platformdevelopment.xero.com https://api.mixpanel.com https://www.googletagmanager.com https://www.facebook.com https://connect.facebook.net https://p.adsymptotic.com https://*.fls.doubleclick.net https://*.linkedin.com https://www.google-analytics.com https://identity.xero.com https://login.xero.com https://go.xero.com https://static.xero.com 'unsafe-inline'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
", source: https://www.googletagmanager.com/gtag/js?id=G-Q622B96ZEQ&l=dataLayer&cx=c (333)
[0317/232458.819:INFO:CONSOLE(0)] "Refused to load the image 'https://www.google.com.au/ads/ga-audiences?v=1&t=sr&slf_rd=1&_r=4&tid=G-Q622B96ZEQ&cid=1821054078.1615983899>m=2oe330&aip=1&z=174504349' because it violates the following Content Security Policy directive: "img-src 'self' https://browsercheck.xero.com https://edge.xero.com https://js-agent.newrelic.com https://bam.nr-data.net https://telemetry.ext.platformdevelopment.xero.com https://api.mixpanel.com https://www.googletagmanager.com https://www.facebook.com https://connect.facebook.net https://p.adsymptotic.com https://*.fls.doubleclick.net https://*.linkedin.com https://www.google-analytics.com https://identity.xero.com https://login.xero.com https://go.xero.com https://static.xero.com".
", source: https://login.xero.com/identity/user/login?...
i verified locale folder it is same as it is in my local system. And it says refused to connect as it violates something.. then it shouldn't work when i try second time. So i am totally confused what's happening here. can anybody tell me whats wrong here ?.
Help !
This was very basic. I hadn't initialized Cef. As it was working without it second time. I did initialize it in App.xaml.cs when application is starting and now it does work fine everytime. Although i still wonder why it was working (if i load window second time without initializing Cef).
Here's what i added.
if (!Cef.IsInitialized)
{
try
{
//Perform dependency check to make sure all relevant resources are in our output directory.
Cef.Initialize(new CefSettings(), performDependencyCheck: true, browserProcessHandler: null);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
ErrorLogger.LogError(ex.GetType().ToString(), ex, GetType().FullName, System.Reflection.MethodBase.GetCurrentMethod().Name);
}
}
As it was working very well in my system without initializing Cef i thought it isn't compulsory to do that. But it seems that it is necessary.
My xamarin.forms app is meant to join a Zoom meeting on a mobile device using Launcher.OpenAsync() with a uri scheme of the form "zoomus://zoom.us/join?confno=1234567890&pwd=123456".
This works fine on Android, but on iOS it doesn't seem to do anything at all. I call Launcher.CanOpenAsync() beforehand, and that returns true, so the uri should be OK. The Zoom app is already installed. In info.plist I have added zoomus (and zoom) to LSApplicationQueriesSchemes.
My code looks like this:
private void RunZoomAsync()
{
Task zoomTask = Task.Run(async () =>
{
if (await Launcher.CanOpenAsync(selectedMedia.Uri))
{
Message = "Launching Zoom";
await Launcher.OpenAsync(selectedMedia.Uri).ConfigureAwait(false);
}
else
{
Message = "Zoom not found. You must install Zoom from your App Store";
}
});
}
I see the message on the screen, so I know it's getting to the right bit of code.
I tried sending the same link to the iPhone in an email and that does nothing either. (I tried that on the Android phone, and the email app wouldn’t even display the link as a hyperlink). Is there some setting on the iPhone, or in my app, to allow deep linking?
As you may have guessed, I am not normally an iPhone user. I’m using an old iPhone 6 for testing, running iOS 12.4.8.
I have sought help from the Zoom developer forum, who suggested that when using url schemes in iOS, there is an AppDelegate function that needs to be overridden:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
I'm guessing the above is not C#, and that the Essentials Launcher class deals with whatever is required in iOS.
Am I missing something, or is this a bug? Any help gratefully appreciated.
I tried sending the same link to the iPhone in an email and that does
nothing either. (I tried that on the Android phone, and the email app
wouldn’t even display the link as a hyperlink). Is there some setting
on the iPhone, or in my app, to allow deep linking?
This needs to work if you have installed the app and if you are using the proper protocol and if your hardware and operating system is working properly. Your problem is not caused by your code (well unless you are using the wrong protocol), so this is the answer for this site as it doesn't deal with non-coding problems.
Why your Zoom app is not working as expected - you should start with the Zoom customer support as they are in the best position to give you the answer if it exists, but it is extremely likely that your device is faulty in some way.
My problem was that I wasn't running the Launcher in the main thread, so (I assume) the Zoom app didn't have access to the screen. So I just changed:
Task zoomTask = Task.Run(async () =>
to:
MainThread.BeginInvokeOnMainThread(async () =>
and it's now working!
I want to create an app that calls the Hololens default browser. I used the following code, but whenever I call this function, the Application will crash. If this code is not suitable for UWP, how can I call HoloLens' default browser in an app?
The version of the software I am using is:
1.Unity 2018 3.11f
2.Mixed Reality Toolkit v2.0.0 RC1
3.Visual Studio 2017
public void OpenAnlagenWiKi_URL()
{
string tempUrl = string.Format("{0}", AnlagenWiKi_Link.text);
Application.OpenURL(tempUrl);
}
I hope to successfully call HoloLens' default browser in the app.
It's a bit tricky. Any Hololens application is actually UWP process.
First of all, you need to switch it into the background mode by calling AppResourceGroupInfo.StartSuspendAsync. The details are here.
When the app would go into background, you should call open process
System.Diagnostics.Process.Start("http://google.com");
I'm tring to follow the Configuring tutorial of the Facebook SDK for .NET.
But when I add the RootFrame.UriMapper = new FacebookUriMapper(); line of code the NavigationService seems stop to work.
The app start's fine but the command NavigationService.Navigate(new Uri("/Views/LoginPage.xaml", UriKind.Relative)); inserted in a Button on init app page don't work. Other commands on same button like a MessageBox.Show works fine.
Thank you for any help you can provide.
The file FacebookUriMapper in the Facebook.Client SDK has a bug. When looking via debugger, it doesn't redirect to the target page, but switches back to the default RedirectUri in Facebook.xml. Clone the repository in your computer, open the WP8 solution, restore required Nuget packages. Now, open FacebookUriMapper.cs file, modify the last else block to return uri. Build and use this as your referenced assembly. NavigationService works absolutely fine after this.
When I test my app on my device, by deploying it with Visual Studio directly from my pc to my phone, ad is showing. Then I published my app, and there the ad is not showing.
After some research, I found that my to show my ad correctly my app should have ID_CAP_WEBBROWSERCOMPONENT in WMAppManifest file. I noticed, by watching my app's details inside my developer dashboard, that that id_cap is being removed after publishing the app!
I'm not the only, one but I didn't find an answer.
Some posts:
http://social.msdn.microsoft.com/Forums/wpapps/en-US/a172dcb6-7e31-45a1-82f1-44bcd8aeac73/my-app-needs-idcapwebbrowsercomponent-but-marketplace-says-not?forum=wpsubmit
http://social.msdn.microsoft.com/Forums/wpapps/en-US/6e5c635d-fcb4-4156-97fe-c5153088bb91/ads-are-not-showing-im-my-published-app-they-worked-during-development-whats-up-with-that?forum=wpdevelop
Note that I'm working with XNA-Silverlight and using the DrawableAd associated with AdComponent.
I really don't know how to handle this problem. Maybe can I add the capability programmatically?
** EDIT **
I aknowledged that the manifest file is just used while debugging, when you submit an app, it's capababilities are recognized automatically. Here is the problem. I run the StoreKitTeste in Visual Studio as shown here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/gg180730(v=vs.105).aspx#BKMK_UsingtheMarketplaceTestKittoDetermineApplicationCapabilitiesforWindowsPhoneOS71Applications
and in fact it doesn't recognize ID_CAP_WEBBROWSERCOMPONENT. How can I make him see that I need it?
** EDIT 2 *
I found here the same problem http://www.geekchamp.com/tips/be-careful-when-submitting-for-windows-phone-marketplace-an-app-that-uses-capturesource-class
It is related to microphone capability, how can I do the same with Webbrowsercomponent?
I just added: WebBrowser w = new WebBrowser(); somewhere and it recognized its capability.