HtmlPage.Window.Navigate works in IE but not in Chrome - silverlight-4.0

I have a very simple silverlight interface that has a bunch of links on it. Sort of like an old school html area map where different parts take you to different places on the internal network.
I was testing my pages in IE on a development box and was having success redirecting the page using
HtmlPage.Window.Navigate(New Uri("http://mytestbox02/"))
I took a copy of the source over to my laptop where the default browser for VS2010 happened to be Chrome and to my surprise my links did not work. Sometimes I saw it redirect but it mangled up the uri and it ended up being in the form of mytestbox02/ and therefore it didn't go anywhere but 404 because it was missing the http:// prefix. Sometimes I get an exception. Details of that exception are
System.InvalidOperationException was caught
Message=SetProperty failed.
StackTrace:
at System.Windows.Browser.ScriptObject.SetProperty(String name, Object value)
at System.Windows.Browser.ScriptObject.GetObjectForSafari(IntPtr identity, IntPtr handle, Type type, Boolean releaseReferenceOnDispose)
at System.Windows.Browser.ScriptObject.GetObject(IntPtr handle, Type type, Boolean ownsHandle, Boolean releaseReferenceOnDispose)
at System.Windows.Hosting.ScriptingInterface.GetScriptParamValue(ScriptParam scriptParam)
at System.Windows.Hosting.ScriptingInterface.ConvertFromScriptParamAndDispose(ScriptParam scriptParam)
at System.Windows.Browser.ScriptObject.TryInvoke(String name, Object[] args, Exception& error)
at System.Windows.Browser.ScriptObject.Invoke(String name, Object[] args)
at System.Windows.Browser.HtmlWindow.Navigate(Uri navigateToUri, String target, String targetFeatures)
at System.Windows.Browser.HtmlWindow.Navigate(Uri navigateToUri)
at popupwindow.MainPage.ChildWindow_Closed(Object sender, EventArgs e)
InnerException:
Silverlight 4.1.10111.0 on both the dev box and my laptop.
Any clue what is going on here? I can't be fully sure my clients will use IE so I hope there is a fix for this. Or something more cross-compatible that I can use other than window.navigate? I haven't found anything yet though..

It seems that this may in fact be a Chrome issue - I just spent the day fighting it myself.
http://forums.silverlight.net/t/213769.aspx/1
http://stulic.blogspot.com/2009/08/javascript-locationhref-vs-silverlight.html
You'll probably need to use some kind of javascript.
HtmlPage.Window.Eval("window.location.href = '<something>';");
//or
HtmlPage.Window.Eval("window.location.reload();");

Related

I'm trying to set up a new SharePoint production server and getting an error creating an Open XML 2.5 document

I have a SharePoint application written in Visual Basic that works fine and creates Word Documents using Open XML 2.5 on my development machine. We recently set up a new Production server and I published the .wsp file and deployed it on the new server. The application all works fine except the code that generates reports in Word format. It fails on the following line of code.
Dim wpd As WordprocessingDocument = WordprocessingDocument.Create(MemStream, WordprocessingDocumentType.Document, True)
This is what the code looks like in the function that is failing.
''' \<summary\>
'''
''' \</summary\>
''' \<param name="MemStream"\>\</param\>
''' \<returns\>\</returns\>
Public Function WPDCreateFromStream(MemStream As MemoryStream) As WordprocessingDocument
Try
Dim wpd As WordprocessingDocument = WordprocessingDocument.Create(MemStream, WordprocessingDocumentType.Document, True)
Dim MainPart As MainDocumentPart = wpd.AddMainDocumentPart()
MainPart.Document = New Document()
Dim DocBody As New Body()
Return wpd
Catch ex As Exception
WriteErrorToEventLog("OpenXML", "WPDCreateFromStream", "", ex)
Return Nothing
End Try
End Function
Here is the exception detail I get when trying to make the WordProcessingDocument.Create call above.
ERROR: Source: OpenXML Routine: WPDCreateFromStream User:
Message: The type initializer for 'MS.Utility.EventTrace' threw an exception.
StackTrace: at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateCore(Stream stream)
at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create(Stream stream, WordprocessingDocumentType type, Boolean autoSave)
at FIS.SP.PSTARProjectTracker.PSTAR.Core.BusinessLogic.OpenXML.WPDCreateFromStream(MemoryStream MemStream)
Source: WindowsBase
Data: System.Collections.ListDictionaryInternal
InnerException: System.Security.SecurityException: Requested registry access is not allowed.
at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at Microsoft.Win32.Registry.GetValue(String keyName, String valueName, Object defaultValue)
at MS.Utility.EventTrace.IsClassicETWRegistryEnabled()
at MS.Utility.EventTrace..cctor()
The Zone of the assembly that failed was:
MyComputer
ToString: System.TypeInitializationException: The type initializer for 'MS.Utility.EventTrace' threw an exception. ---> System.Security.SecurityException: Requested registry access is not allowed.
at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at Microsoft.Win32.Registry.GetValue(String keyName, String valueName, Object defaultValue)
at MS.Utility.EventTrace.IsClassicETWRegistryEnabled()
at MS.Utility.EventTrace..cctor()
--- End of inner exception stack trace ---
at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateCore(Stream stream)
at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create(Stream stream, WordprocessingDocumentType type, Boolean autoSave)
at FIS.SP.PSTARProjectTracker.PSTAR.Core.BusinessLogic.OpenXML.WPDCreateFromStream(MemoryStream MemStream)
TargetSite: Void EasyTraceEvent(Keyword, Event)
I know this is not an issue with the code as the same code works in development. I assume it has to do with permissions, or getting the DocumentFormat.OpenXML.dll installed / registered correctly on the new server, but I've had no luck searching for a solution.
I tried installing OpenXML and the Productivity tool on the server. The productivity tool works and can open a word document, but the Application has the same issue.
If anyone has run into this and can point me to a solution, I would appreciate it.
The MemoryStream is created and passed in to be used by this function. The WordProcessingDocument is returned to the calling function. I could explicitly call ByVal, but in this case it would not change anything.
I am creating a new document, that is why it is coded using WordProcessingDocument.Create
Remember, this code all functions perfectly on the development SharePoint server. It has been used heavily for about a year. I'm just trying to get this to work on a new production server we recently stood up. I have to believe this is related to some permission issue, or a component that is not installed or registered correctly. For Open XML, I believe there is just the one DLL (DocumentFormat.OpenXML.DLL) and it does not register. It is on the server from installing the .wsp package. I also tried installing Open XML 2.5 on the server along with the productivity tool and they all work fine.
The more I think about it, it just feels like a permission issue.

Cross Browser Test With Coded UI Locate Browser

I am currently using Coded UI to test on IE and am using the Selenium cross browser components to extend this testing onto Chrome.
Before the most recent update to the dot net bindings from selenium these lines worked fine
BrowserWindow.CurrentBrowser = "chrome";
CurrentBrowser = BrowserWindow.Launch(onDemandURL);
Now I receive the following error stating a null value on the windowHandle
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl..ctor(IntPtr windowHandle)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FromWindowHandle(IntPtr windowHandle)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControlFactory.FromWindowHandle(IntPtr windowHandle)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserService.InitializeTopLevelWindow()
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserService.InitializeCrossBrowserService(String[] args)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserService..ctor(String[] args)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.BrowserServices.ChromeBrowserService..ctor(String[] args)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserService.<.cctor>b__0(String[] args)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserService.Launch(Uri uri)
at Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowser.CrossBrowserFactory.Launch(Uri uri)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.LaunchPrivate(Uri uri)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.<>c__DisplayClass15.<Launch>b__14()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.Launch(Uri uri)
There seems to be an issue in the CrossBrowserService call to InitializeTopLevelWindow(). I'm not sure if that's a bug in the cross browser server or where it's coming from. That being said - is there any other way to launch the chrome browser and assign it to CurrentBrowser like I did above, where CurrentBrowser is of type BrowserWindow in this case. Or am I doing something wrong in the above 2 lines?

Unable to determine the identity of domain using System.IO.Packaging

I am getting "Unable to determine the identity of domain" when using System.IO.Packaging through COM Interop, there are a few articles describing why this is happening and the solution is to run the offending function in its own AppDomain.
So I took the sample code, which looks like the below but I still get the error, I am wondering what i am doing wrong and also, with VS 2010 it says AddAssembly and AddHost are obsolete - I wonder if that means they are no longer implemented, but if thats the case I dont really understand how to use the new methods (AddAssemblyEvidence and AddHostEvidence)??
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
evidence.AddAssembly(Assembly.GetExecutingAssembly().FullName);
evidence.AddHost(new Zone(SecurityZone.MyComputer));
AppDomain domain = AppDomain.CreateDomain("BlobPackage", evidence, setup);
BlobPackage blob_interal = (BlobPackage)domain.CreateInstanceAndUnwrap(typeof(BlobPackage).Assembly.FullName, typeof(BlobPackage).FullName);
blob_interal.pack(FilePath, RootPath, m_source_files); <-- STILL FAILS
AppDomain.Unload(domain);
I solved this one myself, I forgot to inherit my class from MarshalByRefObject.
Its a bit stupid, it allows you to create an instance and call it except its still running in the default domain, you would think it would throw an exception or something, anyway by marking the class as [Serializable()] and deriving from MarshalByRefObject fixes it.

WebGet UriTemplate fails on dot ('.'/%2E)?

I've been trying for a while now to figure out why this UriTemplate does not work as part of a WCF service and can't seem to get anywhere:
[WebGet(UriTemplate="api/1.0/version")]
string GetVersion();
A quick test shows that UrlTemplateTable matches it fine (output is 'api/1.0/version'):
static void Main(string[] args)
{
Uri prefix = new Uri("http://localhost/");
System.UriTemplateTable table = new System.UriTemplateTable(prefix);
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(new UriTemplate("api/1.0/version"), "a"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(new UriTemplate("api/2.0/version"), "b"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(new UriTemplate("api/version"), "c"));
Uri uri = new Uri("http://localhost/api/1.0/version");
UriTemplateMatch match = table.MatchSingle(uri);
Console.WriteLine("{0}", match.Template.ToString());
}
The dot is not an illegal character in URLs, RequestPathInvalidCharacters does not exclude it, there are no rewrite rules in place that could interfere. Couldn't find anything in the documentation on it either.
While there is an obvious workaround, not use the dot in the template, I'm curious as to why it fails with 'HTTP 404/The resource cannot be found'.
I ran into the same issue before. I realized it was a limitation in IIS, and nothing to do with WCF. When IIS initially intercepts the request assumes the value following the . represents an extension, so it tries to find a managed handler for that extension. Since it does not find any, it just throws a 404.
Regards
Pablo.

Apache Error is incompatible with throws class

I've got a quick question. In my grails project I am making some web service calls. One of the calls (for a search function) tends to timeout if not enough characters are given to search for. I can't increase the number of required characters so I instead am trying to catch the exception and display an error page asking the user to add more detailed parameters.
The method looks like this:
import org.apache.http.client.HttpResponseException
class RestSearchService implements SearchService {
List<Person> getPersonSearch( String fName, String lName) throws HttpResponseException {
...
// Make the call
...
}
}
I then catch the thrown exception in the controller to redirect to the error page. I've tested it and this code appears to work fine. The problem is that the method above is underlined (I'm using SpringSource Tool Suite for an IDE) and says
Exception HttpResponseException is not compatible with
throws clause in SearchService.getPersonSearch(String, String)
Does anyone know what might be causing this? Also, might it mean that there is an actual problem or circumstance where this will cause the app to break? Like I said, from what I can tell the throw/redirect is working like a champ, but that error makes me nervous about moving the app to production.
Thanks in advance,
-Mike
I would say that your interface SearchService is not right! what is the signature of the method 'getPersonSearch' in the interface?
its like this:
List<Person> getPersonSearch( String fName, String lName);
or like this:
List<Person> getPersonSearch( String fName, String lName) throws HttpResponseException;
the second one is correct, if you have the first one, thats should be the problem!