Skip to main content

Posts

Showing posts with the label Silverlight

No GetEntryAssembly in Silverlight!

Ran into a problem today, wanting to get the assembly that started the an application. Now this isn't a tricky problem just had to bend it to my will :) We have a code-base shared across platforms (WPF & Silverlight) via project linker  and we need the ability to get the executable assembly, MSDN describes this as 't he assembly that is the process executable in the default application domain ' ans this is accessed via the  GetEntryAssembly method. The problem is purely because GetEntryAssembly is not supported in Silverlight so we had to come up with away to get the assembly version of the startup dll in the Silverlight XAP. The following code is contained in a library (framework) assembly which know nothing about which assembly (executable) was loaded into the default application domain. So I came up with the idea of using the Application.Current property:

Calling 'HtmlPage.Window.Invoke' from a background thread

Received what at the time seemed like a strange exception from a piece of code in a silverlight I was debugging yesterday - ' this operation can only occur on the ui thread. ' What makes this strange was the fact this wasn't attempting to update any UI controls or classes bound to views,  infact this was the complete opposite, this was a method trying to invoke out to javascript from a randomly assigned thread (thread pool). To compound my confusion not only was I seeing this intermittently but the action I was trying to achieve still appeared to completely successfully, writing to an in-memory javascript log! Now the answer is as you probably known, is... Any interaction with the host browser from silverlight has to be done on the UI thread even if you're not updating any UI.