Pergunta

I am starting to work in a project that is running on other developer's machines. I have grabbed the code from source control, and tried to run it, but I am getting an exception stating that it

could not load file or assembly or one of its dependencies. The system cannot find the file specified.

I have checked the reference and confirmed that the dll is in the reference directory. I have also run Process Monitor, and I believe I see where the dll is being accessed. The result is a Name Not Found, but the path provided is the debug directory for the current project. I'm not sure if referenced files are supposed to be copied to this directory, and that is why it is trying to look there.

Any ideas on what might be preventing a dll that exists in the referenced directory from being found?

Foi útil?

Solução

Check the property page of the reference. There should be an option Copy Local, set it to true This will copy the assembly to the output directory at build-time.

This will copy the reference to the debug path, which is required if the targetted assembly is not in the GAC or loaded with a specified path.


As @StayOnTarget perfectly mentions, while this might work, it is not always the best solution because it might mask another miss configuration - specifically when dealing with framework references.

See When using PresentationFramework.Aero, do I need to set "Copy Local" to true (and include it in my setup project)? for this scenario.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top