I have a Windows Forms client -- deployed with ClickOnce -- on Windows XP
Professional. The client accesses a web service on a Windows 2003 R2 box
using the SoapService/SoapClient in WSE 3.0. The method that I'm having
trouble with looks as follows:
[SoapMethod("http://www.somecompany.com/getportfolioview")]
public PortfolioDataSet GetPortfolioView()
{
// create an empty soap request since the service doesn't expect params
SoapEnvelope env = new SoapEnvelope();
return
base.SendRequestResponse("http://www.somecompany.com/getportfolioview",
env).GetBodyObject(typeof(PortfolioDataSet),
SoapServiceAttribute.TargetNamespace) as PortfolioDataSet;
}
This works great on most of the clients in production. For one user this is
throwing an exception as follows (I had to OCR the error from a screen shot
so forgive the typos):
Item has already been added. Key in dictionary: ‘path’ Key being added: ‘path’
mscorlib
at System.Collecbons.Hashtable,Insert(Object key, Object nvalue, Boolean add)
at System.Collectons.Hashtable.Add(Object key, Object value)
at System.Collections Speóahzed.StringDictionary. Add(String key, String
value)
at System. CodeDom.Compiler .
Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken,
String cmd, String currentOir TempFileCollection tempFiles, Sfring&
outputName, String& errorName, String trueCmdLine)
at System.CodeDom.Compder Executor ,ExecWaitWithCapture(SafeUserTokenHandle
userToken, String and, String currentDir, TempEileCollection tempFiles,
String& outputName, Sbing& errorName, String trueCmdLine)
at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options,
String compilerDirectory, String compilerExe, String arguments, String&
outpuile, 1nt32& natveReturn Value, String trueArgs)
at Microsoft. CSharp .CSharpcodeGenerator,FromFileBatch(Compilerparameters
options, String[] fileNames)
at Microsoft.CSharp . CSharpCodeGenerator .
FromSourceBatd,(CompilerParameters options, String[j sources)
at Microsoft.CSharp.CSharpCodeGenerator.System CodeDom
.Compiler.ICodeCompiler. CompileAssemblyFromSourceBatd,(CompilerParameters
options, Stringfl sources)
at System. CodeDom.Compiler. CodeDornProvider
.CompileAssemblyFromSource(CompilerParameters options, String[I sources)
at System.Xml.Serializabon.Compiler.Compile(Assembly parent, String ns,
CompilerParameters parameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMappinglj
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
CompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly. .ctor(XmlMapping[] xmlMappings,
Typefl types, String defaultNamespace, String location, Evidence evidence)
at System.Xml. Serialization .XmlSerializer .GenerateTempAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace)
at System.XmLSerialization.XmlSerializer. .ctorCJype type, String
defaultNamespace)
at Microsoft. Web.Services3.Xml.XmlSenalizerCache.GetxmlSerializerCJype
type, String defauttNamespace)
at Microsoft.Web.Services3. SoapEnvelope. Get5odyObject(Jype bodyType,
String defaultNamespace)
at Somecompany.Client.GetPortfolioViewO
at Somecompany.WinUI.LoadPortfolioO
at Somecompany.WinUI.Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms . Form .OnLoad(EventArgs e)
at System.Windows.Forms,Form.OnCreateControlO
at System. Windows.Forms.Control.CreateControl(Boolean flgnorevisible)
at System.Windows.Forms,ControLCreateControlO
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control. IndProc(Message& m)
at System .Windows.Forms. ScrollableControl. WndProc(Message& m)
at System. Windows .Forms. ContainerControl . WndProc(Message& m)
at System.Windows.Forms . Form.WmShow Window (Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow. OnMessage(Message& m)
at System.Windows.Forms.Control. ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, 1nt32 msg, Intr
wparam, IntPtT Iparam)
Insert
Hashtable
mscorlib. dli
de8fe383-36a 1-d58-92cd-ac5d967Of924
C: \WINDO WS V”licrosoft. NETframework\v2.O. 5O727pscorlib.dll
mscoriib, Version =2.0.0.0, Culture =neutral, PublicKeyToken=b77a5c56 1934089
Any ideas what is causing this error on the client?
Steven Cheng[MSFT] - 07 Feb 2007 12:40 GMT
Hello jarred,
From your description, you've an .net 2.0 smart client application which
use the WSE 3.0 soapClient to send webservice message which use SoapService
as host. The client works well on most machine, but encounter an unexpected
exception on a paricular client, correct?
Based on the error message you provided, it seems the problem is occured
inside the WSE3.0's dynamic code generation. It use the CodeDom of .net
framework to dynamically generate necessary proxy code for your WSE
soapclient. Also, the error message indicate there are some dynamic code
which has been generated twice(duplicated). So at least I think your code
logic should be ok here. Does the problem occur randomly or will always
occur whenver you start that smart client application and call the
webservice?
since it is on a particular machine and that's not your local test
environment, it would be a bit hard to troubleshoot. I think you can first
let the user try testing the smart client app with another different logon
user to see whether it it specific to the user profile. Also, you can check
the .net framework environment of that machine to see whether it has been
corrupted. Another thing you can test is try running a non-smart client
deployed winform application (which use the same code to access the
soapservice) to see whether the problem remains.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Steven Cheng[MSFT] - 09 Feb 2007 14:30 GMT
Hello Jarred,
Have you got any progress on this issue? Due to the client environment
coupled characteristic of this problem, you may need some more specific and
thorough troubleshooting to get the root cause. If you feel necessary, I
suggest you contact CSS for further assistance on this.
http://msdn.microsoft.com/subscriptions/support/default.aspx
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
jarred - 09 Feb 2007 22:03 GMT
I actually resolved the problem by running sgen on the entities project that
houses the objects that are (de)serialized.
Sgen wouldn't successfully work on the entities assembly, so I had to look
back at the code. The entities assembly has multiple typed datasets in it.
Some of the datasets have the same table names as other datasets within the
assembly. Apparently this creates ambiguities for sgen.
I reworked the datasets so none of the table names were the same across all
datasets in the assembly. Sgen worked at this point. I redeployed the app
with the serializer assembly and it started working for the client. Still not
sure why this one box was the only box that couldn't handle the affected code.
Perhaps Visual Studio 2005 should let you know that there may be
serialization problems with the assembly if there are ambiguities like this.
I did get the build to fail when sgen failed by putting it as a post-build
step -- I did try setting the Project Properties->Build->Generate
serialization assembly to On and it just seemed to fail silently (it compiled
fine, but no serialization assembly and no errors).
> Hello Jarred,
>
[quoted text clipped - 13 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights
Steven Cheng[MSFT] - 12 Feb 2007 02:07 GMT
Hi Jarred,
Thanks for your followup and shared us your result. This can also benefit
some other members who encounter the same issue.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.