0

我从以下调用堆栈中得到了这个未处理的异常,但我不知道为什么它对我来说失败了......(虽然我运行它的方式可能有些特别,是的......)

“跨 appdomains 的远程调用失败,在程序集 'System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 中的类型 'System.Xml.Linq.XElement' 未标记为可序列化”

Server stack trace: 
   at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
   at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize)
   at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage..ctor(IMethodCallMessage mcm)
   at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.SmuggleIfPossible(IMessage msg)
   at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg)

Exception rethrown at [0]: 

   Source=mscorlib
   StackTrace:
     Server stack trace: 
        at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
        at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
        at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
        at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder)
        at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder)
        at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
        at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
        at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
        at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize)
        at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage..ctor(IMethodCallMessage mcm)
        at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.SmuggleIfPossible(IMessage msg)
        at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg)
     Exception rethrown at [0]: 
        at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
        at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

失败的电话来自

         at Microsoft.ServiceHosting.Tools.MSBuildTasks.PackageCreator.CreateServiceApplicationPackage(String serviceRdFilePath, String processedServiceDefinitionFile, FileStream packageStream, Dictionary`2 namedStreams, Dictionary`2 rolesDictionary)

当我检查被走私的味精信息时,我看到 argsToSerialize 包含一些 MemoryStreams 和

+       [0x00000000]    {[Kernel, Microsoft.ServiceHosting.Tools.Internal.SimpleServiceModel.Role]} System.Collections.Generic.KeyValuePair<string,Microsoft.ServiceHosting.Tools.Internal.SimpleServiceModel.Role>

Microsoft.ServiceHosting.Tools.Internal.SimpleServiceModel.Role 标记为[Serializable]

并且看起来序列化可能正在序列化 Microsoft.ServiceHosting.Tools.Internal.SimpleServiceModel.RoleEnvironment 类型的属性的中间

其中包含一个XElement...啊哈。这只是因为 XElement 不应该在 [Serializable] 类中而被破坏了吗?但我想知道当我从命令行运行 cspack 时,这个问题如何不会重现?我该如何解决?

4

1 回答 1

0

我与从事 Azure SDK 工作的人取得了联系。他告诉我,我在 SDK 2.5 中遇到的错误已在 SDK 2.5.1 中修复,万岁!我还没有测试过。

于 2015-08-21T21:19:14.600 回答