Click here to Skip to main content
15,885,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My project solution contains all class library projects. I have used many User controls for UI. While trying to open design view, Visual studio shows error "To prevent possible data loss before loading the designer, the following errors must be resolved:

Error description: "Could not find a part of the path 'C:\Users\HP\AppData\Local\Microsoft\VisualStudio\14.0\ProjectAssemblies\4zyymhdz01\EXTCONFIG\EXConfig.xml'. "

Call Stack is

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at CallBacks.DataReader..ctor(String sFileName) in D:\SOURCE_CODE\Source\CallBacks\XmlDOMHelper.cs:line 24
at CallBacks.Hookfunction.GetImagePath() in D:\SOURCE_CODE\Source\CallBacks\Hookfunction.cs:line 302
at UserInterface.BaseFormClass..ctor() in D:\SOURCE_CODE\Source\UserInterface\BaseFormClass.cs:line


What I have tried:

C#
public string ReadRegistry() {
  RegistryKey rk = Registry.LocalMachine; 
  ConfigFile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\EXTCONFIG" + @"\EXConfig.xml"; 
  if (dataReaderCOnfig == null) dataReaderCOnfig = new DataReader(RConfigFile);
  return dataReaderCOnfig.GetValue("FDTXML"); 
}


The xml file is a config fie which contains path of images, templates, installation path etc. This file is kind of external configuration file for the project
Using absolute path, it works but it will work for development computer only. The output files are distributive to other PCs
Posted
Updated 10-Apr-18 18:29pm
v4

1 solution

In order to investigate where the file is trying to be loaded from, why not output the location you try to use to System.Diagnostics.Debug or even to the user control. This would help you to see where the path is pointing to and to adjust the code loading the file as needed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900