I converted my .net application to .net 4.0 and because im using async/await I installed NuGet packages Async for .Net 4 and dependencies Microsoft BCL...
When I build my application, everything goes well but when I move my app .exe to correct environment I get the error:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a or one of its dependencies.
If I include Microsoft.Threading.Tasks.dll to my applicatin directory everything works well (this .dll is copied to my app build directory).
So the question is do I need to include this Microsoft.Threading.Tasks.dll to my app installer or Is there way to bundle this to my app .exe?
When you build your app there will be a few DLL's in the output folder. Your exe potentially needs all of the DLL's in that folder in able to run.
You should include all of the dll's with the installer that the compiler puts in to the output directory.
Related
I have developed a WPF app on .NET 5 (CRUD operations with Entity Framework Core). MSI packages are built with Wix toolset. Up to here everything works.
I am currently trying to convert the app to .NET 6. Everything runs perfectly, the Nuget packages can all be updated, building the MSI packages also works.
After installation on the client PC, the following message appears and the app crashes:
Could not load file or assembly "Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, ..." The system cannot find the file specified.
Thanks for any help or ideas...
I'm migrating a muti-project .NET 4.6 solution to .NET Core 5.02. The .csproj files were manually migrated using these instructions. The solution creates DLLs which are plugins for another application; that app loads the DLLs at runtime. The DLLs created by the solution run fine on my development PC (of course). When installing these plugins into a pristine copy of the app in Windows Sandbox, one of the DLLs fails with error:
Could not load file or assembly 'System.Drawing.Common, Version=5.0.0.2,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the
file specified.
This prevents that DLL from being loaded. A differnt DLL with a reference to Microsoft.Windows.Compatibility loads OK but it has no ref to System.Drawing.
The project in which this fails at runtime has System.Drawing installed as a package reference (no packages.config). Again, it compiles and runs correctly on the development PC.
I've tried:
uninstalling System.Drawing from NuGet, fetching it again from NuGet and reinstalling it in the solution
using Update-Package -reinstall in the project which resulted with no references needing reinstall, closing and reopening VS2019 ;)
used Publish on the project but only got a .nupkg instead of a DLL and dependencies.
I'm not allowed to post pics (new user) or I would include pics of the Dependencies tree and of the project references in the .csproj. Does anyone have any suggestions? Thank you.
The following has to be added to the project's .csproj file:
<PropertyGroup> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> </PropertyGroup>
Small question : If a dll is being referenced from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1, how does an application link/finds that during runtime? (or when launched without VS)?
Is it from GAC or the dll is copied into executable location at runtime?
The Framework you build with (4.6.1) has to be installed on the client (GAC) to run. Standard with normal Windows client/server.
If you want to embed the DLL in your EXE, have a look at Embedding DLLs in a compiled executable.
I highly recommend to use Costura.Fody - by far the best and easiest
way to embed resources in your assembly. It's available as NuGet
package.
Install-Package Costura.Fody
After adding it to the project, it will automatically embed all
references that are copied to the output directory into your main
assembly. You might want to clean the embedded files by adding a
target to your project:
Install-CleanReferencesTarget
I have a C# project that generates some.dll and it references a bunch of DLLs, one of them is System.ComponentModel.Composition.dll which is found under C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0.
I built some.dll and deployed on a Windows XP system. The application that uses this some.dll runs normally. But when I try to look for the System.ComponentModel.Composition.dll under C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 on the Windows XP system, I could not find it.
I just want to understand how the application is running properly.
The reason why I want to understand it is, I built the some.dll in a different system and deployed on another Windows XP system. When I try to start the application, the application crashes with error:
Exception ::Could not load file or assembly 'System.ComponentModel.Composition.resources, Version=4.0.0.0, Culture=en-NZ, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
The reference assemblies are used at compile time. Usually, as here, to refer to assemblies that are installed as part of the .NET Framework. Which will place these assemblies somewhere under either C:\Windows\Assembly (for the GAC) or C:\Windows\Microsoft.Net.
It would tend to suggest in this case that the machine with the component missing does not have the correct version of .NET installed.
It's my 3 day of working with C#, so my question is noobish, sorry.
I wrote small application, which works with System.Web.Script.Serialization, from System.Web.Extensions library. I have add reference to this DLL (it's from GAC).
But after installation of published application, it can not work on systems, where this DLL doesn't exist in GAC.
So I want to build this DLL into my application, to not depend on the existence of DLL.
What have I tried:
Added reference to DLL and turned option "Copy Local" to "True"
Copied DLL to the project folder and create reference to that file
In "Prerequisites" turned on option ".NET 3.5 Framework SP1 Client Profile"
In "Prerequisites" turned on option ".NET 4 Framework Client Profile (x86 and x64)"
And still I'm getting message Could not load file or assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
When in my system application works fine.
Please, tell me, what should I do to compile application with this DLL.
System: Win7 x86, MS Visual C# 2010 Express (I have trial of professional, if it can help, but hope it can be solved in the Express edition too).
System.Web.Extensions depends on System.Web, which is not part of the client profile, you should change your prerequisites