0

I have a .net framework project with framework as 4.8. Recently I integrated docuSign 5.12 using a class library and nuget packages. Everything worked fine in development. When I published the exe in server, I am getting could not load file or assembly error. I cleared the references, reinstalled docusign, changed copy to output property to true for all and published again. But same result.

What I noticed is, when installing .net framework in server, it didn’t create a folder called .Netframework in ‘c:\Program Files(x86)\Reference Assemblies\Microsoft’. As the required dependencies missing are system dependencies, they are not copied to published folder.

So, I have another server where .net 4.8 SDK is present and everything worked fine there. My questions are

  1. Why didn’t installation in server didn’t create assemblies?
  2. Do we need to install .net 4.8 SDK for this to work?
  3. How to publish dependencies for these kind of Nuget packages?

I have not added code samples as it is working already. Dependencies are https://www.nuget.org/packages/DocuSign.eSign.dll/5.12.0#dependencies-body-tab.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
T.kowshik Yedida
  • 195
  • 1
  • 2
  • 13
  • Have you checked what assembly is actually missing? Something like fuslogvw might help. – Ralf Feb 06 '23 at 16:55
  • The following may be helpful: https://stackoverflow.com/questions/47733014/whats-the-difference-between-sdk-and-runtime-in-net-core – Tu deschizi eu inchid Feb 06 '23 at 16:55
  • @Ralf, I am unable to debug as it is happening only in server. I added logging where it says NewtonSoft version error. But it is present already in the output. – T.kowshik Yedida Feb 06 '23 at 17:13
  • @user09938, I went through that. Technically it should work in server with just the runtime. I am not sure what I am missing. – T.kowshik Yedida Feb 06 '23 at 17:14
  • 1
    NewtonSoft is a typical candidate for version mismatches where multiple versions are referenced and depending on how you build the correct or a to old version for someone end in the output. THink about adding a fitting [bindingredirect](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions) to the app.config. – Ralf Feb 06 '23 at 17:26
  • The article mentions .net 4.5 and above automatically adds binding redirect. also, when I have the above said assemblies in place, it all works fine. I suspect Microsoft.CSharp dependency which is the only non system based reference not present in output folder. – T.kowshik Yedida Feb 06 '23 at 17:55
  • On your development computer, you might try opening `Visual Studio Installer`, click "Modify", select "Individual Components", and ensure that the "SDK" and "Targeting Pack" are checked (ie: installed) for the version of .NET Framework that you are targeting. – Tu deschizi eu inchid Feb 06 '23 at 18:23
  • How does that help? I am a bit lost here. It is working with my development environment. – T.kowshik Yedida Feb 06 '23 at 18:43
  • @T.kowshikYedida: Only one way to find out. Try it. Reboot your development computer after installing the additional SDKs and targeting packs. Then clean and rebuild your project. – Tu deschizi eu inchid Feb 06 '23 at 18:57
  • How is it going to help in the server? Is it going to add any extra parametrs or dependencies or references? – T.kowshik Yedida Feb 06 '23 at 19:20
  • According to [Install .NET Framework for developers](https://learn.microsoft.com/en-us/dotnet/framework/install/guide-for-developers#to-install-the-net-framework-developer-pack-or-targeting-pack): _When you target a particular version of .NET Framework, your application is built by using the reference assemblies that are included with that version's developer pack. At run time, assemblies are resolved from the Global Assembly Cache, and the reference assemblies are not used._ Refer to the article for additional information. – Tu deschizi eu inchid Feb 06 '23 at 20:43
  • I did what you suggested and published but the error is still same. – T.kowshik Yedida Feb 07 '23 at 07:51

2 Answers2

0

You can use the publish functionality of VS. It will package your app, including all NuGet dlls and their dependencies and send it to server. If you use Azure - it's integrated into the process. You can even include it in a CI/CD process. But your specific problem can be addressed by just having VS publish the app to your server instead of you manually copying files over there.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
0

As per the comment from Ralf, I checked the references. Found an interesting thing. I already had a binding redirect in the project but, it was added to the class library config file but not the startup project config file. Because of that, my API was referring to old Newtonsoft version. I copied redirect from class library config to my main project config and it started working.

T.kowshik Yedida
  • 195
  • 1
  • 2
  • 13