I am creating an API-Addin for a Program that uses .NET Framework 4.7.2 and I cannot change that. I am adding the ComponentOne (.NET 4.5.2) DLLs in Visual Studio. When the Addin in the external program tries to load the dll, there is an error that the DLL cannot be found. I am pretty sure this problem is caused by the different .NET Framework versions. Is there any workaround which could help when loading DLLs with lower .NET versions?
I managed to find a solution where I manually load the DLL before it is referenced. I used the Assembly.LoadFrom(assemblyPath) function.
https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.loadfrom?view=net-6.0
Related
Since English is not my native language I'm gonna try to explain myself as clearly as possible.
I have an old project on Visual Basic targeting the .NET Framework version 4.5.2, the project has a reference to System.Drawing dll but no System.Drawing.Common dll reference, when executing the application on my development PC it works fine.
My problem is that when I execute it in a virtual machine that I'm starting to use by requirement of my boss that had no .NET installed, the application cannot found a reference to System.Drawing.Common dll; I already have installed on the virtual machine:
.NET Compact Framework 2.0 (Since my boss told me that it could be some even older dlls)
.NET Compact Framework 3.5 (Since it went with the 2.0 version)
Windows Desktop Runtime 3.0.3 (Cause I found some links that said the dll is part of .NET Core)
Windows Desktop Runtime 3.1.3 (Just in case)
And trying to install any of the .NET 4.x versions tells me that its already installed cause the OS is Windows 10.
Since that seemed not to work I also put a copy of System.Drawing.Common.dll directly in the executable directory and modified the project to load it when the AssemblyResolve event fires. But it still not working, and also I canĀ“t understand why is it requesting that assembly if none of my dlls and exe reference to it.
I'm trying to keep the virtual machine with no developer tools so i'm not sure what else to do. Would be pretty grateful if anyone has some clue of what my problem is. Thank you.
Edit: what makes more noise in my mind is: If System.Drawing.Common is a dll of .NET, shouldn't it be automatically loaded to any .NET application when it is needed? or at least be recovered since I already put the dll in the same folder as the .exe file of my application
when i am setting Target .Net Framework to 3.5 and build the solution, it was showing [System.Bad_Image_Format Exception:'Could not load file or assembly 'interop.Redemption,Version=5.18.0.0'']
Interops are version agnostic. You need to re-add the reference to the project. Make sure the bitness of the reference assembly corresponds to your project's one.
I'm in C# in Visual Studio running 2015 Update 3.
I'm using a dll that I made myself for the backend of a system, and in the references of the project, one shows the "System" as Version 2.0.5 and the project being used as a dll shows it as 4.0.0. I believe this is the cause of a conflict that is preventing me from running this app. How do I update just the system version or even specify it so I can make them the same?
I think you should go to the references of your project containing the old reference, remove System and add it with version 4.0.0.0. However, you should also check that target .NET framework versions match (maybe the older dll is obtained compiling against .NET framework 2.0 and the newest one against .NET framework 4.0).
In order to find out the cause that is preventing you from running the application (you should provide what is happening), an useful tool is Assembly Binding Log Viewer which will show the exact assemblies that the application is trying to load (fully qualified assembly names).
I'm using VS2013 with PTVS and have the problem, that i have no IntelliSense support for self written c#/.net assemblies. The assemblies are all referenced in the project. I'm using .net framework 4.5.1. The referenced system dlls are available via IntelliSense (like System or System.Data).
IntelliSense also works for custom dlls, if i use clr.AddReference at the top of a script. But this is no solution. What am i doing wrong?
Maybe some one has a solution, thank you!
I am trying to make a setup for a C# application in .NET 3.5.
The application runs an other application which was compiled for .NET 4.5 and uses some DLLs. I want to add this application to the application folder in the setup.
I can't add the DLL's to the setup as a file, there is an error popping up. ("The operation could not be completed")
If I add the DDLs to the project folder and then use them as content, I get an "Unrecoverable build error" when I create the project.
How am I supposed to add these DLLs? I do not care how, but I need them in the project folder.
Thanks.
PS: I am using the standard setup for VisualStudio 2008.
With Visual Studio, when you add your external DLL as a reference in a project, it will automatically be added to the setup.
First of all, isn't there any way to find an earlier version of the assembly targeting .NET 3.5? Or if you have access to the source, remove/change the .NET 4.5 specific code and recompile?
Otherwise, you can try to wrap you dll around a COM interface, as described here. This article targets .NET 4 dll used with .NET 2.0 but the mechanism should still work in your configuration. I have used it successfully myself for 2.0/4.0 interop.
Here is another trick you can try.
Consider that in either case you will need .NET 4.5 installed on target computer, in order to work. So you can move your project from 3.5 to 4.5. I understand that you use VS2008 which doesn't have .NET 4.5, but you can use express (free) edition of Visual Studio from here -> Microsoft Download Page
I solved this problem using a simple trick:
The errors came only from the DLLs written in .NET 4.5. The executable (.exe) did not cause any errors. What I did is to package all the DLL's into the exe using the ILMerge tool.
Then I added the .exe file to the library and everything worked like a charm.
ILMerge download site (Microsoft)