我們有一個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