1

Issue:

I have two projects. The first named Studio and the second named Worker which is a class library. Worker project refers some third party assemblies like Ecng.Common, Ecng.Data, etc.

When i try to load Worker in Studio via MEF, MEF throws an exception:

Can't find file or assembly Ecng.Transactions

However there is no project reference in Worker for Ecng.Transactions. Worker works without it.

What do I need to do to fix this issue?

Edit 1:

var catalog = new AggregateCatalog(); 

foreach (var nameAndPath in robotsDirectory) 
{ 
  catalog.Catalogs.Add(new DirectoryCatalog(nameAndPath.Value)); 
} 

var container = new CompositionContainer(catalog);

container.ComposeParts(this); // Here i have Exception 
Ganesh R.
  • 4,337
  • 3
  • 30
  • 46
Vader
  • 21
  • 3

1 Answers1

0

Does any of the assemblies that Worker refers, refer to Ecng.Transactions? You can use tools like DotPeek or Visual Studio Object Explorer to figure that out

And when are you getting the error?

  1. While MEF is parsing the Worker assembly for MEF Export tags? or
  2. When you are trying to load a specific class inside Worker?
Ganesh R.
  • 4,337
  • 3
  • 30
  • 46
  • var catalog = new AggregateCatalog(); foreach (var nameAndPath in robotsDirectory) { catalog.Catalogs.Add(new DirectoryCatalog(nameAndPath.Value)); } var container = new CompositionContainer(catalog); container.ComposeParts(this); // Here i have Exception – Vader Jun 25 '13 at 11:14
  • @Vader Did you check what directories are you asking MEF to look at? A dll inside one such directory may have a dependency on the Transactions dll. Also MEF would let you know for what class instance did it throw the error. – Ganesh R. Jun 25 '13 at 12:12
  • Yes, 3 assembly have a dependency on the Transactions.dll. But when i bild Worker, there is no Transactions.dll in output directory, and it work without problem. – Vader Jun 25 '13 at 12:30
  • At last, i put Transactions.dll in directory with another assemblys by hand. But it does not working. I have same exception. – Vader Jun 25 '13 at 12:33
  • @Vader Is Transaction.dll encrypted? Are all the dlls referring to the same public keyed and versioned transaction dll that you copied to the folder? Post the exact exception message. Also enable first chance exceptions and debug the app. It will provide you with more information – Ganesh R. Jun 25 '13 at 13:22
  • Is Transaction.dll encrypted - No. Are all the dlls referring to the same ... - Yes. Translate exception text. Can't load one, or more requested types. Look LoaderExceptios for more information. LoaderExceptios: Can't load file or assembly \"Ecng.Transactions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" or one of component that depend on it. Can't find target file.":"Ecng.Transactions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"} – Vader Jun 26 '13 at 09:00
  • Can you use Fusion log viewer shipped with Visual Studio to figure out if any binding errors are logged? (C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64\FUSLOGVW.exe) – Ganesh R. Jun 26 '13 at 11:40
  • Can i go another way? I think, that MEF check all dependence, and don't find Ecng.Transactions.dll. Because of it, i have exception. But application Worker work without this .dll. Worker don't need it. if i use Assembly.LoadFrom() it work without problems . How can i turn off check, which MEF do? Sorry about my english. – Vader Jun 26 '13 at 12:11