Currently, I'm trying to write a small tray application that will show the status and provide control of a server-side application exposed over webservice. The webservice only has 3 operations: start, stop and status. When I call any of these operations in code, they throw an ArgumentException citing "An item with the same key has already been added". I am compiling the webservice on Visual C# Express 2008, and .NET 3.5.
The Code:
private TelnetConnClient Conn
{ get { return new TelnetConnClient(); } }
private bool Connected //call webservice operations
{
get { return Conn.Status(); }
set { if(value) Conn.Start();
else Conn.Stop(); }
}
The Stacktrace:
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.ServiceModel.TransactionFlowAttribute.ApplyBehavior(OperationDescription description, BindingParameterCollection parameters)
at System.ServiceModel.TransactionFlowAttribute.System.ServiceModel.Description.IOperationBehavior.AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
at System.ServiceModel.Description.DispatcherBuilder.AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection parameters)
at System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters)
at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint)
at System.ServiceModel.ChannelFactory.CreateFactory()
at System.ServiceModel.ChannelFactory.OnOpening()
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ChannelFactory.EnsureOpened()
at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.ChannelFactory`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannelInternal()
at System.ServiceModel.ClientBase`1.get_Channel()
at KordiaConnect.ferries.TelnetConnClient.Start() in C:\My Dropbox\Coding\RTF\KordiaConnect\KordiaConnect\Service References\ferries\Reference.cs:line 86
at coldshark.ferries.Main.set_Connected(Boolean value) in C:\My Dropbox\Coding\RTF\KordiaConnect\KordiaConnect\Main.cs:line 22
at coldshark.ferries.Main.<.ctor>b__0(Object sender, EventArgs e) in C:\My Dropbox\Coding\RTF\KordiaConnect\KordiaConnect\Main.cs:line 43
at System.Windows.Forms.NotifyIcon.OnClick(EventArgs e)
at System.Windows.Forms.NotifyIcon.WmMouseUp(Message& m, MouseButtons button)
at System.Windows.Forms.NotifyIcon.WndProc(Message& msg)
at System.Windows.Forms.NotifyIcon.NotifyIconNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run()
at coldshark.ferries.Main..ctor() in C:\My Dropbox\Coding\RTF\KordiaConnect\KordiaConnect\Main.cs:line 55
I can just call the webservice from the web interface, but this application will give me a handy status notification icon, and I'd really love to know why the out-of-the-box auto-generated code fails for no particular reason.