while testing getting problem in some system others working fine
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: xyz.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 54433673
Problem Signature 04: mscorlib
Problem Signature 05: 4.0.30319.17929
Problem Signature 06: 4ffa561c
Problem Signature 07: 43c4
Problem Signature 08: 105
Problem Signature 09: System.IO.DirectoryNotFound
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
I tries to Google
Problem Event Name: CLR20r3 and found following commands which i have executed successfully in command prompt with admin priority
regsvr32 atl.dll
cd C:\WINDOWS\eHome
ehSched /unregServer
ehSched /service
ehRecvr /unregServer
ehRecvr /service
ehRec.exe /unregServer
ehRec.exe /regserver
ehmsas.exe /unregServer
ehmsas.exe /regserver
but it didn't help. Then i tried to search
System.IO.DirectoryNotFound Exception causes but have found nothing suspicious in my code that have missing directory.
What could be the possible remedy of this problem? my environment specification is .NET 4.5
--Updated part--
Thanks to Mehdi Gholam who become source to trace error by putting Try catch over main() this is what i got.
System.IO.DirectoryNotFoundException: Could not find a part of the path
'C:\Users\hctnba\AppData\Local\abcde\pan.log'.
at System.IO._Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access,
Int32 right, Boolean useRight, FileShare share, Int32 bufferSize, FileOptions
options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFormProxy,
Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize)
at System.IO.File.Create(String path)
at UserSide.App_Code.LogFile.createLogFile()
at UserSide.App_Code.LogFile.writeLogFile(String lofFileOutput, String status)
at UserSide.formSplashScreen.ctor()
at UserSide.Program.Main()
After getting this i tried to create
C:\Users\hctnba\AppData\Local\abcde\pan.log file manually it didn't work. then i make file/folder accessibility authentication all(read/write/execute) to
hctnba (i.e. current user) and also to
everyone [However UAC is already disabled on system] even then it gives same error. why only in this system its not working fine but for others its working nicely.
System configuration (Hardware/Software/OS) are same for everyone.
-- Code Updation --
Following is the code which i am using to write log files. In above mentioned code i have changed the name of log file by some random name but in actual its created in
%LocalAppData%/getest/ folder with name of current system date.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;
namespace UserSide.App_Code
{
class LogFile
{
public static void writeLog(string logFileOutput, string status)
{
createLogFile();
DateTime currentDateTime = DateTime.Now;
string logTime = Convert.ToString(currentDateTime);
using (StreamWriter sw = File.AppendText(@getLogFilePath()))
{
sw.WriteLine(logTime + " | " + status + " | " + logFileOutput);
}
}
public static void createLogFile()
{
if (!File.Exists(getLogFilePath()))
{
File.Create(getLogFilePath()).Dispose();
}
}
public static string getLogFilePath(){
string logFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\gatesv";
DateTime today = DateTime.Today;
string logFileName = today.ToString("MM-dd-yyyy");
logFileName = logFileName + ".log";
logFilePath = logFilePath + "\\" + logFileName;
return logFilePath;
}
}
}
---- updated code that work fine -----
Thanks everyone to direct in correct direction. this was a minor problem by at the end the very suspected part was actual area that i should check very first. now code is working. Thanks once again
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;
namespace UserSide.App_Code
{
class LogFile
{
public static string logDirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\gatesv";
public static string logFileName = DateTime.Today.ToString("MM-dd-yyyy") + ".log";
public static string logFilePath = logDirPath + "\\" + logFileName;
public static void writeLog(string logFileOutput, string status)
{
if (!Directory.Exists(logDirPath))
{
Directory.CreateDirectory(logDirPath);
}
if (!File.Exists(logFilePath))
{
File.Create(logFilePath).Dispose();
}
string logTime = Convert.ToString(DateTime.Now);
using (StreamWriter sw = File.AppendText(@logFilePath))
{
sw.WriteLine(logTime + " | " + status + " | " + logFileOutput);
}
}
}
}