1

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 descriptiton: "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 136 
Marco Forberg
  • 2,634
  • 5
  • 22
  • 33
DipakM
  • 37
  • 6
  • to me it looks like you are trying to read some file inside the consructor of some of you form classes. You might be facing issues with different directories at design time. Disabling file access at design time could help. have a look at [this question](https://stackoverflow.com/questions/1166226/detecting-design-mode-from-a-controls-constructor/1166280) – Marco Forberg Apr 09 '18 at 07:23
  • Or move youre file to a specific folder and access it with an absolute path. – Marco Forberg Apr 09 '18 at 07:30
  • I believe Visual Studio is not able to copy folder\file EXTCONFIG\EXConfig.xml to the path required. How to do that? Or is there another way to copy the folder explicitly ? – DipakM Apr 09 '18 at 11:37
  • can you show the part of code where your constructor accesses the file – Marco Forberg Apr 10 '18 at 06:42
  • 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"); } – DipakM Apr 10 '18 at 08:13
  • 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 – DipakM Apr 10 '18 at 08:16
  • Using absolute path, it works but it will work for development computer only. The output files are attributable to other PCs – DipakM Apr 10 '18 at 08:30
  • the look up some method to check if you are in design mode. if yes then use the absolute path. if not use your normal file lookup – Marco Forberg Apr 10 '18 at 10:27

0 Answers0