Reynan
Reynan

Reputation: 163

Crystal report. "cannot find the path specified" in windows server 2008 using MVC

This is working properly in may computer but when i deployed it to client test server. this error pop up. the server is windows server 2008 standard edition. I already check the path of the rpt and install CRV and allow access to everyone. I spent almost 2 days and still can't find the solution.

Server Error in '/QC' Application.

The system cannot find the path specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Runtime.InteropServices.COMException: The system cannot find the path specified.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[COMException (0x80004005): The system cannot find the path specified.
]
   CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) +0
   CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) +1140
   CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext) +656
   CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options) +111
   CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportFormatType formatType) +99
   Sanipex.Infrastructure.Label.PrintToImage(String inputPath, String parameter, String outputPath, ImageFormat formatType) +482
   Sanipex.Controllers.WarehouseController.ScanLabel(Nullable`1 qty, Nullable`1 missinglabel, String txtdate, String product, Nullable`1 linenumber, Nullable`1 ordernumber, String btnsubmit, SessionData model, Cases casemodel) +17807
   lambda_method(Closure , ControllerBase , Object[] ) +465
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +182
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +225
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +99
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9631916
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

Upvotes: 5

Views: 30031

Answers (12)

Jay Taplin
Jay Taplin

Reputation: 570

I just spent the last five hours trying to figure out why two reports work great in dev but fail on the server. Originally they were sourced by views but I changed them out to use stored procedures, and that's where things went wrong (on the server only, though).

I'm just going to document (very simply) what I had to do to make these work:

My first problem was that the stored procedure was receiving NULL values for all parameters. This was because, when setting the report's connection (ODBC) to point to the server, the report lost its parameter mapping to the stored procedure. I needed to assign the name of the table to the table's TableName property before applying the logon info, then I needed to assign the name to the Location property of the table after:

foreach(var crTable in doc.Database.Tables) {
    crystalTableLogOnInfo = crTable.LogOnInfo;

    crystalTableLogOnInfo.ConnectionInfo.ServerName = strDSNName;
    crystalTableLogOnInfo.ConnectionInfo.DatabaseName = strDBName;
    crystalTableLogOnInfo.ConnectionInfo.UserID = strUserName;
    crystalTableLogOnInfo.ConnectionInfo.Password = strPassword;
    crystalTableLogOnInfo.TableName = crTable.Name; // this line
    crTable.ApplyLogOnInfo(crystalTableLogOnInfo);
    crTable.Location = crTable.Name;                // and this line
}

doc.VerifyDatabase();

Once I added those two lines, the stored proc received the parameter values, but then the report failed when I called its ExportToStream method. By chance I figured out that I needed to rename the table in the report. I had to do this because when I had swapped out the view for a stored procedure, Crystal effectively aliased the stored proc with the original view's name and I guess that, somewhere under the hood, Crystal uses the alias when it should be using the real underlying table/view/proc. Using the "Database Expert", I opposite-clicked on the name of my original view (under the "Selected Tables" box), selected "Rename", and changed it to the name of the stored procedure concatenated with a semicolon and the number 1, such as "spMyReportData;1".

Upvotes: 0

kmorgan26
kmorgan26

Reputation: 11

I know this is an old thread, but I had this same error when deploying to Windows Server 2016. It was working fine locally, but the "cannot find the specified path" error was thrown once I deployed to a server.

What I did to resolve my problem: I went to IIS, and created a virtual directory that pointed to the /AppName/bin/Reports folder where my report is located.

All is well!

Upvotes: 0

Farrah Jiang
Farrah Jiang

Reputation: 93

The error message usually means nothing. One of the cases I've met is that the query is not running properly in the oracle version installed on the environment. But it does run properly on the environment developed the report. Another case I've met is that one of the sub reports has used different data type for comparing in oracle, and seems some instances support while other will throw error. And they both just has the same uninformative error message.

Upvotes: 0

Christian Bopp
Christian Bopp

Reputation: 11

I had the same problem, but seeing that one report was working then I inspected your properties and compared with those that don't work. In fact the Crystal remain with the connectivity kind defined on developer machine and if on server don´t has that connectivity installed the application will fail. To correct this must change the kind of connectivity. In my case I replace SQLNCLI11 with SQLOLEDB.

On VS2015, select your report then go to menu "Crystal Reports" >> "Database" >> "Set database location", then expand Properties.

On "Provider" property change the type of connectivity. I put SQLOLEDB and my report work perfectly.

Upvotes: 1

rpgivpgmr
rpgivpgmr

Reputation: 1

The ODBC connections all need to be named the same even if the connections all point to the same connection. If you have a report with several subreports and any of the data connections are named differently, you will get the 'path not found' error.

Upvotes: 0

Nathan Koop
Nathan Koop

Reputation: 25197

This can be a misleading error.

In my case, the stored procedure for the report generally worked, but when passed a parameter in a certain format it would fail which would cause the The system cannot find the file specified exception.

Upvotes: 1

Newbie
Newbie

Reputation: 41

We had a similar problem with compiling our application on different machines. That was due to incorrect paths of subreports. Make sure the path to subreports are always reachable. That solved the problem on our side.

Upvotes: 0

rishabh bhalla
rishabh bhalla

Reputation: 55

Make sure your Crystal report don't have any formula field or any other that is link with the database that use are not connected. I have a same issue, i was adding some crystal report in my visual Studio project that is made by someone, i just change the SQL Query and making a ODBC connection to the database i want to connect and i think it should work fine. But i was getting error msg. "The system cannot find the path specified." After debugging into crystal report code again and again i came to know issue is in the Formula field. Finally issue solved. Thanks Happy Coding

Upvotes: 0

Untainted123
Untainted123

Reputation: 21

I had the same problem, and the fix for me was to make sure you have the same ODBC connection between the 2 machines. The file it is looking for in this case seems to be the ODBC connection parameters. Also, make sure you have the same settings between your machines regarding bitness. As in, 32bit ODBC settings vs 64bit ODBC settings must match the one CR is looking for.

Upvotes: 0

ceetheman
ceetheman

Reputation: 836

Found out that Crystal Report does that if we load the data for him. But providing the connection information makes it work.

var report = new ReportDocument();
report.Load("FILE PATH HERE");

report.SetParameterValue("@myParameter", "Value");

var connectionBuilder = new SqlConnectionStringBuilder(connectionString);

foreach (var connection in report.DataSourceConnections)
{
   if (connectionBuilder.IntegratedSecurity)
   {
       connection.SetConnection(connectionBuilder.DataSource, connectionBuilder.InitialCatalog, true);
   }
   else
   {
       connection.SetConnection(connectionBuilder.DataSource, connectionBuilder.InitialCatalog, connectionBuilder.UserID, connectionBuilder.Password);
       connection.IntegratedSecurity = false;
    }
}

return report.ExportToStream(ExportFormatType.PortableDocFormat);

Upvotes: 0

MANOJ GOPI
MANOJ GOPI

Reputation: 1279

Please check if you have chosen the Copy to Output Folder as "Copy Always" in the properties of the crystal report files under visual studio.

Copy to output folder

Try it in some other machine and if it works, then you can try re-installing the Crystal Report Viewer in Server 2008 machine.

In the development system you might have directly run so, there you will not be facing this error but while deploying you may experience these error.

Here is one solution for the given exception.

Upvotes: 1

Symeon Breen
Symeon Breen

Reputation: 1541

I have had similar issues with deploying crystal reports. The issue is usually installing the correct crystal reports runtime on the server, by correct I mean 32 or 64 bit - depending on how the iis website is set up.

the other issue is the user that the site is running as in IIS - make sure it does have access to where the files are located.

Upvotes: 3

Related Questions