Posts tagged .net
Posts tagged .net
28 notes &
Whowh, that’s a nice error:
Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule To fix this add <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> to the <httpModules> section on your web.config. Windsor also detected you're running IIS in Integrated Pipeline mode. This means that you also need to add the module to the <modules> section under <system.webServer>. Alternatively make sure you have Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 assembly in your GAC (it is installed by ASP.NET MVC3 or WebMatrix) and Windsor will be able to register the module automatically without having to add anything to the config file.
That doesn’t make sense… After some fumbling around I got the next error message:
An error occurred creating the configuration section handler for common/logging: Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'
And after that another error in log4net configuration. Eventually colleague Mark helped me figure out the following was the underlying problem:
log4net version 1.2.11 has a different publicKeyToken then 1.2.10
So when I upgraded my nuget files, log4net 1.2.11 got downloaded and referenced. But castle.windsor was looking for 1.2.10, and didn’t see the similarity with 1.2.11. And so it epically failed :( For some reason it did work on my machine, but not on the live server, which didn’t help.
What can we learn from this?
It took me 2 hours to figure out what was wrong. And all that because I let castle.windsor do the dependency injection via public properties. This just ended up with CollectionObjectService being null:
public CollectionObjectService CollectionObjectService { get; set; } public SynchronizerService() { }
When I re-wrote it so the services use constructors to get their dependencies injected, the error that actually told me what was wrong turned up:
public CollectionObjectService CollectionObjectService { get; private set; } public SynchronizerService(CollectionObjectService coService) { this.CollectionObjectService = coService; }
14 notes &
There’s this old-old-old website that I want to give a little upgrade. It’s written in classic ASP (remember “on error resume next”?) and has a nice content management system. I’m not planning on re-writing the whole thing, but just to make some tweaks.
First thing I wanted to do was upgrade to .net 4 and .net mvc3. I’ve allways hosted my sites at Vevida, and they’ve never let me down. This time they moved my website to a different server (took about 20 minutes) and then helped me configure the whole thing. All I have is FTP access and the CMS was in a protected folder so your browser asked a username/password to enter it. In .net 4 this isn’t possible anymore (apparantly) so I created my own authorization using FormsAuthentication:
<system.web>
<authentication mode="Forms">
<forms loginUrl="Login.aspx" defaultUrl="Members" />
</authentication>
<authorization>
<allow users="?" />
</authorization>
</system.web>
<location path="cms">
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
And then the login logic using a normal .aspx file:
var username = Request.Form["username"];
var password = Request.Form["password"];
if (username == "specific" && password == "credentials")
{
FormsAuthentication.RedirectFromLoginPage(username, true);
}
That’s easy! Everything’s up-and-running again, and now I can start using .asp and .aspx and .cshtml files next to eachother :)