0

I experienced some odd situation in build solution of c#.

All 5 projects in a solution.

A.exe B.dll b.dll C.dll c.dll (B, b, C, c are all usercontrol project).

A.exe referenced B.dll and C.dll.

B.dll referenced b.dll.

C.dll referenced c.dll.

All referenced option is "Copy Local" : true.

When A.exe project is builded, In Debug folder, A.exe and B.dll and b.dll and C.dll are created. (not c.dll).

At last I have known that the reason of difference.

b.dll usercontrol is used in B.dll xaml having b's element name.

but c.dll usercontrol is used with no name.

The difference of B with C is just whether the used control's name is used or not in xaml.

Any one can explain, why this difference is result in the dll copy or not in exe project debug folder?

user3678158
  • 25
  • 2
  • 6
  • [Msbuild doesn't copy references (dlls) if using project dependencies in solution](http://stackoverflow.com/questions/1132243/msbuild-doesnt-copy-references-dlls-if-using-project-dependencies-in-solution?rq=1) and [How does visual studio determine what to copy to the output directory with multi-project solutions?](http://stackoverflow.com/questions/353617/how-does-visual-studio-determine-what-to-copy-to-the-output-directory-with-multi/2828191#2828191), basically if `c.dll` isn't explicitly used from other assemblies, then it won't be copied despite the `"Copy Local" : true`. – Yurii May 28 '14 at 06:41

1 Answers1

0

When you give a control a x:Name, it causes it to create an instance for it in the generated code behind (partial) class. This is enough for the reference following system to detect the reference, and copy in the dependency dll.

That's why you're seeing the difference in behaviors.

Yuval Itzchakov
  • 136,303
  • 28
  • 230
  • 296