- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在使用 WCF 测试客户端向服务发出请求,但出现以下错误:
Could not load file or assembly 'aDoc_Client.XmlSerializers' or one of its dependencies. The system cannot find the file specified.
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
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 IDWS_WS.AuthenticateUser(String user, String password)
at DWS_WSClient.AuthenticateUser(String user, String password)
我还激活了 SGEN 以强制 XML 序列化,在 .csproj 中使用此代码(Generating an Xml Serialization assembly as part of my build):
<Target Name="AfterBuild"
DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource"
Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)"
Outputs="$(OutputPath)$(_SGenDllName)">
<!-- Delete the file because I can't figure out how to force the SGen task. -->
<Delete Files="$(TargetDir)$(TargetName).XmlSerializers.dll" ContinueOnError="true" />
<SGen BuildAssemblyName="$(TargetFileName)"
BuildAssemblyPath="$(OutputPath)"
References="@(ReferencePath)"
ShouldGenerateSerializer="true"
UseProxyTypes="false"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
DelaySign="$(DelaySign)"
ToolPath="$(TargetFrameworkSDKToolsDirectory)"
Platform="$(Platform)">
<Output TaskParameter="SerializationAssembly"
ItemName="SerializationAssembly" />
</SGen>
</Target>
但是我得到以下错误:
There was an error reflecting type 'aDoc_Client.DocumentManagementExplicitService.OTAuthentication'.
我怀疑这可能是第一个错误的原因,但是这个对象是服务引用中的一个对象。
Reference.cs 中的对象声明如下:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1015")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:api.ecm.opentext.com")]
public partial class OTAuthentication : object, System.ComponentModel.INotifyPropertyChanged {
private string authenticationTokenField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
public string AuthenticationToken {
get {
return this.authenticationTokenField;
}
set {
this.authenticationTokenField = value;
this.RaisePropertyChanged("AuthenticationToken");
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
如何生成 MyAssembly.XmlSerializers.dll?
更新 1:
在我的应用程序和服务引用之间的最后一个接触点插入 try catch 之后:
public string AuthenticateUser(string userName, string userPassword) {
string output = string.Empty;
try
{
output = base.Channel.AuthenticateUser(userName, userPassword);
}
catch(Exception ex)
{
output = ex.ToString();
}
return output;
}
返回异常字符串后,出现以下错误:
System.IO.FileNotFoundException: Could not load file or assembly 'aDoc_Client.XmlSerializers' or one of its dependencies. The system cannot find the file specified.
File name: 'aDoc_Client.XmlSerializers'
Server stack trace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean f or Int rospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyName an, Evidence securityEvidence, StackCrawlMark& stackMark)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.Win32.Fusion.ReadCache(ArrayList alAssems, String name, UInt32 nFlag)
at System.Reflection.RuntimeAssembly.EnumerateCache(AssemblyName partialName)
at System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyName an, Evidence securityEvidence, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadWithPartialName(String partialName, Evidence securityEvidence)
at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GenerateSerializers()
at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GetSerializer(Int32 handle)
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isReq uest)
at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
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 aDoc_Client.AuthenticationExplicitService.Authentication.AuthenticateUser(String userName, String userPassword)
at aDoc_Client.AuthenticationExplicitService.AuthenticationClient.AuthenticateUser(String userName, String userPassword)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
更新 2:
按照 Could not load MyAssembly.XmlSerializers.dll. The system cannot find the file specified 中的说明手动运行 SGEN 工具后使用 visual studio 命令提示符我得到以下错误:
Error: There was an error reflecting type
'aDoc_Client.DocumentManagementExplicitService.OTAuthentication'.
- Types 'aDoc_Client.DocumentManagementExplicitService.OTAuthentication'
and 'aDoc_Client.AuthenticationExplicitService.OTAuthentication'
both use the XML type name, 'OTAuthentication', from namespace 'urn:api.ecm.opentext.com'.
Use XML attributes to specify a unique XML name and/or namespace for the type.
If you would like more help, please type "sgen /?".
aDoc_Client.DocumentManagementExplicitService 和 aDoc_Client.AuthenticationExplicitService 是服务引用,看来我需要找到一种方法来为服务引用指定新的命名空间。
更新 3:
虽然看起来很疯狂,但在不更改任何一行代码的情况下,我在调用服务时没有得到异常。
这会一直重复下去,我似乎无法理解为什么它只有在首次从 .net 应用程序调用后才有效。
最佳答案
问题是 WCF 测试客户端版本。
关于c# - 未生成 MyAssembly.XmlSerializers.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38768061/
运行 prorgam 时,我似乎缺少一个库,当我启动我的项目的输出时,我在启动时遇到异常。 A first chance exception of type 'System.IO.FileLoadEx
这个问题在这里已经有了答案: XmlSerializer giving FileNotFoundException at constructor (19 个回答) 关闭 3 年前。 我获取了 IIS
我正在使用 WCF 测试客户端向服务发出请求,但出现以下错误: Could not load file or assembly 'aDoc_Client.XmlSerializers' or one
我有一个 WPF 应用程序,我订阅了事件 AppDomain.AssemblyResolve (只要运行时没有找到程序集,就会引发此事件),并且我注意到它被多次调用尝试解析 MyAssembly.re
我有一个 C# 网络服务项目。我创建了一个客户端来创建和管理与服务的连接。我们有一个用 C++ 编写的旧 PC 产品,它们需要有一个接口(interface)来调用该服务。我在客户端为它们创建了一些调
我最近安装了 Visual Studio 2012。 但是,安装后,之前在 Visual Studio 2010 中正常运行的项目开始抛出并因以下错误而崩溃: 'System.TypeInitiali
我正在开发一个生成程序集的项目。我刚刚注意到正在生成一个额外的程序集 *.XmlSerializers.dll。为什么这个文件是自动生成的,它的用途是什么? 最佳答案 在.NET实现时,XmlSeri
我刚刚开始使用 NDepend,正在尝试分析解决方案。 当我添加解决方案的程序集时会出现此警告,并且不会加载任何带有警告的程序集: Cant' load the assembly {MyAssembl
抱歉关于词汇问题,但我在任何地方都找不到这个:你怎么称呼下面的这个? [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("My
在项目属性的 Code Contracts 选项卡中将“Contract Reference Assembly”设置为“Build”时,会在输出文件夹的“CodeContracts”子文件夹中创建两个
我正在尝试构建我的项目,当项目构建并且“注册 COM 互操作”属性被勾选时,我突然开始收到以下错误。 The assembly "c:\MyAssembly.dll" could not be con
我是一家公司的实习生,我的任务是为他们提供一个可用的门户网站。由于我是一名实习生,我的技能还没有那么先进,所以他们聘请了一位将与我们合作的高级开发人员。他设置了我们的项目结构等...他告诉我们使用 A
所以我找到了一堆关于这个主题的话题,但我认为我还没有找到一个适用的话题。 基本上,我的 .exe 加载一个 .dll (MyAssembly) 文件,该文件执行序列化和加载。显然它序列化得很好。 但是
这似乎是 JetBrains Resharper 9.1 Ultimate Test Runner 引用旧版本 NUnit 时出现的错误。我在程序集中使用 NUnit 3.0。 [Window Tit
我正在使用 .NET4.5 和 Entity Framework 6 alpha3 创建一个 Web 应用程序,该应用程序使用新的 SQL Compact 数据库。该数据库尚不存在。 我在网络表单中有
我是一名优秀的程序员,十分优秀!