Does LinqPad support libraries using MEF?
Hi!
I'd like to use the Simple.Data library but it doesn't work in LinqPad (but it does in VS). I tried manually add all the references and even with NuGet but I get the same result.
To reproduce:
- NuGet the package Simple.Data.SqlCompact40
- Code: var db = Database.OpenFile("Test.sdf");
Take a look at the exception's call stack -> Simple.Data.MefHelper.Compose[T](String contractName)
I'd like to use the Simple.Data library but it doesn't work in LinqPad (but it does in VS). I tried manually add all the references and even with NuGet but I get the same result.
To reproduce:
- NuGet the package Simple.Data.SqlCompact40
- Code: var db = Database.OpenFile("Test.sdf");
Take a look at the exception's call stack -> Simple.Data.MefHelper.Compose[T](String contractName)
Comments
The reason it works in Visual Studio is that Visual Studio copies all referenced assemblies into bin\debug. I could make LINQPad do the same, although it would incur a small performance hit. This is one of the reasons that creating & running a LINQPad query is faster than creating and running a VS project.
A simple workaround for now is to reference the three assemblies from a single folder (such as your VS project's bin\debug folder).
I'm not sure how best to solve this properly. Obviously LINQPad could treat all NuGet references as "copy local", but this would be a waste in the majority of cases where the referenced assemblies need not be in the same folder. Or I can make it a query-level option, but then how would users know when to use it?
Another option is to copy local if any of the assemblies reference System.ComponentModel.Composition.dll. I don't know whether this problem is largely isolated to when MEF is in use.
I was thinking of a work around. Merging all three packages into one and serving it from the file system in a private NuGet feed. I just need to find a tool or write my own if possible. Maybe this work around could be a real solution in LinqPad to this problem in the future if you start to get more feedback on this issue.
Thanks
If I then change the code it compiles to the same output folder with a set of new c# files but it is also leaving the previous query code there. Now when I run the query MEF will fail as it finds the same plugins defined more than once.
Is there a way to tell LinqPad to clear the folder each time?