WPF ClickOnce missed references

ⅰ亾dé卋堺 提交于 2019-12-04 17:32:37
Shahrooz Ansari

There are two ways solving solve this.

At first, you have to go PropertiesPublishApplication Files, and at this place, make your DLL files include in your project

But if it does not work, go to References and make the DLL file CopyLocal = False. You add a DLL file like Existing Item in your project and make them Copy Always.

It will work correctly.

But for your sample I watch this and I solved it. Look at this image:

You have four DLL files. You need do this for them:

System.Diagnostics.Tracing.dll
System.Reflection.dll
System.Runtime.dll
System.Runtime.Extensions.dll

At first go to your reference and make them Copy Local False:

Then go to the path of each DLL file and add them like Existing Item, and then make all of them Copy To Output Directory CopyAlways

Then Publish it and run it like in this picture. I run it from publish file and it works.

Even if you set the dll to copy local, the dll will not get copied over unless you actually use the dll in your code. You might try adding System.Runtime in your code somewhere like this maybe?

     var dummytest = System.Runtime.GCSettings.IsServerGC;

Based on Issue 9 on https://blogs.msdn.microsoft.com/bclteam/p/asynctargetingpackkb/ I was able to do the following:

Symptom

ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Bcl or Microsoft.Bcl.Async packages may experience a TypeLoadException or other errors after being installed.

Resolution

This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:

  1. Right-click on the project and choose Add Existing Item
  2. Browse to the folder where the System.Runtime.dll lives
  3. In the File name text box paste in the path of the file
  4. Click the down-arrow next to the Add button and choose Add as Link
  5. In Solution Explorer, holding CTRL select System.Runtime.dll
  6. Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
  7. Republish
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!