Skip to content

Get FileNotFoundException when create App.config file in .NET Core Console App Project #2402

@JoyceLiang

Description

@JoyceLiang

My code call Microsoft.VisualStudio.Editors.WCF.Configuration.VSApplicationConfiguration.QueryEditConfiguration() to get/generate config file for current project. In .NET Core Console App, I expected App.config be created after that, but get a FileNotFoundException.

I also found below project types have same problem

  • Class Library (.NET Core)
  • Unit Test Project (.NET Core)
  • xUnit Test Project (.NET Core)
  • ASP .NET Core Web Application (.NET Core) with template "Empty"
  • Class Library (.NET standard)
  • ASP.NET Core Web Application (.NET Framework) with template "Empty"

For UWP project, the conifg file app.config can be created successfully.

My VS version is 15.3 26604.2 d15prerel.

=================================================
System.IO.FileNotFoundException: 'The system cannot find the file specified. (Exception from HRESULT: 0x80070002)'

    Microsoft.VisualStudio.ProjectSystem.Managed.VS.dll!Microsoft.VisualStudio.ProjectSystem.VS.CreateFileFromTemplateService.CreateFileAsync(string templateFile, string parentDocumentMoniker, string fileName)	Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext(object stateMachine)	Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()	Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()	Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()	Unknown
Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.JoinableTaskFactory.SingleExecuteProtector.TryExecute()	Unknown
Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()	Unknown
Microsoft.VisualStudio.ProjectSystem.Implementation.dll!Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously(System.Func<System.Threading.Tasks.Task> asyncAction)	Unknown
Microsoft.VisualStudio.ProjectSystem.VS.Implementation.dll!Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.HrInvoke.AnonymousMethod__0()	Unknown
Microsoft.VisualStudio.ProjectSystem.VS.dll!Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke.AnonymousMethod__0()	Unknown
Microsoft.VisualStudio.ProjectSystem.VS.dll!Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke(System.Func<Microsoft.VisualStudio.ProjectSystem.VS.HResult> action, System.IServiceProvider vsShellServiceProvider, Microsoft.VisualStudio.ProjectSystem.IProjectFaultHandlerService projectFaultHandlerService, Microsoft.VisualStudio.ProjectSystem.UnconfiguredProject project)	Unknown
Microsoft.VisualStudio.ProjectSystem.VS.Implementation.dll!Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.HrInvoke(System.Func<System.Threading.Tasks.Task> asyncAction, bool registerProjectFaultHandlerService)	Unknown
Microsoft.VisualStudio.ProjectSystem.VS.Implementation.dll!Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.GetFile(int fileId, uint flags, out uint itemidParam, out string fileNameParam)	Unknown
Microsoft.VisualStudio.ProjectSystem.VS.Implementation.dll!Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNodeWrapper.GetFile(int fileID, uint grfFlags, out uint pitemid, out string pbstrFilename)	Unknown
[Native to Managed Transition]	
[Managed to Native Transition]	
Microsoft.VisualStudio.Editors.WCF.dll!Microsoft.VisualStudio.Editors.WCF.Configuration.ProjectConfigurationFile.EnsureExists()	Unknown
Microsoft.VisualStudio.Editors.WCF.dll!Microsoft.VisualStudio.Editors.WCF.Configuration.VSApplicationConfiguration.QueryEditConfiguration()	Unknown

Microsoft.VisualStudio.ConnectedServices.Package2.dll!Microsoft.VisualStudio.ConnectedServices.ConfigHelpers.EditableXmlConfigImplementation.EditableXmlConfigImplementation(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy projectHierarchy) Line 35 C#

Metadata

Metadata

Assignees

No one assigned

    Labels

    Triage-Won't-FixThe bug is minor, against project direction or the risk of fixing it outweighs the benefit.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions