Failed to map the path '/'. .net 4.0 - c#

I have a .net app that I just opened on in visual studio 2010 and converted to 4.0 when it asked me on start-up. I go to try to build the site, and I get this error:
Failed to map the path '/'.
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.
[InvalidOperationException: Failed to map the path '/'.]
System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +8804446
System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath) +42
System.Web.VirtualPath.MapPathInternal() +4
System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) +107
System.Web.HttpRequest.MapPath(VirtualPath virtualPath) +37
System.Web.HttpServerUtility.MapPath(String path) +99
NU.WorkManagement.Lookup.Lookups..ctor() +82
NU.WorkManagement.Engine.GlobalModule.Init(HttpApplication application) +624
System.Web.HttpApplication.InitModulesCommon() +80
System.Web.HttpApplication.InitModules() +43
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +828
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +304
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +327
I tried the most popular solution I found vis google (replace and ../ with ~/ but there wern't any...)
Update:
Lookups constructor:
public Lookups()
{
_dirPath = System.Web.HttpContext.Current.Server.MapPath("/") + _xmlPath;
}

I know it's and old question, but for the record if you are running against IIS then
'iisreset' in the console may help resolving "Failed to map the path '/'." issue. I had this problem after renaming the sites in IIS.

I was just trying to go through an exercise in a Microsoft Step By Step book and I hit this problem when trying to precompile an ASP.NET appliction.
Here's how I got past this - and it took me a day to figure out!
When you open the Visual Studio Command Prompt to do your build/precompile, you must right-click and choose "Run As Administrator".
That's all it took for me when trying to run this aspnet_compiler -v DeployThis C:\DeployThis -f -u

Try System.Web.HttpContext.Current.Server.MapPath("~/"). Notice the ~.

We had the same problem, IISRESET didn't do it.
It turned out that the Virtual Directory we trying to map has a double backslash (d:\folder\\subfolder\) in the naming (IIS virtual directory was created with powershell script). Removing the extra backslash made HostingEnvironment.MapPath stop throwing exceptions.
Just in the case this could help somebody :-)

Related

Unreal Engine build crashes at C# trying to open Recycle Bin file

This boggles my mind, to the point that I wonder if isn't an SDK problem.
I share an Unreal Engine (4.26) game with a (non-technical) colleague through Git. Today he received his first code files from me, and to compile it, I had him install the SDKs(windows, .Net, C++ gaming, Visual Studio) and call Generate Visual Studio Project Files. It all generated just fine.
EDIT:
Emptying the recycle bin somehow fixed it, but now the problem repeats itself:
ERROR: Unhandled exception: System.UnauthorizedAccessException: Access to the path 'D:\System Volume Information' is denied.
So this entirely seems like a permission level problem to me, but I asked him to enable developer mode, to uncheck every read-only on Epic Games and Unreal Engine, and to run it in administrator mode. Nothing works. I don't see how we can get any more permissions than this.
Former message:
ERROR: Unhandled exception: System.UnauthorizedAccessException: Access to the path 'D:$RECYCLE.BIN\S-1-5-18' is denied.
Full logfile(minus some cleanup on my part):
Log file open, 04/17/21 12:00:08
LogInit: LLM is enabled
LogInit: LLM CsvWriter: off TraceWriter: off
LogInit: Display: Running engine for game: Naptin
LogPlatformFile: Not using cached read wrapper
LogTaskGraph: Started task graph with 5 named threads and 35 total threads with 3 sets of task threads.
LogStats: Stats thread started at 5.907298
LogD3D11RHI: Loaded GFSDK_Aftermath_Lib.x64.dll
LogICUInternationalization: ICU TimeZone Detection - Raw Offset: -5:00, Platform Override: ''
LogPluginManager: Mounting plugin MeshPainting
.....lots of LogPluginManager......
LogPluginManager: Mounting plugin SteamVR
LogXGEController: Cleaning working directory: C:/Users/adpar/AppData/Local/Temp/UnrealXGEWorkingDir/
LogXGEController: Cannot use XGE Controller as Incredibuild is not installed on this machine.
LogInit: Warning: Incompatible or missing module: Naptin
Running D:/.........UNREALENGINEFOLDER/UE_4.26/Engine/Binaries/DotNET/UnrealBuildTool.exe Development Win64 -Project="D:/....UNREAL/Naptin/Naptin/Naptin.uproject" -TargetType=Editor -Progress -NoEngineChanges -NoHotReloadFromIDE
Using 'git status' to determine working set for adaptive non-unity build (D:\....UNREAL\Naptin\Naptin).
Creating makefile for NaptinEditor(no existing makefile)
#progress push 5%
Parsing headers for NaptinEditor
Running UnrealHeaderTool "D:\....UNREAL\Naptin\Naptin\Naptin.uproject" "D:\....UNREAL\Naptin\Naptin\Intermediate\Build\Win64\NaptinEditor\Development\NaptinEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\Users\adpar\AppData\Local\UnrealBuildTool\Log_UHT.txt" -installed
Reflection code generated for NaptinEditor in 23.9260389 seconds
#progress pop
ERROR: Unhandled exception: System.UnauthorizedAccessException: Access to the path 'D:\$RECYCLE.BIN\S-1-5-18' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.DirectoryInfo.EnumerateFiles()
at Tools.DotNETCommon.FileFilter.FindMatchesFromDirectory(DirectoryInfo CurrentDirectory, String NamePrefix, Boolean bIgnoreSymlinks, List`1 MatchingFileNames) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\DotNETCommon\DotNETUtilities\FileFilter.cs:line 487
at Tools.DotNETCommon.FileFilter.FindMatchesFromDirectory(DirectoryInfo CurrentDirectory, String NamePrefix, Boolean bIgnoreSymlinks, List`1 MatchingFileNames) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\DotNETCommon\DotNETUtilities\FileFilter.cs:line 495
at Tools.DotNETCommon.FileFilter.FindMatchesFromDirectory(DirectoryInfo CurrentDirectory, String NamePrefix, Boolean bIgnoreSymlinks, List`1 MatchingFileNames) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\DotNETCommon\DotNETUtilities\FileFilter.cs:line 495
at Tools.DotNETCommon.FileFilter.ApplyToDirectory(DirectoryReference DirectoryName, Boolean bIgnoreSymlinks) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\DotNETCommon\DotNETUtilities\FileFilter.cs:line 408
at Tools.DotNETCommon.FilePattern.CreateMapping(HashSet`1 Files, FilePattern& SourcePattern, FilePattern& TargetPattern) in D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\DotNETCommon\DotNETUtilities\FilePattern.cs:line 340
at UnrealBuildTool.UEBuildBinary.PrepareRuntimeDependencies(List`1 RuntimeDependencies, Dictionary`2 TargetFileToSourceFile, DirectoryReference ExeDir) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildBinary.cs:line 294
at UnrealBuildTool.UEBuildTarget.Build(BuildConfiguration BuildConfiguration, ISourceFileWorkingSet WorkingSet, Boolean bIsAssemblingBuild, List`1 SpecificFilesToCompile) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 1786
at UnrealBuildTool.BuildMode.CreateMakefile(BuildConfiguration BuildConfiguration, TargetDescriptor TargetDescriptor, ISourceFileWorkingSet WorkingSet) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 615
at UnrealBuildTool.BuildMode.Build(List`1 TargetDescriptors, BuildConfiguration BuildConfiguration, ISourceFileWorkingSet WorkingSet, BuildOptions Options, FileReference WriteOutdatedActionsFile, Boolean bSkipPreBuildTargets) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 257
at UnrealBuildTool.BuildMode.Execute(CommandLineArguments Arguments) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 226
at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 550
LogInit: Warning: Still incompatible or missing module: Naptin
LogCore: Engine exit requested (reason: EngineExit() was called)
LogExit: Preparing to exit.
LogExit: Exiting.
Log file closed, 04/17/21 12:02:43
We have tried a few things, like generating again, or copypasting all of our assets to a new project: if we copy the assets, all good, if we copy the code, the same crash.
This happens only on his machine, so I'm kind of at a loss for words. He did not delete any files, the only difference between his machine and mine is that his SDK is more up-to-date by a few weeks.
I'd really appreciate any clue regarding why this file comes up in the build or how to stop it from crashing. The C++ code doesn't seem to be the issue at all, and he can't start Unreal Engine anymore.

Why do I keep getting "Safe handle has been closed" error for even a simple Hello World Universal Windows Platform Application in Visual Studio?

I keep getting the following error whenever I open the MainPage.xaml by the xaml editor.
I actually get this error for almost all of my apps.
System.ObjectDisposedException
Safe handle has been closed
at Microsoft.VisualStudio.DesignTools.HostUtility.Platform.AppContainerProcessDomainFactory.CreateDesignerProcess(String applicationPath, String clientPort, Uri hostUri, IDictionary environmentVariables, Int32& processId, Object& processData)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.ProcessDomainFactory.ProcessIsolationDomain..ctor(ProcessDomainFactory factory, IIsolationBoundary boundary, AppDomainSetup appDomainInfo, IIsolationTarget isolationTarget, String baseDirectory)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.ProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
at Microsoft.VisualStudio.DesignTools.HostUtility.Platform.AppContainerProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.Initialize()
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.CreateInstance[T](Type type)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedObjectFactory.Initialize()
at Microsoft.VisualStudio.DesignTools.DesignerHost.Services.VSIsolationService.CreateObjectFactory(IIsolationTarget isolationTarget, IObjectCatalog catalog)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
at Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.CreateLease(IIsolationTarget isolationTarget, CancellationToken cancelToken, DesignerServiceEntry& entry, IServiceProvider serviceOverrides)
at Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.InvokeWithCulture[T](CultureInfo culture, Func`2 func, CancellationToken cancelToken)
at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.<>c__DisplayClass10_0`1.<StartTask>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
There is a similar issue with you on this link, and it is solved by upgrade the visual studio. You can try solutions in that link, please also try the following steps to try to resolve your issues:
Restart the machine.
Check the Visual Studio 2015 System Requirements to see if your environment meet the requirements. If it doesn't meet requirement, you might need to upgrade it.
Create a new blank UWP project to see if it will work.
Try to repair your Visual Studio.
Re-install the windows 10 SDK.
If all above cannot resolve your issue I'm afraid you need to re-install your visual studio.
I finally got it fixed by a weird method.
I switched from developer mode to sideloading enabled mode and tried to reload the designer which failed saying I need a developer license to do so. I then reverted back to developer mode and again tried to reload the designer. This time it worked.
Now I have to perform the above steps for every project which failed to load(including new projects) to load them successfully.
Once the XAML designer loads successfully for a project, it will surely load successfully every time subsequently.

Continuous Integration build succeeds, Manual build fails

My Team Project consists of a Web Forms application and WCF Services, in two separate solutions (the WCF services are hosted on a server within the domain, the web app is in the DMZ).
I have two build definitions for my Team Project: a CI build and a manual build
Yesterday I merged a branch back into my trunk to prepare for a deployment. When I checked in my merge the CI build kicked off...and succeeded. So then I queued the manual build (the manual build is what ends up on prod server). The manual build failed. It fails everytime I run it now, however the CI build succeeds every time. The error from the build log is pasted below. I don't know how I broke this build, and I'm confused as to why the CI build succeeds but the manual build fails (same build definition except the drop location is different and the trigger is different).
Error:
Exception Message: Access to the path 'C:\Builds\1\My Web App\My Web
App\Sources\MyAppWcfServices\Services\Messages' is denied. (type
UnauthorizedAccessException) Exception Stack Trace: at
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator1.CommonInit() at
System.IO.FileSystemEnumerableIterator1..ctor(String path, String
originalUserPath, String searchPattern, SearchOption searchOption,
SearchResultHandler`1 resultHandler, Boolean checkHost) at
System.IO.Directory.InternalGetFileDirectoryNames(String path, String
userPathOriginal, String searchPattern, Boolean includeFiles, Boolean
includeDirs, SearchOption searchOption, Boolean checkHost) at
System.IO.Directory.InternalGetDirectories(String path, String
searchPattern, SearchOption searchOption) at
Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String
path) at
Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String
path) at
Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String
path) at
Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String
path) at
Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectory(String path,
Boolean recursive) at
Microsoft.TeamFoundation.Build.Workflow.Activities.DeleteDirectory.Execute(CodeActivityContext
context) at
System.Activities.CodeActivity.InternalExecute(ActivityInstance
instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at
System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor
executor, BookmarkManager bookmarkManager, Location resultLocation)
Things I've read/tried:
TFS 2012 Build "Access to Path Denied"
Tool to find duplicate copies in a build (I didn't run the tool,
couldn't find a log file named like the example...confused)
I do not have my obj or bin directories in version control.
This build definition has been working great for months, up until yesterday. I'm not sure what happened when I merged that would've caused this. There were no conflicts in my merge, it was easy peasy....until I tried to build.
just go to the Build controller server and stop the "Visual Studio Team Foundation Build Service Host 2013" and delete the Files or folder which you have the error in your message and start the service again
Have you checked if the actual file is locked? try a tool like unlocker http://www.emptyloop.com/unlocker
I have seen this error happening when a particular folder/file is opened in iexplorer/cmd.exe etc (either by you or some other user). When TFS tries to clean up the directory and get the latest file, it will fail as it is used by another process.
If you have access to the server, then open the taskmanager -> process and close all the iexplorer.exe/cmd.exe process from other users. Hopefully that will fix it.

Client Version Error after installing Azure 1.8

I recently installed the Azure SDK 1.8 on my machine but am still using a project that is running version 1.7.1 (June 2012 SP1 for VS2012). Since I did this, every time I try to run my project I get the following error:
ErrorCode<ERRCA0019>:SubStatus<ES0001>:Check the client version. It should be within the allowed version range on the server. If necessary, upgrade the client to the allowed version.
[DataCacheException: ErrorCode<ERRCA0019>:SubStatus<ES0001>:Check the client version. It should be within the allowed version range on the server. If necessary, upgrade the client to the allowed version.]
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination) +767
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination) +149
Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable`1 servers, RequestBody request, Func`3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy) +967
Microsoft.ApplicationServer.Caching.WcfClientProtocol.Initialize(IEnumerable`1 servers) +606
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate) +1103
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +131
Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +356
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +447
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +315
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.ResetItemTimeout(HttpContext context, String id) +59
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +707
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12600474
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
I have not had much luck finding a solution. Some forums have mentioned using a different AppFabric version, but they all seem to be referring to running it in the actual Azure cloud service and I can't even get it to run on my local machine.
Any thoughts?
I ran into a similar problem while upgrading to the October 2012 release. I resolved it by removing all the caching references in my project, and then installing the Windows Azure Shared Caching package from NuGet.
I'm not sure if the resulting project will still run with the June 2012 SDK. But it's worth a try.

The given key was not found error on ServiceStack

Suddenly, I've started to get error in my ServiceStack MVC service application as below :
{"The given key was not present in the dictionary."}
System.Exception {System.Collections.Generic.KeyNotFoundException}
and StackTrace:
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at ServiceStack.WebHost.Endpoints.Utils.FilterAttributeCache.GetRequestFilterAttributes(Type requestDtoType) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Utils\FilterAttributeCache.cs:line 44
at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyRequestFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object requestDto) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\EndpointHost.cs:line 201
at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\RestHandler.cs:line 79
at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.ProcessRequest(HttpContext context) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Support\EndpointHandlerBase.cs:line 150
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I've no idea about the error or what wrong is. My app was working and now not working.
Any idea how to fix this ?
EDIT 1: When I navigate the service url in my webbrowser,the debugger never reaches to my service classes and Run methods.
Well, quite strange!
Here are the actions I took and did not work.
Restart IIS and VS 2010.
Compile the code and debug on VS 2010.
Compile the code and replace with the content on IIS and restart IIS again.
Here are the action I took and the project started to work again.
Create a new MVC project.
Install ServiceStack MVC via NuGet.
Copy existing codes to new project.
Rename the namespace in existing code on the new project.
Debug on VS2010 and project started to work like a charm.
When I published the project to the the existing WebSite on IIS , I got the error below :
AppHost instance has been already set
However, to pass the error, I've deleted the existing website and created a new one.
Than, I've copied the new project output in the new website.
All started work like a charm again.
But I still don't know why I got the errors.
I hope this will help who may have the same problems.
I received this error from using the wrong model in the routes.
So:
Routes.Add<ModelA>("/path/to/service");
Should be
Routes.Add<ModelB>("/path/to/service");

Categories