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.
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.
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.
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.
I'm trying to use Selenium WebDriver to automatically login in to a site with a user-name and password. I've done my research and I don't believe this feature is supported by WebDriver, so I need to find another way. The site I'm trying to automate logging into is located here.
When prompted to login a popup window comes up that doesn't seem to be part of the browser. I'm using Firefox and Chrome. It seems Windows API may be required? I already tried passing the credentials in the URL but that didn't work. Also tried sendkeys, but received a Windows exception that the application was not accepting Windows messages. I also tried switching the current handle using driver.windowhandles but the popup doesn't seem to be a new handle.
Does anybody have any ideas? I'm kinda stuck. The preliminary code to get to the popup window is:
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.portal.adp.com");
string currentWindow = driver.CurrentWindowHandle;
IWebElement userLogin = driver.FindElement(By.Id("employee"));
userLogin.Click();
The popup you are seeing is prompted by web server and is a authentication prompt. Selenium doesn't support this operation.
One of the way to handle this limitation is to pass user and password in the url like like below:
http://user:password#example.com
More info available here : http://aleetesting.blogspot.in/2011/10/selenium-webdriver-tips.html
I wanted my answer out there because I think I've solved it. This answer does not require passing the credentials through the URL (for those of you that are unable to like me). It also does not require any custom Firefox Profiles or extensions to be installed or included with the solution or installed onto the browser eliminating cross-machine compatibility issues.
The issue with me was that the authentication could not be completed via passing the credentials through the URL because the login was behind a proxy.
So, I turned to windows automation toolkits and found AutoIT. Using AutoIT and Selenium, you can login automatically by sending the username and password to the windows dialog that appears. Here's how (note the steps below are for c#:
1 - Download AutoIT from http://www.autoitscript.com/site/autoit/downloads/
2 - Add the autoit .dll to your project references.
Right click on references, select Add Reference. Next click the browse button and browse to the dll location (most default installations it will be c:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll), and add to project.
3 - use AutoIT and Selenium like this (assuming your web driver is already initialized):
//Initialize AutoIT
var AutoIT = new AutoItX3();
//Set Selenium page load timeout to 2 seconds so it doesn't wait forever
Driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(2));
//Ingore the error
try
{
Driver.Url = url;
}
catch
{
return;
}
//Wait for the authentication window to appear, then send username and password
AutoIT.WinWait("Authentication Required");
AutoIT.WinActivate("Authentication Required");
AutoIT.Send("username");
AutoIT.Send("{TAB}");
AutoIt.Send("password");
AutoIT.Send("{ENTER}");
//Return Selenium page timeout to infinity again
Driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(-1));
Anyway, that's it, and it works like a charm :)
Also note that there are some special characters that need to be escaped in AutoIT using the sequence "{x}". For example, if your password is "!tRocks", you'd need to pass it into AutoIT as "{!}tRocks".
Happy automating.
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", hostname);
Driver = new FirefoxDriver(profile);
hostname is your URL (example.com) then try to
Driver.Navigate().GoToUrl(http://user:password#example.com);
I just got done working on a prototype project that is supposed to handle exactly this kind of situation.
It utilizes BrowserMob, a popular open source proxy, to perform the authentication.
SeleniumBasicAuthWrapper Hope it helps! It is still a work in progress, but hopefully we'll get any kinks or defects ironed out in the near future.
I am using the Mathematica .Net/Link platform to create a web service to format and calculate math problems. However I am unable to get it working.
I create it using this code:
_Log.IpDebug("Starting the Kernel Link");
if (string.IsNullOrEmpty(_MathLinkArguments))
_InternelKernel = MathLinkFactory.CreateKernelLink();
else
_InternelKernel = MathLinkFactory.CreateKernelLink(_MathLinkArguments);
_Log.IpDebug("Kernel Link Started");
_InternelKernel.WaitAndDiscardAnswer();
The value of _MathLinkArguments is -linkmode launch -linkname \"C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\Math.exe\".
This piece of code is called from the Application_Start method of the global.asax.cs file.
When it gets to the WaitAndDiscardAnswer() call it gives the server error:
Error code: 11. Connected MathLink program has closed the link, but there might still be data underway.
Note: The SampleCode given with the .NET/Link package (both a console app and a WinForms app) works.
Edit:
I copied the console app sample code given with Mathematica into an asp.net page and it gave me the same error the first load and then on subsequent loads it gave me:
Error code: 1. MathLink connection was lost.
Edit2:
I forgot to mention that when I have procmon and task manager open while running my app, I can tell that Math.exe starts but it immediately exits, which makes those error code make complete sense...but doesn't explain why that happened.
To allow the .Net/Link to work in Asp.net (at least in IIS 7.5) you need to enable the property loadUserProfile on the app pool for the web site.
I am not entirely sure why this is the case, but from what I found while trying to debug this, there are some things that are gotten from the user's profile. I know for a fact that the default location of the kernel is, which explains why I couldn't use it with no arguments, and so I can only assume that other things are needed as well and without the profile it couldn't determine that.
But whatever the reason is this is required, it is, or at least it is a fix if you are getting similar problems like this in your own application.
I got the same error in a .Net WinForm application.
mathKernel = new MathKernel();
mathKernel.Compute("<< XYZ`XYZGraphs`");
The error occurred on loading the package straight after instantiating the MathKernel.
To resolve it you can wait a couple of seconds and then instantiating the MathKernel works fine. During this state where there might still be data underway the following conditions are both false:
if (!MathKernel.IsConnected)
{
MathKernel.Connect();
}
if (MathKernel.IsComputing)
{
MathKernel.Abort();
}
Edit:
I've recieved the error again and this time was able to determine the problem.
Using a command line open the MathKernel.exe and view the error message: