I am using WCF Test Client to make a request to a service, however i get the following error:
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)
I verified that i have Generate Serialization Assembly ON in the Project Properties -> Build.
I also activated SGEN to force the XML serialization, using this code(Generating an Xml Serialization assembly as part of my build) in the .csproj:
<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>
however i get the following error:
There was an error reflecting type 'aDoc_Client.DocumentManagementExplicitService.OTAuthentication'.
I suspect this may be the cause of the first error, however this object is an object inside a Service Reference.
The Object declaration in Reference.cs is the following:
[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));
}
}
}
How can i generate MyAssembly.XmlSerializers.dll?
UPDATE 1:
After inserting a try catch in the last point of contact between my application and the service reference:
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;
}
After returning a string with the exception, i get the following errors:
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].
UPDATE 2:
After running SGEN tool manually as specified in Could not load MyAssembly.XmlSerializers.dll. The system cannot find the file specified with visual studio command prompt i get the following errors:
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 and aDoc_Client.AuthenticationExplicitService are service references, it appears i need to find a way to specify new namespaces for the service references.
UPDATE 3:
As crazy as it seems, without changing a single line of code, there is a case where i don't get an exception when calling the service.
And this repeats forever, i cant seem to understand why it only works after being first called from a .net application.
The problem was the WCF Test Client Version.