I'm working on migrating from packages.config to PackageReference format for multiple csproj files. Restore and build succeeds but with hundreds of warnings. These warnings were not showing before my PackageReference changes to csproj files. Please let me know if you could guide on resolving these.
warning NETSDK1049:
Resolved file has a bad image, no metadata, or is otherwise inaccessible. An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) C:\Users\User_Name\.nuget\packages\Package_Name\Package_Version\lib\net45\AssemblyName.dll
warning MSB3246:
Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'AssemblyName.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
Related
I have updated log4net version from 2.0.5 to 2.0.12 in a project. Package.config and .csproj file content changed accordingly. But, msbuild is giving
##[warning]C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "log4net". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
It is causing log4net error. Considered "..\packages\log4net.2.0.12\lib\net45\log4net.dll", but it didn't exist.
How to resolve this error? My csproj file contains hintpath of parent package folder
..\packages\log4net.2.0.12\lib\net45\log4net.dll
I created the following Github repo to document the problem:
https://github.com/red-swan/fake-sqlite-problem
I am unable to build sqlite databases from an F# FAKE file relying on Paket. Adding the nuget package System.Data.SQLite to the paket.dependencies means I can open System.Data.SQLite but when attempting to build a database from the build.fsx file, I get the following error:
(Unable to load DLL 'SQLite.Interop.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E))
SQLite.Interop.dll is a located in dependency runtimes\win-x64\native\netstandard2.0 of System.Data.SQLite's dependency System.Data.SQLite.Core. Trying to reference it directly with and #r statement in the build.fsx fails with the error:
Error opening binary file ... bad cli header, rva
I'm not sure how everything is supposed to resolve, but running the database creation from an actual fsproj works just fine, so I believe it has do with the FAKE or Paket resolution.
If you are familiar with FAKE, does this sound reasonable? Do you know how to fix this?
To reproduce the error:
git clone https://github.com/red-swan/fake-sqlite-problem.git
The above comment by TeaDrivenDev has the solution. I'm putting the answer here so I can close the question.
To be specific, I found the Native dll SQLite.Interop.dll and dropped it into the root folder where the FAKE build.fsx file is. The article TeaDrivenDev references has alternative methods as well.
In one of my VS 2017 instance, the same solution would required a shut down and rebuild when editing a cshtml file during debug. I have search google for a few days now and cannot find a solution.
This is the error:
An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.
Generated Code
The type 'PartialTagHelper' exists in both 'Microsoft.AspNetCore.Mvc.TagHelpers, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.AspNetCore.Mvc.TagHelpers, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Check your NuGet dependencies and dependencies of the dependencies to figure out which of them is dependent on version 2.1.0.
As for fixing the issue there are the following options:
Update all the Microsoft.* NuGetpackages to 2.1.1 - should fix the
problem.
Or clean up the build outputs, NuGet cache, and delete .vs folder to
avoid any caching issues and then - rebuild again. If won't help,
get the repository sources to new directory from scratch.
WHen doing a PIP build it will copy in the solutions other projects outputs from the DeployList.xml but for a different project outside of this solution I only copied in the dll. However it does not like this and throws an error:
Ignored C:\Test.dll because it cannot be loaded properly due to:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) Source: Slb.Ocean.Core
I have also included other files and it copies them in just fine. It just seems to have an issue with dll's and exe's.
If the .dll you are trying to add is a native DLL (without a managed header), the PluginPackager displays the warning message you have given, like this one when trying to add Inventor.dll:
Ignored D:\Program Files\Schlumberger\Petrel 2012\Extensions\OceanLab\Inventor.dll because it cannot be loaded properly due to:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source: Slb.Ocean.Core
[though you would never need to include any .dlls that are part of Petrel, this is just an example]
However, these messages do not keep the .PIP from building, nor do they keep the referenced native .dlls from being included in the generated .PIP file.
There is a enhancement requirement recorded to clean up these misleading messages.
I've recreated the Northwind Spring/NHibernate example that comes with Spring.NET, but with MySQL rather than SQLServer. I've almost got it working I think, but I'm getting this when I try to use Hibernate to load something from the database
A first chance exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll NHibernate.Util.ReflectHelper:
ERROR lambda_method - Could not load type
MySql.Data.MySqlClient.MySqlCommand, MySql.Data.
System.IO.FileNotFoundException: Could not load file or assembly
'MySql.Data' or one of its dependencies.
The system cannot find the file specified.
File name: 'MySql.Data'
Every project (DAO, Service, Web) has a reference to the MySQL.Data DLL so I'm a bit unsure what's going on.
Can anyone help me please?
Make sure that MySQL.Data.dll actually got copied to the output folder. And that you are using right platform (x32 vs x64 bit) and right version of .NET (2,3,3.5 vs 4). If everyhing seems fine, enable Fusion Logging and take a look at this article:
For FileNotFoundException: At the bottom of the log will be the paths
that Fusion tried probing for this assembly. If this was a load by
path (as in Assembly.LoadFrom()), there will be just one path, and
your assembly will need to be there to be found. Otherwise, your
assembly will need to be on one of the probing paths listed or in the
GAC if it's to be found.
You may also get this exception if an unmanaged dependency or internal
module of the assembly failed to load. Try running depends.exe on the
file to verify that unmanaged dependencies can be loaded. Note that if
you re using ASP.NET, the PATH environment variable it's using may
differ from the one the command line uses. If all of them could be
loaded, try ildasm.exe on the file, double-click on "MANIFEST" and
look for ".file" entries. Each of those files will need to be in the
same directory as the manifest-containing file.