(1) Encrypt console app. (2) Decode app.=> Decrypt (3) LocalSettings uses MemStream (4) PaddingMode.Zeros, ver. 2.18.1270

This commit is contained in:
Milan Hanajik 2019-07-17 06:47:08 +02:00
parent e98d633d7f
commit e622718c27
16 changed files with 385 additions and 175 deletions

6
.gitignore vendored
View File

@ -1,11 +1,13 @@
Config/bin/
Config/obj/
Decode/bin/
Decode/obj/
Decrypt/bin/
Decrypt/obj/
DeviceTest/bin/
DeviceTest/obj/
Dirichlet.Numerics/bin
Dirichlet.Numerics/obj
Encrypt/bin/
Encrypt/obj/
GemCard/bin
GemCard/obj
GraphLib/bin

View File

@ -1,107 +0,0 @@
using System;
using System.IO;
using System.Security.Cryptography;
namespace Decode
{
class Program
{
static byte[] cryptoKey = new byte[] { 235, 7, 236, 58, 24, 225, 97, 102, 231, 1, 121, 12, 177, 145, 87, 200,
102, 85, 152, 73, 230, 203, 101, 169, 242, 213, 228, 219, 239, 157, 245, 156 };
static byte[] cryptoIV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
static void Main(string[] args)
{
if ((args.Length < 1) || !File.Exists(args[0]))
{
Console.WriteLine("Usage: Decode <file>");
Console.ReadKey();
return;
}
string fileName = args[0];
try
{
using (StreamReader reader = new StreamReader(fileName))
{
if (reader.ReadLine().StartsWith("<?xml version="))
{
Console.WriteLine(string.Format("File {0} was not encrypted.", fileName));
Console.ReadKey();
return;
}
}
bool successful = false;
Stream stream = File.OpenRead(fileName);
using (BinaryReader binaryReader = new BinaryReader(stream))
{
int length = (int)(new FileInfo(fileName).Length);
/// Load encrypted binary data into an array
byte[] encrypted = new byte[length];
int bytesRead = binaryReader.Read(encrypted, 0, length);
if (bytesRead != length)
{
Console.WriteLine(string.Format("Failed to read file {0}.", fileName));
Console.ReadKey();
return;
}
using (RijndaelManaged myRijndael = new RijndaelManaged())
{
/// Create a decryptor to perform the stream transform.
ICryptoTransform decryptor = myRijndael.CreateDecryptor(cryptoKey, cryptoIV);
/// Create the streams used for decryption.
using (MemoryStream msDecrypt = new MemoryStream(encrypted))
{
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
using (TextWriter writer = new StreamWriter(fileName + ".plain"))
{
writer.Write(srDecrypt.ReadToEnd());
successful = true;
}
}
}
}
}
}
if (successful)
{
/// Decoding the file was successfuly completed => rotate files
if (File.Exists(fileName + ".bak")) File.Delete(fileName + ".bak");
File.Move(fileName, fileName + ".bak");
File.Move(fileName + ".plain", fileName);
return;
}
else
{
Failed(fileName);
return;
}
}
catch (Exception)
{
Failed(fileName);
return;
}
}
static void Failed(string fileName)
{
if (File.Exists(fileName + ".plain"))
{
File.Delete(fileName + ".plain");
}
Console.WriteLine(string.Format("Decoding file {0} failed.", fileName));
Console.ReadKey();
}
}
}

View File

@ -8,8 +8,8 @@
<ProjectGuid>{D476ABBE-A455-4476-8A8D-3F6151217B51}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Decode</RootNamespace>
<AssemblyName>Decode</AssemblyName>
<RootNamespace>Decrypt</RootNamespace>
<AssemblyName>Decrypt</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
@ -35,7 +35,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Decode.Program</StartupObject>
<StartupObject>Decrypt.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />

96
Decrypt/Program.cs Normal file
View File

@ -0,0 +1,96 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Decrypt
{
/// <summary>
/// See also:
/// https://www.fluxbytes.com/csharp/encrypt-and-decrypt-files-in-c/
/// </summary>
class Program
{
static byte[] key = new byte[] { 83, 254, 105, 64, 184, 201, 195, 127, 52, 99, 77, 45, 252, 132, 163, 156 };
static byte[] IV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
static void Main(string[] args)
{
if ((args.Length < 1) || !File.Exists(args[0]))
{
Console.WriteLine("Usage: Decode <file>");
Console.ReadKey();
return;
}
string fileName = args[0];
string intermediateFile = fileName + ".plain"; /// Intermediate file, output of cryptography decoding
string backupFile = fileName + ".bak";
try
{
using (StreamReader reader = new StreamReader(fileName))
{
if (reader.ReadLine().StartsWith("<?xml version="))
{
Console.WriteLine(string.Format("File {0} is not encrypted.", fileName));
Console.ReadKey();
return;
}
}
bool successful = false;
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
using (FileStream fsCrypt = new FileStream(fileName, FileMode.Open))
{
using (FileStream fsOut = new FileStream(intermediateFile, FileMode.Create))
{
using (ICryptoTransform decryptor = aes.CreateDecryptor(key, IV))
{
using (CryptoStream cs = new CryptoStream(fsCrypt, decryptor, CryptoStreamMode.Read))
{
int data;
while ((data = cs.ReadByte()) != -1)
{
if (data != 0) fsOut.WriteByte((byte)data);
}
successful = true;
}
}
}
}
}
if (successful)
{
/// File decryption successfuly completed => rotate files
if (File.Exists(backupFile)) File.Delete(backupFile);
File.Move(fileName, backupFile);
File.Move(intermediateFile, fileName);
return;
}
else
{
Failed(fileName, intermediateFile, "");
return;
}
}
catch (Exception e)
{
Failed(fileName, intermediateFile, e.Message);
return;
}
}
static void Failed(string fileName, string toBeDeleted, string message)
{
if (File.Exists(toBeDeleted))
{
File.Delete(toBeDeleted);
}
Console.WriteLine(string.Format("Decryption of file {0} failed: {1}", fileName, message));
Console.ReadKey();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Decrypt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Decrypt")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c17ec788-0e12-4f9c-aadf-ea4e83a9f373")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]

64
Encrypt/Encrypt.csproj Normal file
View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DA9B09F3-A99D-4883-A954-537560453674}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Encrypt</RootNamespace>
<AssemblyName>Encrypt</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Encrypt.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

93
Encrypt/Program.cs Normal file
View File

@ -0,0 +1,93 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Encrypt
{
/// <summary>
/// See also:
/// https://www.fluxbytes.com/csharp/encrypt-and-decrypt-files-in-c/
/// </summary>
class Program
{
static byte[] key = new byte[] { 83, 254, 105, 64, 184, 201, 195, 127, 52, 99, 77, 45, 252, 132, 163, 156 };
static byte[] IV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
static void Main(string[] args)
{
if ((args.Length < 1) || !File.Exists(args[0]))
{
Console.WriteLine("Usage: Encode <file>");
Console.ReadKey();
return;
}
string fileName = args[0];
string intermediateFile = fileName + ".encrypted"; /// Intermediate file, output of cryptography encoding
string backupFile = fileName + ".bak";
try
{
using (StreamReader reader = new StreamReader(fileName))
{
if (!reader.ReadLine().StartsWith("<?xml version="))
{
Console.WriteLine(string.Format("File {0} is already encrypted.", fileName));
Console.ReadKey();
return;
}
}
bool successful = false;
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
using (FileStream fsCrypt = new FileStream(intermediateFile, FileMode.Create))
{
using (ICryptoTransform encryptor = aes.CreateEncryptor(key, IV))
{
using (CryptoStream cs = new CryptoStream(fsCrypt, encryptor, CryptoStreamMode.Write))
{
using (FileStream fsIn = new FileStream(fileName, FileMode.Open))
{
int data;
while ((data = fsIn.ReadByte()) != -1) cs.WriteByte((byte)data);
successful = true;
}
}
}
}
}
if (successful)
{
/// File encryption successfuly completed => rotate files
if (File.Exists(backupFile)) File.Delete(backupFile);
File.Move(fileName, backupFile);
File.Move(intermediateFile, fileName);
return;
}
else
{
Failed(fileName, intermediateFile);
return;
}
}
catch (Exception)
{
Failed(fileName, intermediateFile);
return;
}
}
static void Failed(string fileName, string toBeDeleted)
{
if (File.Exists(toBeDeleted))
{
File.Delete(toBeDeleted);
}
Console.WriteLine(string.Format("Encryption of file {0} failed.", fileName));
Console.ReadKey();
}
}
}

View File

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Decode")]
[assembly: AssemblyTitle("Encrypt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Decode")]
[assembly: AssemblyProduct("Encrypt")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c17ec788-0e12-4f9c-aadf-ea4e83a9f373")]
[assembly: Guid("0f602531-6f1f-416e-af4d-9242855715a8")]
// Version information for an assembly consists of the following four values:
//

3
Encrypt/app.config Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

14
TBF.sln
View File

@ -48,7 +48,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GemCard", "GemCard\GemCard.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Statistics", "Statistics\Statistics.csproj", "{36755E1D-6FC3-4D9C-8DD3-0250D51532E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decode", "Decode\Decode.csproj", "{D476ABBE-A455-4476-8A8D-3F6151217B51}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decrypt", "Decrypt\Decrypt.csproj", "{D476ABBE-A455-4476-8A8D-3F6151217B51}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encrypt", "Encrypt\Encrypt.csproj", "{DA9B09F3-A99D-4883-A954-537560453674}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -198,6 +200,16 @@ Global
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|Mixed Platforms.Build.0 = Release|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|x86.ActiveCfg = Release|x86
{D476ABBE-A455-4476-8A8D-3F6151217B51}.Release|x86.Build.0 = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|Any CPU.ActiveCfg = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|Mixed Platforms.Build.0 = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|x86.ActiveCfg = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Debug|x86.Build.0 = Debug|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|Any CPU.ActiveCfg = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|Mixed Platforms.ActiveCfg = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|Mixed Platforms.Build.0 = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.ActiveCfg = Release|x86
{DA9B09F3-A99D-4883-A954-537560453674}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Xml.Serialization;
using log4net;
namespace TBF
{
@ -19,12 +20,15 @@ namespace TBF
[XmlRootAttribute("TestBenchFramework")]
public class LocalSettings
{
static XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(LocalSettings) })[0];
private static readonly ILog log = LogManager.GetLogger(typeof(LocalSettings));
static XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(LocalSettings) })[0];
static byte[] cryptoKey = new byte[] { 235, 7, 236, 58, 24, 225, 97, 102, 231, 1, 121, 12, 177, 145, 87, 200,
102, 85, 152, 73, 230, 203, 101, 169, 242, 213, 228, 219, 239, 157, 245, 156 };
///
/// Configuration file ecryption/decryption key and initialization vector
///
static byte[] key = new byte[] { 83, 254, 105, 64, 184, 201, 195, 127, 52, 99, 77, 45, 252, 132, 163, 156 };
static byte[] IV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
static byte[] cryptoIV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
/// <summary>
/// User interface language (used as CultureInfo(..) constructor argument).
@ -291,33 +295,37 @@ namespace TBF
if (isEncrypted)
{
int length = (int)(new FileInfo(fileName).Length);
/// Write settings to a string
StringBuilder plain = new StringBuilder();
Stream stream = File.OpenRead(fileName);
using (BinaryReader binaryReader = new BinaryReader(stream))
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
/// Load encrypted binary data into an array
byte[] encrypted = new byte[length];
int bytesRead = binaryReader.Read(encrypted, 0, length);
if (bytesRead != length) return null;
using (RijndaelManaged myRijndael = new RijndaelManaged())
using (FileStream fsCrypt = new FileStream(fileName, FileMode.Open))
{
// Create a decryptor to perform the stream transform.
ICryptoTransform decryptor = myRijndael.CreateDecryptor(cryptoKey, cryptoIV);
// Create the streams used for decryption.
using (MemoryStream msDecrypt = new MemoryStream(encrypted))
using (ICryptoTransform decryptor = aes.CreateDecryptor(key, IV))
{
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
using (CryptoStream cs = new CryptoStream(fsCrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
using (MemoryStream mStream = new MemoryStream())
{
TextReader txtReader = new StringReader(srDecrypt.ReadToEnd());
LocalSettings ls = serializer.Deserialize(txtReader) as LocalSettings;
using (var writer = new BinaryWriter(mStream))
{
int data;
while ((data = cs.ReadByte()) != -1)
{
if (data != 0) writer.Write((byte)data);
}
writer.Flush();
mStream.Position = 0;
ls.UpdateResultsOutputData();
return ls;
using (var reader = new StreamReader(mStream))
{
LocalSettings ls = serializer.Deserialize(reader) as LocalSettings;
log.WarnFormat("Succesfully loaded and decrypted from '{0}'", fileName);
ls.UpdateResultsOutputData();
return ls;
}
}
}
}
}
@ -329,6 +337,7 @@ namespace TBF
using (StreamReader reader = new StreamReader(fileName))
{
LocalSettings ls = serializer.Deserialize(reader) as LocalSettings;
log.WarnFormat("Succesfully loaded from '{0}'", fileName);
ls.UpdateResultsOutputData();
return ls;
}
@ -336,8 +345,8 @@ namespace TBF
}
catch (Exception e)
{
string msg = e.Message;
return null;
log.ErrorFormat("Failed to load from '{0}': {1}", fileName, e.Message);
return null;
}
}
@ -346,44 +355,46 @@ namespace TBF
/// </summary>
public void Save()
{
UpdateResultsOutputData();
try
{
UpdateResultsOutputData();
#if PUCHONG_200
/// Write settings to an unencrypted file
using (TextWriter writer = new StreamWriter(Program.LocalSettingsFileName))
{
serializer.Serialize(writer, this);
log.Warn("LocalSettings succesfully saved");
}
#else
/// Write settings to a string
StringBuilder plain = new StringBuilder();
using (TextWriter writer = new StringWriter(plain))
/// Encrypt and write to file 'Program.LocalSettingsFileName'
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
serializer.Serialize(writer, this);
}
/// Encrypt and write to a file
using (RijndaelManaged myRijndael = new RijndaelManaged())
{
/// Create an encryptor to perform the stream transform.
ICryptoTransform encryptor = myRijndael.CreateEncryptor(cryptoKey, cryptoIV);
/// Create the streams used for encryption.
using (MemoryStream msEncrypt = new MemoryStream())
using (FileStream fsCrypt = new FileStream(Program.LocalSettingsFileName, FileMode.Create))
{
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
using (ICryptoTransform encryptor = aes.CreateEncryptor(key, IV))
{
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
using (CryptoStream cs = new CryptoStream(fsCrypt, encryptor, CryptoStreamMode.Write))
{
/// Write all data to the stream.
swEncrypt.Write(plain);
}
using (MemoryStream mStream = new MemoryStream())
{
using (var writer = new StreamWriter(mStream))
{
/// Serialize and write settings to a memory stream
serializer.Serialize(writer, this);
writer.Flush();
mStream.Position = 0;
Stream stream = File.OpenWrite(Program.LocalSettingsFileName);
using (BinaryWriter writer = new BinaryWriter(stream))
{
writer.Write(msEncrypt.ToArray());
using (var reader = new StreamReader(mStream))
{
/// Encrypt and write to file 'Program.LocalSettingsFileName'
int data;
while ((data = mStream.ReadByte()) != -1) cs.WriteByte((byte)data);
log.WarnFormat("Succesfully encrypted and saved to '{0}'", Program.LocalSettingsFileName);
}
}
}
}
}
}
@ -392,10 +403,11 @@ namespace TBF
}
catch (Exception e)
{
string msg = e.Message;
log.ErrorFormat("Failed to save to '{0}': {1}", Program.LocalSettingsFileName, e.Message);
}
}
/// <summary>
/// To be able to have RealDensity and AtTemperatire in reports.
/// </summary>

View File

@ -107,7 +107,6 @@ namespace TBF
}
catch (Exception e)
{
log.Error("Fatal error when creating a local application data directory and preparing an initial configuration", e);
MessageBox.Show("Error creating a local application data directory and preparing an initial configuration", "Fatal error");
return; /// Fatal error
}
@ -128,7 +127,6 @@ namespace TBF
Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsBackupName);
if (Program.LocalSettings == null || Program.LocalSettings.TestBenches == null)
{
log.FatalFormat("Local settings: Could not load file {0}, nor {1}.", Program.LocalSettingsFileName, Program.LocalSettingsBackupName);
log.Fatal("Application terminated.");
MessageBox.Show(string.Format("Could not load file {0}, nor {1}.", Program.LocalSettingsFileName, Program.LocalSettingsBackupName), "Fatal error");
return; /// Fatal error
@ -136,7 +134,6 @@ namespace TBF
else
{
LocalSettings.Save(); /// Save the settings to overwrite the wrong file
log.FatalFormat("Local settings: Could not load file {0}, successfully loaded {1}", Program.LocalSettingsFileName, Program.LocalSettingsBackupName);
log.FatalFormat("BatchNr = {0}", LocalSettings.BatchNr);
}
}
@ -144,7 +141,6 @@ namespace TBF
{
/// Loading local seetings from the regular config file was successful. Update the backup
File.Copy(Program.LocalSettingsFileName, Program.LocalSettingsBackupName, true);
log.FatalFormat("Local settings: Successfully loaded from {0}", Program.LocalSettingsFileName);
log.FatalFormat("BatchNr = {0}", LocalSettings.BatchNr);
}

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.1269.0")]
[assembly: AssemblyFileVersion("2.18.1269.0")]
[assembly: AssemblyVersion("2.18.1270.0")]
[assembly: AssemblyFileVersion("2.18.1270.0")]

View File

@ -1,11 +1,13 @@
rmdir /s /q Config\bin
rmdir /s /q Config\obj
rmdir /s /q Decode\bin
rmdir /s /q Decode\obj
rmdir /s /q Decrypt\bin
rmdir /s /q Decrypt\obj
rmdir /s /q DeviceTest\bin
rmdir /s /q DeviceTest\obj
rmdir /s /q Dirichlet.Numerics\bin
rmdir /s /q Dirichlet.Numerics\obj
rmdir /s /q Encrypt\bin
rmdir /s /q Encrypt\obj
rmdir /s /q GemCard\bin
rmdir /s /q GemCard\obj
rmdir /s /q GraphLib\bin
@ -26,3 +28,4 @@ rmdir /s /q Users\bin
rmdir /s /q Users\obj
rmdir /s /q UserManagement\bin
rmdir /s /q UserManagement\obj