Google Checkout 突然返回:“GCheckout.XmlSerializers”加载失败
我在使用 Google Checkout ASP.NET 控件“GCheckout”时突然遇到间歇性错误。
它位于如下所示的第一行代码中:
XmlSerializer Ser = new XmlSerializer(ObjectToSerialize.GetType()); //ObjectToSerialize is a CheckoutShoppingCart object
让我困惑的是为什么它以前似乎一直有效,而现在只是间歇性地返回如下所示的错误。
这个库对我来说是一个巨大的黑匣子,而且我是一个 VB.NET 人,而不是 C# 人。
有人可以提供任何建议吗?
/// <summary>
/// Makes XML out of an object.
/// </summary>
/// <param name="ObjectToSerialize">The object to serialize.</param>
/// <returns>An XML string representing the object.</returns>
/// <example>
/// <code>
/// Car MyCar1 = new Car();
/// byte[] CarBytes = EncodeHelper.Serialize(MyCar1);
/// string CarXml = EncodeHelper.Utf8BytesToString(CarBytes);
/// Car MyCar2 = (Car) Deserialize(CarXml, typeof(Car));
/// // MyCar2 is now a copy of MyCar1.
/// </code>
/// </example>
public static byte[] Serialize(object ObjectToSerialize) {
XmlSerializer Ser = new XmlSerializer(ObjectToSerialize.GetType()); //ObjectToSerialize is a CheckoutShoppingCart object
using (MemoryStream MS = new MemoryStream()) {
XmlTextWriter W = new XmlTextWriter(MS, new UTF8Encoding(false));
W.Formatting = Formatting.Indented;
Ser.Serialize(W, ObjectToSerialize);
W.Flush();
W.Close();
return MS.ToArray();
}
}
The assembly with display name 'GCheckout.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 9. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'GCheckout.XmlSerializers, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'GCheckout.XmlSerializers, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null'
=== Pre-bind state information ===
LOG: User = NA\MYNAME
LOG: DisplayName = GCheckout.XmlSerializers, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL
(Fully-specified)
LOG: Appbase = file:///C:/My/Code/BESI/BESI/
LOG: Initial PrivatePath = C:\My\Code\BESI\BESI\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\My\Code\BESI\BESI\web.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers/GCheckout.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers/GCheckout.XmlSerializers.EXE.
I am suddenly experiencing an intermittent error using the Google Checkout ASP.NET control "GCheckout."
It is on the first line of code shown below:
XmlSerializer Ser = new XmlSerializer(ObjectToSerialize.GetType()); //ObjectToSerialize is a CheckoutShoppingCart object
What puzzles me is why it seemed to work all the time before and now only intermittently returns the error shown below.
This library is a huge black box for me and I am a VB.NET person, not C#.
Can someone offer any suggestions?
/// <summary>
/// Makes XML out of an object.
/// </summary>
/// <param name="ObjectToSerialize">The object to serialize.</param>
/// <returns>An XML string representing the object.</returns>
/// <example>
/// <code>
/// Car MyCar1 = new Car();
/// byte[] CarBytes = EncodeHelper.Serialize(MyCar1);
/// string CarXml = EncodeHelper.Utf8BytesToString(CarBytes);
/// Car MyCar2 = (Car) Deserialize(CarXml, typeof(Car));
/// // MyCar2 is now a copy of MyCar1.
/// </code>
/// </example>
public static byte[] Serialize(object ObjectToSerialize) {
XmlSerializer Ser = new XmlSerializer(ObjectToSerialize.GetType()); //ObjectToSerialize is a CheckoutShoppingCart object
using (MemoryStream MS = new MemoryStream()) {
XmlTextWriter W = new XmlTextWriter(MS, new UTF8Encoding(false));
W.Formatting = Formatting.Indented;
Ser.Serialize(W, ObjectToSerialize);
W.Flush();
W.Close();
return MS.ToArray();
}
}
The assembly with display name 'GCheckout.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 9. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'GCheckout.XmlSerializers, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'GCheckout.XmlSerializers, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null'
=== Pre-bind state information ===
LOG: User = NA\MYNAME
LOG: DisplayName = GCheckout.XmlSerializers, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL
(Fully-specified)
LOG: Appbase = file:///C:/My/Code/BESI/BESI/
LOG: Initial PrivatePath = C:\My\Code\BESI\BESI\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\My\Code\BESI\BESI\web.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers/GCheckout.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/besi/c1115671/77c4386d/GCheckout.XmlSerializers/GCheckout.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/My/Code/BESI/BESI/bin/GCheckout.XmlSerializers/GCheckout.XmlSerializers.EXE.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 XML 序列化的正常异常。调试+异常,关闭复选框。使用Sgen.exe工具预编译序列化程序集,它是快很多。
This is a normal exception for XML serialization. Debug + Exceptions, turn off the check boxes. Use the Sgen.exe tool to pre-compile serialization assemblies, it's a lot faster.