In a C# solution, I have multiple class libraries for the domain model, services, and repositories. I configured Unity in web.config of the main website project so that it knows what concrete objects to map to 开发者_如何学运维the services and repositories. For quick testing, though, I'd like to use PowerShell to load the assemblies and manipulate classes/functions from there to toy around with behavior. However, if I load the class projects directly into PowerShell, it won't know or care about web.config since I don't need that project, and Unity won't know what to inject.
I can always have a function or constructor (?) that will substitute the concrete services manually, I think, but I was curious if there's a better way around it than that.
Load the assembly with your web.config (or app.config): Powershell Calling .NET Assembly that uses App.config
精彩评论