methodaccessexception

Unable to call Assembly.GetName() from my Silverlight application

拟墨画扇 提交于 2019-12-23 09:31:56
问题 I want to display my application version number within my application, and the simplest way to do this is to use the version number for the assembly. var assembly = System.Reflection.Assembly.GetExecutingAssembly(); var name = assembly.GetName(); return String.Format("Version {0}.{1}", name.Version.Major, name.Version.Minor); I can get the executing assembling without problem, but the call to GetName() returns a MethodAccessException with this message Attempt by security transparent method

Anonymous types and Get accessors on WP7.1?

有些话、适合烂在心里 提交于 2019-11-29 09:44:41
I'm trying to write a simple object to Dictionary converter like below: public static class SimplePropertyDictionaryExtensionMethods { public static IDictionary<string,string> ToSimplePropertyDictionary(this object input) { if (input == null) return new Dictionary<string, string>(); var propertyInfos = from property in input.GetType() .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetProperty) where property.CanRead select property; return propertyInfos.ToDictionary(x => x.Name, x => input.GetPropertyValueAsString(x)); } public static

Anonymous types and Get accessors on WP7.1?

徘徊边缘 提交于 2019-11-28 03:12:50
问题 I'm trying to write a simple object to Dictionary converter like below: public static class SimplePropertyDictionaryExtensionMethods { public static IDictionary<string,string> ToSimplePropertyDictionary(this object input) { if (input == null) return new Dictionary<string, string>(); var propertyInfos = from property in input.GetType() .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetProperty) where property.CanRead select property;