1

We have an azure service. The solution for it includes several projects. Some of projects references azure.storage ver. 4.2.1. Based on nugget.org the dependencies for azure.storage are odata, edm etc >= 5.6.0. We want to use the latest one 5.6.3. So we added to the projects references references to all dependent assemblies from version 5.6.3 (despite that ILSPY shows that the dependencies are for ver 5.6.0). But unfortunately the loaded dlls are from gac with version 5.6.0. (not from the path we referenced with the latest version) How the dlls are loaded ?:

  1. Based on Force load an assembly from the /bin and not the GAC? and http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx - it loads assemblies from GAC firstable
  2. Based on http://blogs.msdn.com/b/manishagarwal/archive/2005/09/28/474769.aspx and Microsoft.Common.CurrentVersion.targets it should look first in bin directory - not gac.

What is correct? And how (it at all) can I achieve what I try to do?

Community
  • 1
  • 1
YAKOVM
  • 9,805
  • 31
  • 116
  • 217

1 Answers1

2

You are comparing the resolving of an assembly for compilation to the resolving of assemblies on execution.

Both your points and their references are true, but only for their specific situation. Your #2 references explains the compilation process assembly resolving, your #1 references talk about the execution process.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • Thanks. I still have a question - can I force during execution the version to be as I wish and not the one which was found in GAC? – YAKOVM Nov 28 '14 at 13:51
  • You could handle the [`AssemblyResolve`](http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve%28v=vs.110%29.aspx) event. – Patrick Hofman Nov 28 '14 at 13:52
  • Thanks. If am not using assembly resolver but trust GAC - should I add to csproj all dependencies of azure.storage 4.1.2? what about nugets (packages.config)? – YAKOVM Nov 28 '14 at 14:12
  • You should never trust the GAC. Adding those to your project might be best indeed. – Patrick Hofman Nov 28 '14 at 14:13
  • @why it might be best? what version to add - I prefer to add latest one. - it will be used for compilation .but after that while loading during execution the dll with less version will be taken.... – YAKOVM Nov 28 '14 at 14:15
  • If you deploy them with your exe, they should be picked if the version matches. – Patrick Hofman Nov 28 '14 at 14:16
  • sorry for numerous question - I really need to understand that: what you are sayng - if I deploy them with exe they will not be taken from gac? – YAKOVM Nov 28 '14 at 14:18
  • No, on resolving, if the version matches, and it can't find the matching file in the GAC, it will try the EXE path. Did you set the `Specific version` on the reference in Visual Studio? – Patrick Hofman Nov 28 '14 at 14:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65837/discussion-between-yakov-and-patrick-hofman). – YAKOVM Nov 28 '14 at 14:25