I have a typical problem of loading a dll from GAC. My application references a dll called MyAssembly.dll. Its assembly version is 1.1.6 and file version is 1.2.100 and it is added it to the GAC.
After a bug fix I updated the file version to 1.2.110 (but the same assembly version as there were no changes in the binary) and deployed to the GAC and the application works fine. But for some reason when i installed the previous build (Wise Installation, obfuscated dll), my application stopped working. It gives a Missing Method Exception. if I install the build 1.2.110 (Wise installation, obfuscated dll) my application works fine.
I am not sure why this strange behavior. When installing the lower version (1.2.100) on a machine where 1.2.110 is present, the dlls in the GAC are not overwritten. But when I load the dll and reads its AssemblyFileVersion attribute it says 1.2.100. But FileVersionInfo.GetVersionInfo gives me 1.2.110.
Could anyone help me with solving this issue, please?
The issue was solved by installing the assembly using ngen.exe utility.
Related
I've made a project with c# in which I use "Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll" as a reference assembly.
When I install my program on another computer it gives me an error message:
unable to run the application requires that assembly
microsoft.data.schema.sql.unittesting version 12.0.0.0 in the global
assembly cache
How can I install this .dll in GAC using code.
This assembly is used for unit testing databases. It's shouldn't be needed by your production code.
Remove it from your project references and try if the solution still builds and, if so, the program still works on both your machine as well as on another machine.
I have a project that is build on Any CPU configuration, .Net Framework 2.0, vs2008 with 32bit version of SQLite dll used in it.
Well this works fine on my 32 processor environment, but when i ran this project on 64bit processor environment i experienced
"Could not load file or assembly 'System.Data.SQLite, Version=1.0.66.0, Culture-neutral,
PublicKeyToken=db937bc2d44ff139' or one of its dependencies.
An attempt was made to load a program with an incorrect format."
I even tried adding 64 bit dll on my project but it did not work.
I have tried all the solutions but that did not work for me. Since i am bound to build the project on 32 bit machine, i need a way to run this tool on my 64 bit environment too.
Any suggestions/comments/improvements means a lot for me.
Thanks in Advance.
Compile your application using x86 configuration.
When dealing with dlls like SQLLite that are compiled for x86, your process must be running in x86 mode.
I find these steps can be used to deal with sqlite.
Download NuGet
open cmd and type nuget install System.Data.Sqlite -- note it will create a folder in your current directory
copy dlls from net20 folders to your solution like so.
Add a reference to System.Data.SQLite.dll
Make sure you copy both SQLite.Interop.dlls to your output dir
Hope it helps.
I am upgrading an application and running into some issues with it.
Now the old application was version 1.0 and loading a depedency assembly A at version 2.1.1 The assembly is present in application local directory.
I am upgrading the new application to version 2.0 that will load assembly A version 1.0.1 which is present in its application local directory. I've checked application references using ISpy and confirmed the new application references A version 1.0.1
But when I start the new application (v 2.0), it is still trying to load assembly version 2.1.1 and failing. I checked the app.config, machine.config and GAC and there is no redirection for version of assembly A. I also checked fusion log files but don't see any redirection. All I see is the fusion log is that application prebinds A at version 2.1.1 and hence fails to set up the assembly present in its local directory.
Is there something I am missing here? What could be the possible reasons for application still referencing the older assembly at runtime?
Update: Using some tools, I realized the the older assembly is being referenced from a native DLL that is referenced by my application, but I don't know which third party DLL is that, and the application loads a ton of them. The fusion log confirms it by logging "Calling assembly : (Unknown)." for the missing assembly.
Now my next step is to find which dll is referencing the wrong assembly and fix that. Now the problem is that ILSpy tool doesn't show the native DLLs references, and DLLDepends tool does not show the assemblies references, so I am not able to link the two.
thanks
Since the library your trying to reference is supposed to be apart of the GAC; you may want to try:
Control Panel
Small Icons(Administrative Tools)
Event Viewer
Application
Windows itself should throw an exception with some particular details it's attempting to reference when it has an error. Especially if it's apart of the GAC. It was more helpful for me to hone in mscoree.dll and mscorelib.dll libraries fairly easy. Granted those clients that I used that for had corrupt framework; but Event Viewer told me the exact library that it had an issue with.
You may want to try that. Not sure which library; but keep in mind this is usually beneficial to libraries that are found within the %windir%/Assembly folder. Hope that helps.
I have a Class library project. I am installing this dll produced by the project into the GAC by the command "gacutil /i [Path of the dll]". This dll is used by a windows application. When windows application runs, it successfully accesses the functions and properties of the dll.
Now I have made some changes to the dll. I have uninstalled the original dll from the GAC and will install the newer dll with the required changes. Now when the windows application uses this dll, the new changes from the dll are not getting reflected in the application. The new changes should reflect into the application as I installed the new dll into the GAC.
The Name, version and Public key token is the same for both dlls. I think it won't matter as the i have uninstalled the previous dll and installed the new dll into the GAC.
Am I doing something wrong?? Please suggest a solution.
Thanks and Regards,
Mayur Mahajan
I would suggest for debugging purposes that you version your dll, then print the version to your application to be sure its being updated. Include the System.Reflection namespace and the code would run look like the following:
Assembly assembly = Assembly.LoadFrom("unknown.dll");
label.Text = assembly.GetName().Version.ToString();
I'm using ClickOnce for installing my application written in C#. Everything worked fine till the last update after which start of my application ends with an error saying:
Could not load file or assembly MyAssembly... HRESULT: 0x80131040.
After some research I've found that there is an old version of MyAssembly located in my application's ClickOnce cache folder (C:\Documents and Settings..\Apps\2.0...). However there is an actual version in the deployment package.
I've also found this old version of MyAssembly in a standalone directory in the ClickOnce cache named after this assembly (plus some characters added).
It seems to me that for some reason ClickOnce used this old version of MyAssembly from the cache instead of the new version from the deployment package.
Uninstall/install of my application won't help.
How is this possible?
I have had the same behaviour. It mentioned the problem in another question. Since then, it has happened several times for us with different applications. One strange thing is that it behaves differently on different computers. So one computer could have been updated with the new assembly while another got the old one copied.
.NET ClickOnce deployment and wrong assemblies called after updated version
This appears to be a bug in .NET framework 3.5 SP1.
See Microsoft KB 971052.
Make sure this old assembly is loaded. You can use DllProfiler for that.