by einar@dolittle.com (Einar Ingebrigtsen) via Einar Ingebrigtsen on 7/15/2010 5:31:08 AM
The last few days I've been busy porting Balder to other platforms, amongst those; Windows Phone 7 Series. There are some nuances between the different platforms Balder will support, one of these for Windows Phone 7 was that the Load() method does not exist on an AssemblyPart from the deployment object.
Balder has a discover architecture were it discovers different types from the loaded assemblies, in the Silverlight version I could simply go and get all the AssemblyParts and get it as a resource stream and load them to get the actual Assembly instance. Since the Load() method didn't exist I had to to look elsewhere.Fortunately, the Assembly class in the Windows Phone 7 version of .net has an overload for the Load() method that takes a string. According to the MSDN documentation it needs to take a fully qualified assemblyname, that turned out to be difficult to acquire. But, it turns out that its sufficient to pass it the short name - this can be derived from the DLL name found in the AssemblyParts property called Source.
From the TypeDiscoverer code in Balder :
private void CollectTypes(){ if( null != Deployment.Current ) { var parts = Deployment.Current.Parts; foreach (var part in parts) { var assemblyName = part.Source.Replace(".dll", string.Empty); var assembly = Assembly.Load(assemblyName); var types = assembly.GetTypes(); _types.AddRange(types); } }}
Original Post: Dynamically discovering assemblies and types on Windows Phone 7
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.