Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



StructureMap 101 Error Gotcha

Today I was putting together a test app for a few presentations I am doing in the coming weeks (announcements on these coming soon).  While doing this I kept getting a 101 exception when trying to build an object via StructureMap's ObjectFactory (error information here).

Error message
Assembly {AssemblyNamehere} referenced by an <Assembly> node in StructureMap.config cannot be loaded into the current AppDomain

What did not make sense is that the test project had reference to the assembly that it was complaining about.  It turns out that I was not actually using the assembly so it did NOT copy the assembly to the bin directory during compile time.  Which I guess makes sense.

So, after pondering what to do, I simply created a 'hack' class that created an instance of an object out of the missing assembly.  Now it copied the .dll to the bin directly like I thought it would.  I can here you now, why create the 'hack' class.  Well, simple, I was not using the assembly directly, but using it via IoC with StructureMap. 

So, if you ever get the 101 exception from StructureMap, make sure the assembly is actually being copied to your output (bin) folder like you thought.

Till next time,



Comments

Derik Whittaker said:

@Gustavo,

I tried that but it did not seem to work.  

# February 2, 2008 7:31 PM

Gustavo said:

Weird...i use the NHibernate SysCache without any class using it and copy local = true and it is being copied to the bin directory...

Anyway, you have a solution for your problem so it does not matter :)

# February 3, 2008 7:26 AM

Derik Whittaker said:

@Gustavo,

What version of the IDe are you using?  I came across this one with VS 2008.

# February 3, 2008 7:59 AM

Peter Ritchie said:

post-build event? "COPY filepath"

# February 4, 2008 9:47 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Red-Gate!