Configure Log4Net for NHibernate - nhibernate

This has got to be a lamer question:
In my test project I am attempting to configure log4net. The following method call gives the error.
BasicConfigurator.Configure();
"type name expected but method found"
What am I overlooking?
Thanks,
Nick

Is this a compile time error or runtime error? Do you have a using log4net.Config statement in your class file? Does it still happen if you change it to reference the full class name?
log4net.Config.BasicConfigurator.Configure();

I'm not sure if linking to blog entries is verboten...
If you are trying to log NHibernate stuff, here is what I do:
How to show Log4Net info in NUnit (from NHibernate)
I also have a more basic getting started guide here:
Getting Started with Log4Net

oops.. I was trying to do this in the wrong context. I added the method call to my test project's constructor and we're good.

Related

Cake Build Suppress MSBuild Warnings

I am trying to build my .net solution using cake build file. I am trying to use the documentation on the website here
My current msbuild task looks like this:
MSBuild("./solution.sln", new MSBuildSettings()
.SetConfiguration(environmentSetting)
.SetMSBuildPlatform(MSBuildPlatform.Automatic)
.SetVerbosity(Verbosity.Minimal)
.SetMaxCpuCount(System.Environment.ProcessorCount)
.SetNodeReuse(false)
.WithConsoleLoggerParameter("ErrorsOnly"));
It keeps throwing error for the parameter .WithConsoleLoggerParameter. I am not sure what am I doing wrong here.
The Microsoft documentation shows here the same thing and I tried running it in powershell with the same parameters and it ran just file.
Actually I figured it out. I am not sure how the argument customization works so any explanation for that would be great!
I changed the code to
MSBuild("./solution.sln", new MSBuildSettings(){
ArgumentCustomization = args=>args.Append("/consoleloggerparameters:ErrorsOnly")
}
.SetConfiguration(environmentSetting)
.SetMSBuildPlatform(MSBuildPlatform.Automatic)
.SetVerbosity(Verbosity.Minimal)
.SetMaxCpuCount(System.Environment.ProcessorCount)
.SetNodeReuse(false));
Seems to work. Hope this helps someone!

Unable to locate persister for the entity, no code has changed

I am suddenly getting the error: "Unable to locate persister for the entity named 'MyLib.Project'."
I did not make any code changes to this project since the last time I published it. The reason I went into the code to look at it is because a user reported that the web page that utilizes this library was giving an error. I have also checked the eager loading of the provider as per (NHibernate - Random occurrences of "Unable to locate persister") but I am already eagerly loading.
Furthermore, I even changed my data provider configuration to:
.Mappings(Function(x) x.FluentMappings.AddFromAssemblyOf(Of Project)())
I stepped through the code and actually saw it find the Project mapping and step through it. There are no exceptions thrown while building the provider, but yet the web app still fails when I try to fetch a Project from the DB.
Update
I have tested this same exact code with a desktop application and it works perfectly fine. It seems to me the problem must be with NHibernate and the Web Application. Does anyone have any ideas about this specifically?
The answer to this, of course, is that I made a mistake.
I had two session factories in use in the same program and I passed a session from the wrong factory to one of my functions. So the error is correct, because the session it was passed was unaware of the Project type. I found this out eventually by looking at the Connection property of the session I was querying through.
Hopefully this helps someone else who may have made the same mistake.

Error when creating a new view using MvcScaffoldingT4TwitterBootstrapMvc Nuget package

I installed the MvcScaffolding4TwitterBootstrapMvc package which is based on the scaffolding stuff Steve Sanderson has done. Now I'm attempting to create a new view based on it and I'm just receiving PS errors.
I'm typing this:
Scaffold View LocationType CreateOrEdit -Template _CreateOrEdit
(I've tried other view templates as well)
I receive this error message:
t4(115,64) : error CS1061: Compiling transformation: 'EnvDTE.CodeProperty' does not contain a definition for 'IsScaffoldable' and no extension method 'IsScaffoldable' accepting a first argument of type 'EnvDTE.CodeProperty' could be found
At packages\MvcScaffolding4TwitterBootstrapMvc.1.0.2\tools\RazorView\MvcScaffolding.RazorView.ps1:42 char:27
Obviously the template is causing the error because it can't find something (maybe the T4 library)? But I'm not really sure what or where I'd fix it.
It looks like the IsScaffoldable extension method doesn't exist in the version of the T4Scaffolding.DLL that is installed with the NuGet package.
If found this work item which lead me to GitHub and I see this method exists. Since I'm not really using this attribute, I decided it's probably just simpler for me to remove the .IsScaffoldable() call from the T4 template instead of pulling down the source and compiling a new version of T4Scaffolding.

CConsoleApplication.defaultController not defined when creating new migration

I'm trying to use the yii migration system but I'm stuck on this error when I execute this commande:
yiic migrate create add_table_test
I get this error:
exception 'CException' with message 'Property CConsoleApplication.defaultController" is not defined'
(CCompenent.php:173)
But I've defined a defaultController in my config file:
'basePath'=>$rootPath,
'defaultController' => 'person/index',
'homeUrl'=>array('/me'),
I spent hours looking on Google, but I can't find a solution.
Does anyone have an idea about this problem?
The problem is, that you've actually defined the property defaultController in your config/console.php but as the error message says the CConsoleApplication has no such property.
So just remove defaultController from your console config.
(this is actually an answer given by OP (Michaƫl). I'm putting it here, because he put it into question)
It turned out, that the problem was on my side. I did a really bad thing.
Problem was solved by:
Replacing in yiic.php line $config=dirname(__FILE__).'/config/dev.php'; with $config=dirname(__FILE__).'/config/console.php';.
Create a console.php file in the config directory, without defaultController and theme option.

Using yiidocsgenerator extension to generate documentation

I posted in the Yii forum with no luck. I am hoping someone in this community got this extension working because I really need it!
I used the yiic docs check command, and all the models seem to finally pass the check. So, I proceeded to executing this command:
yiic docs C:\path to my site\protected\models
And at first this appears onscreen:
Building.. : MyApplication Class Reference
Version... : 1.1.7
Source URL:
And then this error pops up:
Building model...
PHP Error[2]:include<GxActiveRecord.php>: failed to open stream: No such file or directory in file C:\path-to-my-app\yii\framework\YiiBase.php at line 396
Where, at that line, I have the following code:
include($className.'.php');
I don't understand why it is looking for a class I do not have!! I found it here, but I don't know in what specific folder that class should reside, or better yet why I should have to download it separately when it's not specified in the instructions. Thanks.
Looks like you've generated models from giix which have GxActiveRecord as a base class and the doc parser does not find this base class, usually you've defined this as an import in your application config, so this may be an expected behavior.
You could try importing something like 'ext.giix.components.GxActiveRecord' in every one of your model classes or copy GxActiveRecord into your models directory just for generating the docs.