我们有一个Silverlight 3项目。将目标框架更改为Silverlight 4后,应用程序将不再启动。它抛出异常在生成的InitializeComponent以下行()方法:将现有项目转换为Silverlight 4的问题
System.Windows.Application.LoadComponent(this, new System.Uri("/SLAppMain;component/App.xaml", System.UriKind.Relative));
这里是例外(注意内部异常):
System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
LineNumber=0
LinePosition=0
StackTrace:
bei System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
InnerException: System.TypeLoadException
Message=Der Typ 'System.Security.AllowPartiallyTrustedCallersAttribute' konnte nicht aus der mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e -Assembly geladen werden.
StackTrace:
bei System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
bei System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
bei System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
bei System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
bei System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
bei System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
bei MS.Internal.XamlSchemaContext.ProcessXmlnsDefinitions(Assembly assembly, String assemblyName)
bei MS.Internal.XamlSchemaContext.EnsureManagedAssemblyAttributesLoaded()
InnerException:
的问题是,该类型System.Security .AllowPartiallyTrustedCallersAttribute不包含在Silverlight版本的mscorlib.dll中。
我不知道如何解决这个问题,也不知道在哪里寻找原因。有没有人遇到过这个问题?什么可能导致这个错误?
我搜索了整个解决方案,但没有找到该属性。 – user351008 2010-05-26 15:15:51
您是否搜索“AllowPartiallyTrustedCallersAttribute”或“AllowPartiallyTrustedCallers”?您应该搜索“AllowPartiallyTrustedCallers”,因为“-Attribute”部分在使用时可以省略。 – 2010-05-26 15:23:07
我的确如此。 – user351008 2010-05-26 15:59:11