Silverlight 4.0 将现有项目转换为Silverlight 4时出现问题
我们有一个正在工作的Silverlight 3项目。将目标框架更改为Silverlight 4后,应用程序将不再启动。它在生成的InitializeComponent()方法的以下行中引发异常: 以下是异常(请注意内部异常): 问题在于mscorlib.dll的Silverlight版本中不包含System.Security.AllowPartiallyTrustedCallersAttribute类型Silverlight 4.0 将现有项目转换为Silverlight 4时出现问题,silverlight-4.0,Silverlight 4.0,我们有一个正在工作的Silverlight 3项目。将目标框架更改为Silverlight 4后,应用程序将不再启动。它在生成的InitializeComponent()方法的以下行中引发异常: 以下是异常(请注意内部异常): 问题在于mscorlib.dll的Silverlight版本中不包含System.Security.AllowPartiallyTrustedCallersAttribute类型 我不知道如何解决这个问题,也不知道从哪里寻找原因。有人遇到过这个问题吗?什么可能导致此错误
我不知道如何解决这个问题,也不知道从哪里寻找原因。有人遇到过这个问题吗?什么可能导致此错误 AllowPartiallyTrustedCallersAttribute类在SL 4中不存在(既不在mscorlib中,也不在其他任何地方),在SL 3中也不存在。 因此,我想,从SL3到SL4的转换肯定不止这些——AllowPartiallyTrustedCallersAttribute是否在代码中的某个地方使用过 干杯,亚历克斯 编辑:实际上,您可能想查看应用程序的AssemblyInfo.cs(在Properties文件夹中)。可能该属性在那里的使用方式如下所示
[assembly: AllowPartiallyTrustedCallers(true)]
。然后,您可以简单地删除它,看看会发生什么…您的项目中是否使用Unity for silverlight?我昨天也有同样的问题,当我取消引用unity时,错误消失了此演练确实帮助了我解决了同样的问题先进行干净的构建,然后进行完整的重构,为我解决了这个问题。具有相同名称的依赖项将在编译后被悄悄覆盖并打包到XAP中,因此,请确保项目的不同目标平台未构建到相同的输出文件夹我搜索了整个解决方案,但未找到属性。您是否搜索了“AllowPartiallyTrustedCallersAttribute”或“AllowPartiallyTrustedCallers”?你应该搜索“AllowPartiallyTrustedCallers”,因为“-Attribute”部分在使用时可以省略。这是一些奇怪的东西……事实上,到目前为止,我在Silverlight世界中还没有遇到AllowPartiallyTrustedCallers;仅在WPF中的XBAP/ClickOnce场景中。恐怕我在这里束手无策了。我脑子里只想到另外两件事,但可能只是作为进一步研究方向的提示:一件事是强大的命名/程序集签名功能。也许在转换过程中有什么事情搞砸了。第二件事是:我曾经遇到过这样的情况:转换向导没有将一些程序集引用改编为SL的新版本(即,仍然引用了3.0版本)。
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:
[assembly: AllowPartiallyTrustedCallers(true)]