Rider Could Not Load File Or Assembly

1 view
Skip to first unread message

Charise Farag

unread,
Aug 5, 2024, 12:34:40 AM8/5/24
to acermyalu
Helloeveryone and thanks for the help in advance. I have two problems intelrinked with each other. First, I am creating for the first time a C# class library in .Net 6 that is a data access layer for other apps. I have never created a class library before, so I may not be doing so correctly, however, I have read the Microsoft documentation and think I did it correct. I then referenced the library by adding the dll file by "Add Project Reference". When I run the application, I receive the error: Could not load file or assembly class library "Microsoft.EntityFrameworkCore version = 6.0 in Class Library. To clarify, the class library uses EntityFramework Core 6.06. I have tried deleting the bin and obj folders ad rebuilding, but it doesn't fix the problem. I am not sure what the next step is to solve this.

@Kmcnet , Welcome to Microsoft Q&A, based on the error you mentioned, it may be caused by incorrect .net Framework version. What is your current app .net framework version? As usual, we need to ensure the current app' .NET Framework version should be .NET 6.0.


You created a specific file reference. The class library contains other library dependencies that the main application knows nothing about because the dependent DLLs are in the class library's bin folder.


Assuming both projects are part of the same solution, create a project reference rather than referencing the DLL directly (file reference). Otherwise, you'll need to physically copy the dependent DLLs or make a reference to the missing libraries in the main project both of which can cause headaches down the road.


So here comes the stupid questions. I assumed since the packages are installed on the class library, it si not necessary to install each of the same packages on the consuming project. Am I misunderstanding this?


Here is something to try, create a new console project, disable ImplicitUsings, in Solution Explorer drag the class project node to the console project node. Now write a simple EF Core query, build/run. Does it work or do you have the same issue as in the current project.


This is incorrect. None of the dependent dll files appear in either the debug or release directories within the bin folder. However, once the missing libraries were added the error resolved. So this now begs other questions. What is the best practice for creating a standalone class library (I created this library separately from the other project). It seems strange that the concept of a class library created to be consumed my different applications requires the library be developed as a part of a solution. I assume you would need to make this library a part of every application that calls it?


Typically, when an older project is opened for the first time in the latest version of Visual Studio, the migration manager kicks in and automatically corrects any inconsistencies between Visual Studio versions. However, some other issue may arise. Using the default install of Visual Studio 2017 Community Edition, trying to compile the solution I was working on returned the following error:


Taking a closer look at the error: The "Microsoft.Build.Tasks.Xaml.PartialClassGenerationTask" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64\XamlBuildTask.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64\XamlBuildTask.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.. It looks like there are a few XAML files that need to be compiled. Honestly, I was not familiar with this particular project so I was totally unaware of this dependency.


This might seem like a fairly obvious solution if you traditionally work with XAML or Windows Workflow Foundation. However, since I was not used to either, it took me some time to figure this out. Hopefully this article can help somebody else.


The first fix was quite easy to find on Google. There are many posts that talk about a problem in the Azure Functions SDK. It seems that the SDK is too eager to clean out referenced assemblies that it thinks are not used. So, you need to instruct the Functions SDK to skip cleaning out by adding the following property group to the Azure Functions app project file.


Oh snap! Using the App Service Editor, I verified that the System.IdentityModel.Tokens.Jwt.dll assembly really was not available in the bin folder. A lot of files, but unfortunately not the required. So apparently the _FunctionsSkipCleanOutput property did not fix everything.


I noticed that my Functions app did not contain a direct reference to System.IdentityModel.Tokens.Jwt but instead, my Functions app references another library, that had a reference to the Tokens assembly. So, I thought that I could easily fix the error by adding a direct reference to the missing package to my Functions app too.


But no. I was wrong! Still, the same error. I realized that if the Functions SDK incorrectly cleans out unused assemblies, it might not be enough just to add a reference to it. I would need to use it too. So I added the following code to the constructor of one of the function classes I had in my project.


I am building ASP.NET using the SAP.Net Connector, latest version. It works correctly on development machine. However, when I deployed it, I get the error, "Could not load file or assembly 'sapnco' or one of its dependencies. An attempt was made to load a program with an incorrect format. " Anyone has any issue with this would like to share some hints. Thanks.


System.BadImageFormatException: 'Could not load file or assembly 'NSAPConnector, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.'


Be sure all the Build Platform architecture and corresponding References in all projects are for the same architecture. For example, if in your Configuration Manager you are compiling for a x64 Platform, and you have a reference to the x86 version of sapnco in your project, it will cause this error. Interestingly Visual Studio doesn't show it in the Error List as a compiler Error List as a hard error.


Actually, .Net deployment miss to include the rscp4n.dll file. I copied the file and put it into the bin folder along with sapnco.dll and sapnco_utils.dll, which were correctly deployed using the deployment feature; however, now I am getting the same error for 'rscp4n.dll'.


I found the solution. If you are hosting under IIS7. You need to, first Enable 32-Bit Applications in your app pool (I am not using 64-bits hosting), and you need to change managed pipeline mode to classic. After restart application pool, it seems to work for me.


fix RIDER-104519 Rider is reporting errors in scripts that work fine in Unity when utilizing DOTS - when Player project, by generating projects for all assemblies in "com.unity.entities", "com.unity.collections"fix RIDER-111622 Unity Rider package is not compatible with Rider Dev builds


RIDER-92424 JetBrains Rider Editor 3.0.20 package Update for Unity, Cause's Rider to Slows to a Crawl after updatingRIDER-92419 JetBrains Rider Editor 3.0.20 for Unity has duplicate assemblies loaded into runtime


new setting to manage list of extensions to be opened with Rideravoid breaking everything on any unhandled exception in RiderScriptEditor cctorhide Rider settings, when different Editor is selecteddynamically load only newer rider pluginspath detection (work on unix symlinks)speed up for project generationlots of bug fixing


I've setup my AWS SSO profile on my windows PC and it's working fine in on AWS toolkit with VS Code.However the same profile is giving me the following error when I try AWS toolkit for Visual Studio 2022.


I have tried adding AWSSDK.Core new nuget package but still keep failing with the same error. New nuget package is version 3.7. Not sure if AWS Toolkit is looking for the exact 3.3 version of awssdk.Core.


From the post I understand that you are trying to set up AWS toolkit for Visual Studio but are getting the error "Assembly AWSSDK.SSOOIDC could not be found or loaded. This assembly must be available at runtime to use Amazon.Runtime.SSOAWSCredentials".


After investigating I was able to find a thread that goes over this issue here (1). The likely fix is to update the the version of the tools that you are using. Per the thread that change fixed the issue. I hope you have a great rest of your day!


Thanks for your reply. That's a fairly old post.This is a new issue that has been started recently with the latest version. -toolkit-visual-studio/issues/267AWS toolkit older versions working fine with SSO, the latest one for 2022 is not working. It's apparently a bug.


If you're a .NET developer, I bet that at least once you've experienced errors like "System.IO.FileLoadException: Could not load file or assembly '[ASSEMBLYNAME], Version=x.x.x.x, Culture=neutral, PublicKeyToken=xxxxxx' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"


Well, dll hell is directly related to assemblies that are signed with strong name. When an assembly is signed with a strong name, a unique identity for the specific assembly with a specific version is created. Assembly's identity consists of it's name, version, culture information, public key and a digital signature. In order to sign an assembly with strong name you need to use a so called Strong Name Key, that is a cryptographic key pair, consisting of:


This creates a version binding so that once you refer to an assembly with the same name, but totally different version or public key than what the application expects, a "Could not load file or assembly" error will be thrown. When strong name is in the game, each new version of the assembly means a totally new identity.

3a8082e126
Reply all
Reply to author
Forward
0 new messages