1

When I run unit testing to serialize to an xml file, I keep getting error message:

Could not load file or assembly 'Company.Fin.Bank.Common.XmlSerializers.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I guess Company.Fin.Bank.Common.XmlSerializers.dll may be in cache somewhere but it is impossible to find this dll, even though i don't need that dll. I want to remove it. But where can i find it? is it possibly in a cache? if yes how can i clean the cache from VS? This problem is very new to me.

What a weird part is that i used another laptop (win 7) to run the unit testing, there is no error message i got - it worked. but when i used my own laptop (win 8) i keep getting error message. I have no idea why.

I hope to find solution from you. Your help means alot. Thanks!!!

jwrush
  • 743
  • 7
  • 25
user235973457
  • 331
  • 4
  • 9
  • 24
  • By cache do you mean the GAC? If so take a look in C:\Windows\assembly, or C:\Windows\Microsoft.NET\assembly if you are using .Net 4.0 or higher. – Daniel Kelley Aug 27 '13 at 15:17
  • If you expand the References folder of your application, is there an assembly there that has a yellow-triangle? This means it can't resolve it. Chances are the other laptop has this DLL and yours does not. Find it, copy it over and add it as a reference to be resolved. The clue is in the error message :) – Moo-Juice Aug 27 '13 at 15:17
  • Is there maybe another library in your project that has that .dll as a dependency? – squillman Aug 27 '13 at 15:18
  • 1
    the answer here might be of help? http://stackoverflow.com/questions/1127431/xmlserializer-giving-filenotfoundexception-at-constructor – NDJ Aug 27 '13 at 15:18
  • This can happen if you are running your unit tests from inside VS and have configured VS to break whenever an exception is thrown. I expect the windows 7 laptop is configured not to break when exceptions are thrown. The dll is not needed and the exception can be ignored, unless a custom serializer routine is needed. – sgmoore Aug 27 '13 at 15:37

2 Answers2

3

That assembly is dynamically generated by the framework (XMLSerializer)

In .Net implementation, the XmlSerializer generates a temporary assembly for serializing/deserializing your classes (for performance reasons).

Also, this may be normal behavior - is it stopping your application from running?

Community
  • 1
  • 1
Tim Mac
  • 1,149
  • 1
  • 8
  • 17
  • +1. Linked questions also have ways to generate this type of assembly (if the exception must be fixed for some reason - i.e. inability to dynamically generate assembly due to some permissions on temp files) – Alexei Levenkov Aug 27 '13 at 15:54
0

even though i don't need that dll

Visual Studio will usually remove unneeded DLLs. Typically this is caused by dependencies (which are harder to keep track of).

I want to remove it.

Check in the References of the project in the Solution Explorer. If any of them have a yellow triangle that means they can't be found (the project may still compile and run if you aren't actually using that reference).

is it possibly in a cache?

As Daniel Kelley mentioned C:\Windows\assembly and C:\Windows\Microsoft.NET\assembly are where the global assembly cache is located. If it isn't there check the Hint Path of the reference (it will show up in Properties).

Good luck finding your reference, keep in mind that you need not only the actual DLL but all of its used references in most cases. Also a decompiler like DotPeek can be useful if you need a more discreet way of looking at references.

Guvante
  • 18,775
  • 1
  • 33
  • 64