I am trying to use EL 5.0 with prism.
As part of the bootstrapper process - I create the Logger Facade adapter- which uses following code for logging...
var logwriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
logwriter.Write(message, category.ToString(), (int)priority);
While the bootstrapper is in process some amount of logging is done by the framework.. and starts writing on to a file...
as part of the ConfigureContainer() , I register the EnterpriseLibraryContainer to use my unity container.
var configurator = new UnityContainerConfigurator(Container);
// Read the configuration files and set up the container.
EnterpriseLibraryContainer.ConfigureContainer(configurator, ConfigurationSourceFactory.Create());
at this stage - any subsequent logging (through exception handling block) to the same logging Target Listener are getting written to a new file (increment file) because the earlier file is held by a different instance
Could any one please assist me in the same?
I was able to resolve this with some help from EnterpriseLib support... here is the link
http://entlib.codeplex.com/discussions/395614
Related
Upgrading Microsoft.Bot.Builder.LanguageGeneration from 4.14.1 to 4.15.0 results in new errors about the fromFile() method. Couldn't find any solution or similar issues on the internet yet. This holds us from upgrading so any feedback is welcome.
/UnitTests/bin/Debug/net5.0/Resources/Lg/General.lg line 25:2 - line 25:39: Error occurred when parsing expression 'fromFile('../Cards/HelpCard.json')'. fromFile does not have an evaluator, it's not a built-in function or a custom function.
This release introduces a global flag called
"Templates.EnableFromFile" that indicates whether the Adaptive
Expression fromFile function is allowed in LG templates. If an
application had previously made use of this function, it is now
required to add the line "Templates.EnableFromFile = true;" to the
Startup.cs code.
from botbuilder-dotnet/releases
Adding it in Startup.cs (or Program.cs) didn't help. I had to put it in the constructor of the service where I used the Templates class.
For someone who needs sample on how to add it.
Add it like this in startup.cs-> ConfigureServices method.
Also on lg file - you dont have to create manually lg file - it will be generated in backend.
You just have to add your content in bot responses which is the content it will be generated in lg file in backend - you can open the same solution in visual studio and see it.
To get error log details in the xamarin project i installed serilog.sinks.xamarin nuget package in my project. In android, I tried serilog.sinks.rollingfile to store the log details in the documents folder. This is my code
Log.Logger=new LoggerConfiguration().WriteTo.RollingFile(Path.Combine(Environment.DirectoryDocuments,"AndroidErrorLog.txt"))
.WriteTo.AndroidLog().CreateLogger();
After executing the project, if I check the documents folder no file are created and no logs details are found. Can any one tell what mistake I have done and how to fix this issue?.
Log.Logger = new LoggerConfiguration()
.WriteTo.File(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "JCA_log-{Date}.txt")
, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] [{SourceContext}] {Message}{NewLine}{Exception}")
.WriteTo.AndroidLog()
.CreateLogger();
Taken from PhillipOGorman from the following sources:
Example #1
Example #2
I had this exact issue. I think it was something in the constructor that seemed to stop Serilog from creating a file.
Note #1: The Serilog code provided relies on the Sinks.File and Sinks.Xamarin.Droid Serilog libraries.
Note #2: He used:
Android.OS.Environment.ExternalStorageDirectory.AbsolutePath
when referencing where the file would write to but,
Environment.GetFolderPath(Environment.SpecialFolder.Personal)
works fine (plus it packages it within your apps sandbox.)
I am trying to prepare a new project for continuous integration.
My project is written in .Net Core and uses Entity Framework Core for Database access.
What I need to try and do is add a pre-build step in my project to add a new migration.
I have already setup the webapp to apply all migrations on startup, but did not really want to have to manually create migrations before committing my code. I believe that should be part of the CI setup as I may go through hundreds of database changes during development, but when I deploy my latest code I would like to have a migration script for each version released.
I am currently using v1.1.0 of all nuget dependancies for .Net Core and EF Core.
EDIT:
The link from J.Pichardo is similar to what I am asking. But from what I can tell it is about applying migrations (which I have already got working in my code).
Answer from bricelam may work as a code version of what I am trying to accomplish. But, I was hoping there was a way to configure the project.json file so that it would run the Add-Migration script using a generated name for the migration (ideally by using environment variables which can be set by my CI).
This would then allow me to manually create migrations during development, but then let my CI create complete migrations during the final stage of each release process.
You can programmatically generate migrations, but I wouldn't recommend it. To do it, reference the Microsoft.EntityFrameworkCore.Design package and use code similar to the following.
using (var context = new MyDbContext())
{
var services = ((IInfrastructure<IServiceProvider>)context).Instance;
var codeHelper = new CSharpHelper();
var scaffolder = ActivatorUtilities.CreateInstance<MigrationsScaffolder>(
services,
new CSharpMigrationsGenerator(
codeHelper,
new CSharpMigrationOperationGenerator(codeHelper),
new CSharpSnapshotGenerator(codeHelper)));
var migration = scaffolder.ScaffoldMigration(
"MyMigration",
"MyApp.Data");
File.WriteAllText(
migration.MigrationId + migration.FileExtension,
migration.MigrationCode);
File.WriteAllText(
migration.MigrationId + ".Designer" + migration.FileExtension,
migration.MetadataCode);
File.WriteAllText(migration.SnapshotName + migration.FileExtension,
migration.SnapshotCode);
}
In order to be able to translate my data annotations in my model with a resource file, I saw that many people recommend the solution offered by jgauffin.
However, when I follow the localization tutorial my project cannot launch.
The problematic code is this one, which is supposed to go in the Global.asax.cs file:
ModelValidatorProviders.Providers.Add(
new LocalizedModelValidatorProvider(stringProvider)
);
It says that the LocalizedModelValidatorProvider constructor does not take any arguments, which is also shown by other tutorials.
But when I change the line like this:
ModelValidatorProviders.Providers.Add(
new LocalizedModelValidatorProvider()
);
I get the following error in the browser:
Attempted to access an element as a type incompatible with the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
The griffin.mvccontrib packages were installed with NuGet under Visual Studio 2012. Any idea what I am doing wrong ?
You might find this link helpful
Here is how I did the registration in the above link:
ResourceStringProvider myResouceFile = new ResourceStringProvider(ModelsResources.ResourceManager);
//ModelsResources is my resource file generated class
GriffinStringsProvider griffinStringsProvider = new GriffinStringsProvider(myResouceFile);
ValidationMessageProviders.Clear();
ValidationMessageProviders.Add(griffinStringsProvider);
ModelMetadataProviders.Current = new LocalizedModelMetadataProvider(myResouceFile);
ModelValidatorProviders.Providers.Clear();
ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider());
Make sure you are including the right assemblies
using System.Resources;
using Griffin.MvcContrib.Localization;
using Griffin.MvcContrib.Localization.ValidationMessages;
Also the assembly for your Resource file.
I have a Windows Phone app that relies on an XML data file that comes packaged with the app. When the app is ran the first time on a phone, I load the file into isolated storage. Once the file is loaded into isolated storage, the app uses the isolated storage version of data. In the next version of my app (the Marketplace update), the XML file will have more elements, how do I update the data file once per app update (new version on the Marketplace)?
I thought I could change the file name in the isolated storage, but that would leave trash behind. I could also check for exceptions when I load the XML file, but are there any other, more elegant ways? I do not want to check for the old file in the isolated storage every time my app runs.
The ideal scenario would be to put a piece of code that would be executed once when the new version of the app is loaded onto the phone, is there a way to do that?
To my knowledge there isn't an "out of the box" event that will run a single time at the first run of an app after it was installed/updated.
You'd have to flag the run your self, like you are already stating (save the current version, compare version at each run of the app to see if app was updated!)
I think I now understand what you want.
Add the XML file as a resource.
Use GetResourceStream to get the content of the XML.
Note that the name for the resource would be something like /DllName;component/Folder/ResourceName
Here is what I did:
In the constructor method of my DataLayer class, I added the following code:
private bool AppIsOld
{
get
{
string storedVersion = GetStoredAppVersion(); //stored previously "seen" version
string currentVersion = GetCurrentlyRunningAppVersion();
return !(storedVersion == currentVersion);
}
}
private string GetCurrentlyRunningAppVersion()
{
var asm = Assembly.GetExecutingAssembly();
var parts = asm.FullName.Split(',');
return parts[1].Split('=')[1].ToString();
}
And then I run the following check:
if (AppIsOld)
RefreshResources(); //do whatever to refresh resources
The code for GetCurrentlyRunningAppVersion() function is taken from here.
This solution is not what I had in mind because it runs every time the class constructor is called while I wanted something that would run once upon version update.