chatratha (4) [Avatar] Offline
#1
Hi Mark,

First of all, thank you for writing an excellent book which has changed my way of developing software solutions.

If it is okay, I would like to get the WpfProductManagementClient sample working. I have read your ReadMe with the sample code; the CommerceService has been set up locally on my default web site, and the database has also been created and populated. Problem is not sure how to start running the CommerceService; the 'Product Management' client starts up but when clicking the Refresh menu button I get an exception thrown SelectAllProducts::SelectAllProducts method (specifically channel.SelectAllProducts). It seems the proxy cannot be opened.

Apologies for this but I am not sure if I am missing an important step in the setup and also not sure how to kick off the CommerceService since the project is a class library.

Thanks for your help.
RobReno (7) [Avatar] Offline
#2
Re: WpfProductManagementClient Sample
Hi Mark and Chatratha,

I want to second Chatratha and say thank you Mark for writing DI.NET. I have learned much from studying your book. One of the more important steps in benefiting from your book for me was getting the sample code for WpfProductManagementClient working so I could step through the code and study it carefully.

Quick question Chatratha. Assuming your Web Service is running have you added permissions to the database? I have managed to get the sample working on Windows 7 and now Windows 8. They were a bit different.

On Windows 7 I added [IISAPPPoolASP.NET v.40] as a User and role db_owner. I also changed the Service to use the same rather than the DefaultAppPool.
mark.seemann (383) [Avatar] Offline
#3
Re: WpfProductManagementClient Sample
Can you post the exact exception details, including exception message and a full stack trace?
chatratha (4) [Avatar] Offline
#4
Re: WpfProductManagementClient Sample
Hi Mark and RobReno,

Thanks for your response.

I have hosted the CommerceService directory in IIS and enabled browsing. I can see the directory structure using http://localhost/CommerceService/.

When I run the WpfClient, and click on the Refresh button, an exception is thrown with the details below.

Unhandled Exception of type 'System.ServiceModel.FaultException'1' occurred in mscorlib.dll
Addition Information: The underlying provider failed an Open

Not sure how to show the full stack trace but the SelectAllProducts is making a call into the Runtime.Remoting.Proxies.RealProxy.PrivateInvoke which then makes a call into Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage which throws the exception.

It seems the problem is my starting of the service, or lacking of it, which is causing this issue, hence any help on this would be good.

Regards.
mark.seemann (383) [Avatar] Offline
#5
Re: WpfProductManagementClient Sample
If you debug into the code, the exception handler in Visual Studio should break on the exception. When that happens, you can copy the entire exception (including stack trace) to the clip board.
chatratha (4) [Avatar] Offline
#6
Re: WpfProductManagementClient Sample
Hi Mark,

Below is the stack trace.


mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg, System.Runtime.Remoting.Messaging.IMessage retMsg) + 0x15c bytes
mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(ref System.Runtime.Remoting.Proxies.MessageData msgData, int type) + 0x6bd bytes
> Ploeh.Samples.ProductManagement.WcfAgent.dll!Ploeh.Samples.ProductManagement.WcfAgent.WcfProductManagementAgent.SelectAllProducts() Line 57 + 0x20 bytes C#
Ploeh.Samples.ProductManagement.PresentationLogic.Wpf.dll!Ploeh.Samples.ProductManagement.PresentationLogic.Wpf.MainWindowViewModel.Refresh(object parameter) Line 120 + 0x30 bytes C#
Ploeh.Samples.ProductManagement.PresentationLogic.Wpf.dll!Ploeh.Samples.ProductManagement.PresentationLogic.Wpf.RelayCommand.Execute(object parameter) Line 47 + 0x24 bytes C#
PresentationFramework.dll!MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource commandSource, bool userInitiated) + 0x100 bytes
PresentationFramework.dll!System.Windows.Controls.Button.OnClick() + 0xb7 bytes
PresentationFramework.dll!System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e) + 0x148 bytes
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x53 bytes
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) + 0x271 bytes
PresentationCore.dll!System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args, System.Windows.RoutedEvent newEvent) + 0x191 bytes
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x53 bytes
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) + 0x271 bytes
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args) + 0x15c bytes
PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs args) + 0x96 bytes
PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea() + 0x451 bytes
PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport inputReport) + 0xbb bytes
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(System.IntPtr hwnd, System.Windows.Input.InputMode mode, int timestamp, System.Windows.Input.RawMouseActions actions, int x, int y, int wheel) + 0x5af bytes
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage(System.IntPtr hwnd, MS.Internal.Interop.WindowMessage msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x3fd bytes
PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x90 bytes
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x13d bytes
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x97 bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x5a bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x47 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) + 0x5d bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) + 0xd2 bytes
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) + 0x164 bytes
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) + 0x13a bytes
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) + 0x12f bytes
PresentationFramework.dll!System.Windows.Application.Run() + 0xbb bytes
ProductManagementClient.exe!Ploeh.Samples.ProductManagement.WpfClient.App.Main() Line 50 + 0x12 bytes C#
RobReno (7) [Avatar] Offline
#7
Re: WpfProductManagementClient Sample
Not sure if this has anything to do with the problem or not. When I got the sample working I found at one point I forgot to generate the proxies using the instructions in the ProductWcfAgent folder:

svcutil ......ComplexCommerceCommerceServiceinPloeh.Samples.CommerceService.dll
svcutil ploehproductMgtSrvc.wsdl *.xsd /n:"urn:ploeh:productMgtSrvc,Ploeh.Samples.ProductManagement.WcfAgent.WcfClient" /noConfig /o:IProductManagementService.cs /tcv:Version35
del *.wsdl
del *.xsd
chatratha (4) [Avatar] Offline
#8
Re: WpfProductManagementClient Sample
Hi RobReno,

I had not generated the proxies but I have now followed your instructions (same as instructions in the UpdateClient.ps1 file) and generated the proxies successfully.

I have again tried 'Refreshing' from the client dialog but still get the same error.

Thanks for your help on this.

Regards.
mark.seemann (383) [Avatar] Offline
#9
Re: WpfProductManagementClient Sample
What I actually mostly needed wasn't so much the stack trace (although those can be informative too) as much as all exception messages, particularly including all inner exceptions (if any).

Another thing you need to examine is whether the service ever receives the request. If you can set a breakpoint in the service code and that breakpoint is hit when the client makes the request, the trouble is somewhere in the service itself. If not, you'll need to figure out why the client doesn't reach the service.

Regenerating the service client isn't going to help - I'm sorry, but that's pure cargo cult...