AdventuresWith.Net | Dann Blackwell

Whatever I think of Godaddy, they haven’t caused me too much pain yet, just minor inconvenience. This time it’s my precious StructureMap.

StructureMap, I like it and alot of people do, but it just won’t work under Medium Trust! So it’s either time to change Hosts, or change IoC container. Pretty obvious which one is the easier choice here.

So what choice do you have? Well not much. So the answer is:

Unity from Microsoft Patterns & Practices*

Here’s a nice manual to go with it.

And what’s not able to be run in medium / partial trust:

Windsor Castle
Spring.Net
StructureMap

There was someone who was explaining how to download and build Spring.Net to allow it to run under Medium Trust, but that seems pretty likely to cause issues when you hack code (try to ignore my NHibernate post when I say that).

It may be the same for the other 2, but off the bat, Unity wins.

*Caveat: Unity is restricted in what it can do when run without ReflectionPermission (which is what Medium Trust disallows), but typically this won’t affect much from the normal IoC behaviour.  The restrictions are explained on this MSDN doc, but it’s to do with internal and private constructors and properties. If it’s public you should be sweet.

, ,

Ok, so Log4Net is not that bad. It is a very good logging system, etc…

So how do you perform IoC with the NHibernate logger? Well, you can’t. Unless you are ready to HACK CODE.

That’s the brilliant thing about open source. Take it and modify until its the shade of green that suits you.

The First Warning

If you modify the DLL for NHibernate, then all associated DLL’s break.
For me this means FluentNHibernate wont like you. So you will have to rebuild that too for the new NHibernate DLL.

According to the bug report for exactly this issue, in the future log4net will be removed as a dependency (yay). For the logger interface Commons.Logging has been “sort-of” chosen. Meaning: you should  use the ILog interface from Commons.Logging for your Log interface! Make’s it a bit more future proof.

What I did to have IoC : 2nd Warning  – This is not a concise walkthrough

  1. Download the source code of
    1. NHibernate – Under the Browse Files you will find a SRC version.
    2. FluentNHibernate – Download from GitHub
    3. Commons.Logging 
  2. Create a new Interface called ILog that is inside the NHibernate project. This is because it will be used as an adapter for the Commons.Logging. It’s probably best to put under a smart namespace like NHibernate.Logging.ILog
  3. Create a LogManager class that does the same thing as the log4net LogManger, but using the Commons.Logging assembly. I know this is vague, but my implementation wasn’t very good. The idea is that when NHibernate is called, the LogManager is setup using the Commons.Logging.ILog object that was returned by my  IoC object  factory.
  4. Remove the References of log4net from the projects
  5. Replace all namespaces of log4net with the namespace of your new Interface and LogManager (say NHibernate.Logging).
  6. Remove all Log4Net residue, like Cfg calls and XML setup arguments.
  7. Build and everything should be happy.

, ,

This is a direct quote from the Wikipedia page on Global.asax. Just thought it would be nice to a quick list to refer to.

  • Application_Init
    • Fires when the application initializes for the first time.
  • Application_Start
    • Fires the first time an application starts.
  • Session_Start
    • Fires the first time when a user’s session is started.
  • Application_BeginRequest
    • Fires each time a new request comes in.
  • Application_EndRequest
    • Fires when the application terminates.
  • Application_AuthenticateRequest
    • Indicates that a request is ready to be authenticated.
  • Application_Error
    • Fires when an unhandled error occurs within the application.
  • Session_End
    • Fires whenever a single user Session ends or times out.
  • Application_End
    • Fires when the application ends or times out (Typically used for application cleanup logic).

No tags

 

I had some time trying to work out the details on the ol’ neufbox, so here is a hint for getting it to be in English which makes life easier for non-francophones:

  1. Hold down the green button on top of the neufbox until it starts flashing purple (takes about 5 seconds)
    image
  2. Go to the neufbox Configuration Page Maintenace –> Personnalisation page.
      – usually http://192.168.1.1/6_3
  3. Click the “Continuer” button (should still be flashing purple on the box)

    image

  4. Change the language to Anglais (English) and click “Valider”

    image 

Done!

image

A handy list of ActionResult’s that I found on StackOverflow thanks to Chris.S and his reference to the MSDN doc.

ContentResult
Writes a string value directly into the HTTP response.

EmptyResult
Does not write to the HTTP response.

FileContentResult
Takes the contents of a file (represented as an array of bytes) and write the contents into the HTTP response.

FilePathResult
Takes the contents of a file at the given location and writes the contents into the HTTP response.

FileStreamResult
Takes a file stream produced by the controller and writes the stream into the HTTP response.

HttpUnauthorizedResult
A special result used by authorization filters when authorization checks fail.

JavaScriptResult
Responds to the client with a script for the client to execute.

JsonResult
Responds to the client with data in JavaScript Object Notation (JSON).

RedirectResult
Redirects the client to a new URL.

RedirectToRouteResult
Renders the specified view to respond with an HTML fragment (typically used in AJAX scenarios).

PartialViewResult
Renders the specified view to respond with an HTML fragment (typically used in AJAX scenarios).

ViewResult
Renders the specified view and responds to the client with HTML.

Dec/09

5

Fantastic Intro to Prism

I stumbled across this excellent written / video tutorial with source when starting out in my Prism adventure.

Prism for Silverlight – Silver Bay Labs

image

image

I think this is the best starting out example I have found. It still requires a basic understanding of Inversion of Control to figure out what he’s trying to do, but run through it a few times and it all sort of fits together.

,

After trying for a while to figure out how it all sort of works and what I was actually looking for, I found this page at Sparkling Client – Downloading Prism.

Once you get there, there is a 10 step method on how to use Prism/CAG or whatever you want to call it.

Not intuitive in any way for Microsoft to hide it by giving it different  names (Prism == Composite Application Guidance), but I guess that’s life.

I blame Microsoft’s love (or perhaps just programmer’s vanity) of renaming things that already have a name, but I think it got away on them here.

Update: Herding Code, in an interview with Glenn on Prism / CAG, discovered that Prism is the “Cool Name” whereas Composite Application Guidance is the “Serious Important Name”.

Coming soon: A photo viewer app using Prism. I know it’s been done to death, but it’s a good start.

, , ,

Its always tough to figure out what’s happening to your domains when you register them, set the Name Servers and… well nothing happens.

So you do this:

1) Download DNSDataView and run it

2) Write in your Domain name and your expected DOMAIN NAME SERVER

image

3) Click OK and if you get something to show (like below), then you can put these names as the primary and secondary name servers for your domain!  (ping the servers to get the IPs if needed). If not try another server in the list.

image

The usual nameservers for me were:

ns14.domaincontrol.com
ns15.domaincontrol.com
ns25.domaincontrol.com
ns26.domaincontrol.com
ns48.domaincontrol.com
ns49.domaincontrol.com
ns50.domaincontrol.com
ns51.domaincontrol.com

,

<< Latest posts