Load Report Failed (Invalid Report File Path) - asp.net

I have old Asp.net web application (Visual Studio 2005) deployed in Windows Server 2012 and it runs for years. Now, we are encountering "Load report failed - Invalid Report File Path" error. Then I checked the code if the .rpt file has correct path and the actual .rpt file is already in the web server and yet, it was there. Ever since we are encountering this error, we just recycling the App pool of the application in IIS and the app runs smoothly again.
Any ideas on how this issue prevent from recurring?
Here's the snippet of my code:
reportPath = Server.MapPath("~\crm-DailyActualSalesCompressed.rpt")
pReportDoc.Load(reportPath)
pReportDoc.SetDatabaseLogon(myConInfo.UserID, myConInfo.Password, myConInfo.ServerName,
myConInfo.DatabaseName)

As the error message said you are wrong on your path, this backslash ”\” is for physical path and this slash “/” is for relative url’s which needs to mapped by Server.
So in order to read your CR file you can do that in two ways that depends on your pReportDoc what kind of Object/type is:
If is a backend object you can do that:
reportPath = Request.PhysicalApplicationPath & "crm-DailyActualSalesCompressed.rpt"
pReportDoc.Load(reportPath)
pReportDoc.SetDatabaseLogon(myConInfo.UserID, myConInfo.Password, myConInfo.ServerName, myConInfo.DatabaseName)
If pReportDoc is a kind of WebControl or something elese you can do that:
reportPath = Server.MapPath("~/crm-DailyActualSalesCompressed.rpt")
pReportDoc.Load(reportPath)
pReportDoc.SetDatabaseLogon(myConInfo.UserID, myConInfo.Password, myConInfo.ServerName, myConInfo.DatabaseName)
Obviously you need to know also if you CR file is on root (as seems) or included in other nested paths

Related

Server.MapPath() on IIS8.5 in Windows 2012 Server giving Object Doesnt Support this Property or method

I am trying to implement a Classic ASP Project on II8.5 on Windows Server 2012 R2.
While launching the DashBoard.asp, Getting error
Object Doesnt Support Property or method : Server.MapPath("\")
The Project is working fine on IIS7.5 on Windows 2008 Server R2. But Failing on II8.5. Have Done all the respective setting Required for Classic ASP to execute on IIS8.5 server, Still getting the same issue.
Can Anybody Guide, Why Server Object Methods are not getting recognized on IIS8.5?
Edit: New approach
looking at the code, you have following line that fails in global.asa Application_OnStart:
Call setXDefInApplicationScope(Server.MapPath("fb/infra/server/XDef"))
Maybe setXDefInApplicationScope is not defined in this context, but resides in an included file that does not apply in Application_OnStart
Edit: second option (ruled out by comments)
I would guess, you have created a variable named "server" in the context, that overwrites the Server object you think you are using.
class clsServer
public foo
end class
dim server
set server = new clsServer
Response.Write Server.MapPath("/") ' will raise the error
I guess, it may not be that obvious in your setup, could be in any included file. More importantly, if you did not specify option explicit as you should, there must not even exist a dim.

System.Web.HttpException Could not load type '[namespace].???'

This started as Could not load type 'Global' error. After I tried a few things and getting no where I deleted the Global.asax file and now the error is Could not load type '[namespace].???'
Where ??? is the class name of every page I try to load
The web site (when executed within VS2008, local dev computer) works fine but once published (with no errors) and deployed to the server gives me Could not load type '[namespace].???' error
I did install elmah and I was able to get more details for this "generic" Could not load type '[namespace].???' error
elmah reports a HTTP error 500 :
System.Web.HttpException Could not load type '[namespace].???' ->
System.Web.HttpParseException: Could not load type '[namespace].???'
Any ideas?
I have checked the "basics"
References
Doing a clean and a build
Checking the Inherits attr in the HTML against the code behind
UPDATE #1
I did deploy the site to a different DEV computer (configured IIS, virtual folder, etc.) and it works. When I use the same published code on the server, get the generic Could not load type '[namespace].???' error
UPDATE #2
I created a test web app. One form (Default.aspx) with a button. The click event does a Response.Write("Hello World"); I moved this app to the server and guess what, I get the Could not load type TestSite._Default
UPDATE #3
According to the fusion log viewer, these two websites are attempting to load CppCodeProvider and VJSharpCodeProvider, but I have no references to any of these. After a Google search, I found this post
I checked and I have no references to JAVA files. Still don't know what the problem is
Strangely enough, sometimes we get this error when the disk is full.
Make sure the project file is uploaded to the build server along with the added files. VS will add lines to this file that points to the new files location.
<Content Include="xxx.aspx" />
<Compile Include="xxx.aspx.cs">
<DependentUpon>xxx.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
Without the updated project file it will not find the code behind.
Really weird, maybe you should try to test it in a different server, this happens for example when you are using in you dev environment some namespaces from .NET 4.5 and you haven't installed the same framework in your server, so maybe the error is related to this behavior, if you are not using any third dll in your web application outside Microsoft's framework, so should try to reinstall the framework, I don't think the problem is related to visual studio.

What is the process involved in viewing a webservice in a browser from within visual studio?

I have created a new VS2008 ASP.Net Web service project, with the default name WebService1. If I right click on the Service1.asmx file and select 'View in Browser' what are the processes that go on to make this happen? I am asking because I have a situation where when I run this from a visual studio project started in our development shell (which sets up a common build environment) I cannot get the web service to show up in the browser.
It starts the asp.net development server and creates a single file:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\c43ddc22\268ae91b\hash\hash.web
but when I start it from a stand alone project i get a whole slew of files in here:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\edad4eee\d198cf0e\App_Web_defaultwsdlhelpgenerator.aspx.cdcab7d2.vicgkf94.dll
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\edad4eee\d198cf0e\service1.asmx.cdcab7d2.compiled
etc etc
I am trying to debug this but not really getting anywhere. i have inspected the output from VS but the only option I get is for the build output, which is basic and doesn't really contain any information that is useful. I have tried running both versions with DebugView running but no output there either.
I would like to know if there are any log files I could look at, or if anyone has any suggestions on how I might be able to debug what is going wrong here?
For completeness the output I get when it doesn't work is:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not create type 'WebService1.Service1'.
Source Error:
Line 1:
Source File: /Service1.asmx Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082
Ok, not sure that its perfect but I found a resolution to this issue. the problems seems to be that the development shell redirects the <OutputPath> of the projects visual studio is building, and this was causing problems as, although the dependencies of the web service project were being copied into the $(ProjectDir)Bin\ directory, the actual webservice dll itself was not. The solution (workaround?) seems to be to add this to the post build event command line:
xcopy /y "$(TargetPath)" "$(ProjectDir)Bin\"
Then i am able to right click on the .asmx file and select view in browser and everything works as expected.
Hope this might help someone else in the future. or maybe even me in another place and time.

ASP.NET Stack Trace Question

This is something that I have been curious about for a bit, but have never found the solution to:
After I publish an application to a server, if it throws an error, the Stack Trace still contains references to my local environment. E.G.:
at [appname].dropdown.OnLoad(EventArgs e) in C:\Documents and Settings\[user]\Desktop\[solution]\[project]\dropdown.cs:line 74
Why does it refer to my local paths instead of the servers paths of these objects?
Thanks.
As the debug information contains the file name at the moment that it was compiled. It's just a text value, it's not updated with the path of the actual file.
The actual name of the file wouldn't be very useful anyway, as that would be some generated file name somewhere in the .NET cache folder.
It's probably because you published a compiled version built on your machine.

Visual Studio 2008 Generation of Designer File Failed (Cannot use a leading .. to exit above the top directory)

It seems the universe is against me this week. I have been happily coding away on my ASP.Net application for weeks now without issues. Today I tried to add a textbox to a form, and on saving the form, I received the following error:
Generation of designer file failed: Cannot use a leading .. to exit above the top directory
I googled, but with no luck. I did find a blog post that shows how to add a key into the registry so that Visual Studio logs more detail about these errors, and the following is what shows up in the generated log file:
-------------------------------------------------------------
C:\[path to aspx file]\PageName.aspx
Generation of designer file failed: Cannot use a leading .. to exit above the top directory.
-------------------------------------------------------------
System.Web.HttpException: Cannot use a leading .. to exit above the top directory.
at System.Web.Util.UrlPath.ReduceVirtualPath(String path)
at System.Web.Util.UrlPath.Reduce(String path)
at System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative)
at System.Web.VirtualPath.Combine(VirtualPath relativePath)
at System.Web.VirtualPath.Combine(VirtualPath v1, VirtualPath v2)
at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)
at Microsoft.VisualStudio.Web.Application.Parser.BeginParse(String virtualPath, String text)
at Microsoft.VisualStudio.Web.Application.Generator.UpdateDesignerClass(String document, String codeBehind, String codeBehindFile, String[] publicFields, UDC_Flags flags)
-------------------------------------------------------------
And, of course this means that there is no way I can reference the newly added text box from the code behind.
I thought it might be just this page giving the issue, but I have tried three other pages with the same result. I haven't changed the environment for weeks, so I am not sure how this happens.
Any ideas out there?
Thanks in advance
Hamish
For anyone that has the same problem in the future, here is what caused it...
When debugging the application, instead of using VS's built in web server, I was using IIS. For some reason, this caused the above error. I changed the app to use the built in web server, ran it, and then reverted it back to the IIS settings, and all was good.
Not sure why it happened, perhaps something went a little haywire in the plumbing. I'm just glad its back and working.
Generation of designer file failed:
Cannot use a leading .. to exit above
the top directory.
What a wonderful error message!
I had this problem when I clicked on the designer view of a web user control in VS 2010.
In my case I noticed that the ascx file icon was showing a blue mark in the bottom left corner.
I clicked on the properties and found that the files (ascx, ascx.cs and ascx.cs.designer.cs) were not in the project path but on my desktop.(I don't know how that happened)
This seemed to line up with the usual cryptic MS error message relating to directory.
To fix this I removed the files from the project (ascx, ascx.cs and ascx.cs.designer.cs) then added a new Web User Control to the project with the required name and copied the contents back in from the files on my desktop.
So check your file paths if you see
this error message.
Change the solution configuration from Release to Debug.
It's working now for me.
Check the output of the Web project based on your configuration (Release, Debug, ..) and platform (Any CPU, x86, ..).
In my case, this output folder was set to bin/ and after adding a new configuration for x86 platforms this option was set to bin/x86/Debug or bin/x86/Release. And these errors started to appear when adding new files to project.

Resources