{"id":7306,"date":"2014-06-07T02:23:47","date_gmt":"2014-06-07T02:23:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/winforms-reportviewer-cannot-connecto-to-remote-report-server-sql-express-collection-of-common-programming-errors\/"},"modified":"2014-06-07T02:23:47","modified_gmt":"2014-06-07T02:23:47","slug":"winforms-reportviewer-cannot-connecto-to-remote-report-server-sql-express-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/winforms-reportviewer-cannot-connecto-to-remote-report-server-sql-express-collection-of-common-programming-errors\/","title":{"rendered":"WinForms ReportViewer cannot connecto to remote Report Server (SQL Express)-Collection of common programming errors"},"content":{"rendered":"<p><strong>Introduction:<\/strong><\/p>\n<p>I have SQL Server Express 2008 R2 installed with Advanced Services. I have created few reports using BI Design Studio and deployed them to the Server. If I access the reporting server using IE (http:\/\/Ser2008\/Reports\/) it works fine (I have to put in User Name\/Password). I can view reports or fool around with the settings.<\/p>\n<p><strong>Problem:<\/strong><\/p>\n<p>On my local machine I created a winforms application with one form containing a ReportViewer control. On form load I&#8217;m running following code:<\/p>\n<pre><code>reportViewer1.ProcessingMode = ProcessingMode.Remote;\nreportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = \n            new CustomCredentials(\"secret@123\") { \n                          UserName = \"administrator\", \n                          Domain = \"ser2008\" \n            }.NetworkCredentials;\n\nreportViewer1.ServerReport.ReportServerUrl = new Uri(\"http:\/\/ser2008\/Reports\/\");\nreportViewer1.ServerReport.ReportPath = \"\/Students\/Attendance\";\n\nvar l = new List();\nl.Add(CreateParameter(\"UserId\", \"144\"));\nl.Add(CreateParameter(\"Class\", \"8\"));\nl.Add(CreateParameter(\"date_from\", \"2011-09-04\"));\nl.Add(CreateParameter(\"date_to\", \"2011-12-31\"));\n\nreportViewer1.ServerReport.SetParameters(l); \/\/EXCEPTION THROWN HERE\nreportViewer1.RefreshReport();\n<\/code><\/pre>\n<p>I get following exception:<\/p>\n<pre><code>The attempt to connect to the report server failed.  Check your connection \ninformation and that the report server is a compatible version. The request \nfailed with HTTP status 404: Not Found.\n<\/code><\/pre>\n<p>The stack trace is as follows:<\/p>\n<pre><code>    at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005\n                .Execution.RSExecutionConnection.MissingEndpointException\n                .ThrowIfEndpointMissing(WebException e)\nat Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005\n                .Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn]\n                      (RSExecutionConnection connection, ProxyMethod`1 initialMethod, ProxyMethod`1 retryMethod)\nat Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005.\n                Execution.RSExecutionConnection.LogonUser(String userName, String password, String authority)\nat Microsoft.Reporting.WinForms.ServerReport.get_Service()\nat Microsoft.Reporting.WinForms.ServerReport.EnsureExecutionSession()\nat Microsoft.Reporting.WinForms.ServerReport.SetParameters(IEnumerable`1 parameters)\nat GridEditor.ReportViewerForm.btnRefresh_Click(Object sender, EventArgs e) \n                in D:\\TestApp\\ReportViewerForm.cs:line 79\nat System.Windows.Forms.Control.OnClick(EventArgs e)\nat System.Windows.Forms.Button.OnClick(EventArgs e)\nat System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\nat System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)\nat System.Windows.Forms.Control.WndProc(Message&amp; m)\nat System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)\nat System.Windows.Forms.Button.WndProc(Message&amp; m)\nat System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)\nat System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)\nat System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\nat System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)\nat System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager\n                        .FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\nat System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\nat System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\nat System.Windows.Forms.Application.Run(Form mainForm)\nat GridEditor.Program.Main() in D:\\TestApp\\Program.cs:line 16\nat System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)\nat System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\nat Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\nat System.Threading.ThreadHelper.ThreadStart_Context(Object state)\nat System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback\n                        , Object state, Boolean ignoreSyncCtx)\nat System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\nat System.Threading.ThreadHelper.ThreadStart()\n<\/code><\/pre>\n<p><strong>CustomCredentials:<\/strong><\/p>\n<pre><code>public class CustomCredentials : IReportServerCredentials\n{\n    public string UserName { get; set; }\n    public SecureString Password { get; set; }\n    public string Domain { get; set; }\n\n    #region ctor\n    public CustomCredentials(string password)\n    {\n        Password = new SecureString();\n        foreach (char c in password.ToCharArray())\n            Password.AppendChar(c);\n    }\n    #endregion\n\n    #region IReportServerCredentials Members\n    public bool GetFormsCredentials(out Cookie authCookie, out string userName\n                    , out string password, out string authority)\n    {\n        throw new NotImplementedException();\n    }\n\n    public System.Security.Principal.WindowsIdentity ImpersonationUser\n    {\n        get { throw new NotImplementedException(); }\n    }\n\n    public System.Net.ICredentials NetworkCredentials\n    {\n        get { return new NetworkCredential(UserName, Password, Domain); }\n    }\n    #endregion\n}\n<\/code><\/pre>\n<p><em><strong>UPDATE:<\/strong><\/em><\/p>\n<p>I have found following exception also in some place in my log file:<\/p>\n<pre><code>System.Web.Services.Protocols.SoapException: The path of the item \n'\/Students\/Attendance\/_vti_bin\/ListData.svc\/$metadata' is not valid. The full \npath must be less than 260 characters long; other restrictions apply. If the \nreport server is in native mode, the path must start with slash. ---&gt; \nMicrosoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException:\nThe path of the item '\/Students\/Attendance\/_vti_bin\/ListData.svc\/$metadata' is \n  not valid. The full path must be less than 260 characters long; other \n  restrictions apply. If the report server is in native mode, the path must \n  start with slash.\nat Microsoft.ReportingServices.WebServer.ReportingService2005Impl\n      .GetPermissions(String Item, String[]&amp; Permissions)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: I have SQL Server Express 2008 R2 installed with Advanced Services. I have created few reports using BI Design Studio and deployed them to the Server. If I access the reporting server using IE (http:\/\/Ser2008\/Reports\/) it works fine (I have to put in User Name\/Password). I can view reports or fool around with the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7306","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7306"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7306\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}