I'm developing a .NET application. The application uses a managed library. The application only works with a specific version of this library.
Currently I'm including a copy of the library's DLL files alongside the application. This works fine if the user does not have the library installed. The problem is, if the user has another version of the library installed, the application uses that version instead of the one included alongside the application.
How can I disable or override this behaviour? I've tried Googling it and the only answers that I've found seem to either relate to unmanaged assemblies or refer to specifying a path for a library that isn't installed.
EDIT: I did some more investigation and it turns out that the two versions of the library have the same version number and public key token, so there's no way for the system to distinguish between them. So basically I need to force the system to use the supplied version instead of the version in the GAC, even if it thinks they're the same.
You can try setting the Specific Version of the reference to true.
You can set that property on the property pane of the reference to the assembly.
Related
I have the following situation:
In my workplace, I am developing a plugin based Desktop Application.
The goal is that the plugins are completely independet in their functionality spectrum from the Core Application.
Now I have the situation that the Core references Version 1.0.0.4 of a library, but a plugin references version 1.0.0.8 of the same library.
The plugin and all needed references are merged into a single .dll file using Fody.Costura.
When running my Application, i get a "System.MissingMethodException",
because the plugin calls a method of the aforementioned library, that is not yet present in the version the core uses.
How can I explicitely tell the plugin to load and use the assembly version that is embedded in the plugin itself?
I can't seem to find a way to accomplish this, i have already tried using Binding Redirect to the newer version, or loading the assembly manually in code, but it just won´t work...
I know that there are two GACs will be available on a system where latest .NET framework is installed.
i.e. "C:\Windows\assembly" for framework lower than 3.5, and "C:\Windows\Microsoft.NET\assembly\GAC_MSIL" for 4.0 and above.
Now, I have two questions:
First question is, I've a C#.NET assembly developed in frawework 4.5 and i have to add a reference to Microsoft.Office.Interop.InfoPath.Xml.dll.
I'm not finding this reference in the latest GAC, but it is there in the old one. So can I add from the old GAC?
Second question : If I install a latest version of Office, this reference also get migrated to another version. So unless I re-refer this dll in my project, my assembly cannot load the mentioned dll as it is checking for exact version number. Is there a generic solution for this, so that I need not change the reference and rebuild my application?
Remove the references to the GAC and use the assemblies from the file system. Set CopyLocal = TRUE;
You may need more than the one Assembly, an article here - InfoPath Interop describes the assemblies required.
The InfoPath primary interop assemblies can be downloaded here: http://msdn.microsoft.com/en-us/library/15s06t57.aspx
I have created an application which requires the ODBC Connector to be installed on the computer to work. As my application need to connect to mysql database, it needs only one dll file (MySql.Data.dll) to work.
When i put this dll in the same location as the application it works ok. Now i want to merge this dll so that i will have only one Executable at the end ?
How can i merge this dependant DLL with my executable ?
You can't do that, all assemblies will get referenced from somewhere...
From the .NET framework path like:
System.Net.dll
All .NET apps need .NET Framework assemblies to run and that's why the user that want to execute your app needs .NET Framework installed. So your app knows where to find this assembly and won't need you to put, for example, the System.Net.dll assembly in the same path of your app for a success running.
Or from external paths like you app does.
Your app knows where to find .NET Framework assemblies to run but wait! it needs also some extra dll to run, so that's why you get the MySql.Data.dll in the same path when compiling your app.
Possible solution:
1. If you want to make just one executable try to use Spoon Studio (hard to find full cracked version and expensive to buy it). This will give you the possibility to embedded any assembly like the one you want or all .NET Framework, so this will make your app not dependant from any .NET Framework installation or needed assembly in the user computer that executes your app.
2. Try to use ILMerge, but please read below links to know if your code fits the requirements.
How to and important information:
http://www.codeproject.com/Articles/9364/Merging-NET-assemblies-using-ILMerge
http://www.blackwasp.co.uk/ILMerge.aspx
If it's a pure .NET module, you can try the ilmerge utility.
I have a ASP.NET web application in which I have references to a couple of Class Libraries I developed.
Each of these libraries has a version number set in the AssemblyInfo.cs file.
I would like to force the application to use only libraries with a specific version. i.e.
If I have User.dll of version 2.5.0.0 which is a referenced in the web application, and I try to copy in User.dll of version 3.0.0.0 I want the application to fail... or well just give me an error of some sort.
Also I do not want to store the assemblies in the GAC.
Is there some setting in web.config file I could use?
Thanks
You need to sign the referenced assemblies with a strong name.
I am creating a Class LLibrary in c# by using microsoft provided Dll's.
Now i want to statically add those Microsoft provided libraries to My Dll.How can i do this.
I have simply added a reference to those Microsoft provided Dlls and creating My Dll? Is it fine or not?
if Microsoft provided dll is not available on other machine then my Dll may fails i need to add the libraries statically??
How can i do this??
There's no such thing as statically linking to another assembly in .NET. There are some third party products such as .NET linker that merge assemblies into one but they are unsupported.
If you have the redistribution license for that library, you can ship a copy along with your assembly. In Visual Studio you can make this happen by setting "Copy Local" to "True" in the properties window for that assembly reference.
See discussion here and read the comments -- Jeff does provide a way.
http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx
If the dll is not available at execution time; yes it will fail. However:
many Microsoft dlls are pre-installed with .NET (caveat: "client profile")
many of the Microsoft dlls are redistributable; so you can include them with your package
There isn't a linker provided in the core framework, although ILMerge may be useful.
Its not very clear what you want to achieve but it seems you are concerned that your class lib will work on some other machine or not. The thing is that the .Net framework is a free redistributable which should be installed if not present on the target machine. With the .Net framework already installed on a machine, there should be no problem as such.
Static linking as such does not make sense in .Net other that adding an assembly reference to your project. Hope it helps