Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
581 views
in Technique[技术] by (71.8m points)

c# - Referenced library isn't copied

I have ProjectA(WPFApplication) that references ProjectB(ClassLibrary). Inside ProjectB i have wpf window that uses control from ThirdParty.dll wich i accordingly reference from ProjectB.

The problem is that it doesn't find ThirdParty.dll in output folder of ProjectA and xaml parse runtime exceprion is raised. There is no ThirdParty.dll in GAC. Copy Locally is set to true. It works if i manually add in output folder of ProjectA that library and it also works if i use that ThirdParty.dll somwhere right in my cs files.

How can i solve that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The reason for this is that visual studio only copies resources to the output folder if Copy Local is set. Just set the reference to Copy Local and you should be fine.

Check out this link on how this works.

When you reference ProjectA, the references from ProjectB is not automatically referenced. For this to work, you need to add a reference to ThirdParty.dll from ProjectA as well if you only use it in XAML. The compiler does not copy references that are only used in XAML. But if you use them in code, they are copied.

This is the same issue as discussed here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...