4
votes

I have a WPF app that works with local SQLite and Entity Framework Core. I want to distribute my app using ClickOnce.

Everything works fine when I run it using Visual Studio 2017. But app had a crash on a start when I used ClickOnce. The crash was so early so I couldn't even log the exception. After some time I found that in publish folder some dlls were missed. For example System.Runtime. All references are NuGet packages. Then I found that despite of I have a reference to the dlls in my project ClickOnce application files list doesn't contains it.

The only solution I have found for now is to add missed dlls as files in root of my project and set build action to Content. In ClickOnce application file dialog I set publish status to Include.

It works now but it looks like not the best way to do it. The question is why they are missed in the first place. More likely I missed something or I am not understand the root of the problem.

UPD:

You can find an example code here.

It works from Visual Studio but crashes on a start when you try to install it as ClickOnce application.

UPD: The problem was fixed in Visual Studio Professional version 15.6.1

3
@Pikoh As I said: "despite of I have a reference to the dlls in my project ClickOnce application files list doesn't contains it" - Ivan Chepikov
@Pikoh I didn't have it at all in the list before I added them as common files to the project. - Ivan Chepikov
Do you have in the reference "Local copy" set to true? - Pikoh
@Pikoh Yes I Do. - Ivan Chepikov
I've just tried with a test application to add the Entity Framework Core package and it automatically shows up in "Application files", so i can't help you more. Sorry - Pikoh

3 Answers

3
votes

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

This place

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.

DLL file and copy always

It will work correctly.

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

Enter image description here

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:

Enter image description here

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

Enter image description here

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

0
votes

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;
0
votes

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