Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The application requires the assembly ... to be installed in global assembly cache

I have created an window application using C#. I am publishing the application which is successful.

When I am trying to install the application it is showing the below error.enter image description here

I am seen some solution which is about setting the project which automatically the same as below

enter image description here

I don't want to put the dll's in GAC.

Any suggestion or solution for this.

I have gone through the following urls

Error message "Unable to install or run the application. The application requires stdole Version 7.0.3300.0 in the GAC"
Unable to install or run the application: Click Once

like image 583
शेखर Avatar asked Mar 11 '16 10:03

शेखर


1 Answers

It is a ClickOnce error message, it is telling you that it cannot locate the JamaaTech.Smpp.Client.Net.Lib.v1.4.dll assembly. This is a particularly clumsy error message, you of course never want to use the GAC in ClickOnce. And it doesn't tell you about the real problem, you don't stand a chance to diagnose the problem. You know that the assembly is present, you definitely included it in the deployment package, so why can't it find it?

There is another reason why an assembly can't be loaded beyond the file simply not being present. It will also fail when the wrong version of the assembly is present. In other words, the [AssemblyVersion] of the assembly does not match the one you compiled your program with.

Looking at the attribute declaration in the library shows:

[assembly: AssemblyVersion("1.4.3.*")]
[assembly: AssemblyFileVersion("1.4.3.1")]

Note the * in the attribute. This is a horribly bad idea. Looks like the author likes semantic versioning but doesn't trust it enough to correctly track changes to the project. The * gets substituted at build-time by a seemingly random number, 21129 in your case. It is not that random, it is derived from the time of day. The number of seconds / 2 since midnight. You can deduce from the poor error message that it wants the one that was built at 11:44:18 in the morning and probably found another one.

What is likely to go wrong with this approach are the two references in your WindowsFormsApplication1 project. You are pretty likely to have added the Debug build of these assemblies as references. Which all works fine, you never noticed a problem when you debugged your app. But when you build the Release version of your app, like ClickOnce publishing will do, you'll now have a version mismatch, the Release build of these assemblies have a randomly different version number and will not match the version of the reference assembly.

Two basic ways to fix this problem, I recommend you use both:

  • Get rid of the horrid random number generator and edit the [AssemblyVersion] attribute. There are two, one in the JamaaTech.SMPP.Net.Lib/Properties/AssemblyInfo.cs source file and another in the JamaaTech.SMPP.Net.Lib/Properties/AssemblyInfo.cs source file. Just make them the same as the [AssemblyFileVersion], at least you can then see the version number when you look at the file with the Explorer.

  • You'll have to fix your solution. If you haven't already done so (you probably did), download the source code from the Codeplex depository and add the two projects to your solution. Use File > Add > Existing Project. Remove the assembly references in the WindowsFormsApplication1 project, they are definitely bad, and add them back, now selecting a project reference. This ensures that the assemblies are always built before your WindowsFormsApplication1 project and that it thus always uses the correct reference and thus the correct version number. Do make sure that the two DLLs in the Application Files dialog came from the project's Release build directory.

like image 167
Hans Passant Avatar answered Oct 10 '22 09:10

Hans Passant