Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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,


Posted 02-02-2008 2:48 PM by Derik Whittaker

[Advertisement]

Comments

Gustavo wrote re: StructureMap 101 Error Gotcha
on 02-02-2008 4:29 PM

If the assembly must be copied just put copy local=true. I don't see the need for hacking a class.

Derik Whittaker wrote re: StructureMap 101 Error Gotcha
on 02-02-2008 7:31 PM

@Gustavo,

I tried that but it did not seem to work.  

Gustavo wrote re: StructureMap 101 Error Gotcha
on 02-03-2008 7:26 AM

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 :)

Derik Whittaker wrote re: StructureMap 101 Error Gotcha
on 02-03-2008 7:59 AM

@Gustavo,

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

Peter Ritchie wrote re: StructureMap 101 Error Gotcha
on 02-04-2008 9:47 AM

post-build event? "COPY filepath"

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)