Solved

How do I Install a .net 4.5 dll in GAC?

Posted on 2014-11-13
8
1,154 Views
Last Modified: 2014-11-23
I have created an integration pack with C# for System Center Orchestrator 2012 that runs on Windows Server 2012 R2 that depends on Newtonsoft.Json which is in Newtonsoft.Json.dll. When I run the runbook I get:

Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

Exception: FileNotFoundException
Target site: LogIn.Execute

Stack trace:
   at MyClient.LogIn.Execute(IActivityRequest request, IActivityResponse response)

I first thought I could use Ilmerge to merge the dependent dlls together, and I used this guide to set this up automatically when compiling in Visual Studio 2013: http://www.hanselman.com/blog/MixingLanguagesInASingleAssemblyInVisualStudioSeamlesslyWithILMergeAndMSBuild.aspx

But when doing this, and including both the required dll and dependent projects for the merging - the compile and merge takes for ever. The reason is that several sub-projects use .net and all those dependencies need to be merged as well - which is alot.

So then I thought I might want to install the required dll into the GAC. I found http://camerondwyer.wordpress.com/2013/05/22/how-to-install-a-dll-to-the-gac-on-windows-2012-using-only-powershell-without-having-to-install-sdk-or-visual-studio/, but this installs into the .net 4 part of the gac I suppose, because it didn't fix my problem and the dll is compiled for .net 4.5 of what I can see.

The options I have is to be able to ilmerge without merging the whole .net or install the dll on the Orchestrator runbook server so that my integration pack can use it. Any suggestions?
0
Comment
Question by:itnifl
8 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40439721
personally I don't like bloating the GAC and only install .dll's on an as needed basis.
0
 
LVL 2

Author Comment

by:itnifl
ID: 40441270
OK, I understand. Do you have a suggestion for a better solution for me? Would be nice to get this working :p
0
 
LVL 40
ID: 40446476
"Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0"

Unless there is a coincidence in the version numbers, you need the Framework 4.5 installed on that computer. Installing only one dll from the framework will not be enough.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 14

Expert Comment

by:CtrlAltDl
ID: 40447720
Unfortunately Jacques is right, you will need to install .net Framework 4.5 on that computer.  Is there reason you can't do that?  Is it a shared hosting server or something?  IT admin won't allow it to be installed?

https://support.microsoft.com/kb/324733
"You cannot include the .NET Framework in a Windows Installer setup package that you create by using Microsoft Visual Studio .NET deployment tools. The .NET Framework must be installed separately."
0
 
LVL 2

Author Comment

by:itnifl
ID: 40449455
Hello and thank you for your reply. I think you guys are mistaking. Net 4.5 is installed on the server where this is running: .Net 4.5 is installed
It isn't the framework that is missing, but Newtonsoft.Json that is missing. Newtonsoft.Json is not a part of .Net 4.5, but uses it as far as I know.

My Integration Pack uses Newtonsoft.Json which is added to my Visual Studio project using NuGet. It compiles into Newtonsoft.Json.dll which in <my project>\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll and <my project>\bin\Debug\Newtonsoft.Json.dll:
Overview
When using ILmerge to merge all dll's at compile time, the command looks like this:
"C:\Program Files (x86)\Microsoft\Ilmerge\Ilmerge.exe" 	/out:
	"C:\Users\username\Documents\stash_prosjekter\SCO Integration Packs\myProject\bin\Debug\myProject.dll" 
	"C:\Users\username\Documents\stash_prosjekter\SCO Integration Packs\myProject\obj\Debug\myProject.dll" 
	"C:\Users\username\Documents\stash_prosjekter\SCO Integration Packs\myProject\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll" 
	"C:\Users\username\Documents\stash_prosjekter\Models\API\models\bin\Debug\models.dll" 
	"C:\Users\username\Documents\stash_prosjekter\WebRequestor\bin\Debug\webrequestor.dll"

Open in new window


The strange thing is that when I create the integration pack or oip file with  Orchestrator Integration Pack Wizard, I have chosen to include Newtonsoft.Json.dll as a dependency. This should be enough so that the Integration Pack would have access to the file to use the code there, but this time it seems not to be ok.

Looks like the integration packs get installed here:
C:\Program Files (x86)\Common Files\Microsoft System Center 2012\Orchestrator\Extensions\Support\Integration Toolkit, my particular integration pack is here: C:\Program Files (x86)\Common Files\Microsoft System Center 2012\Orchestrator\Extensions\Support\Integration Toolkit\f3533bfa-e025-4189-a5c2-a7164d5083c0, and all the dlls are there - even Newtonsoft.Json.dll. So all should be ok, but it is not...
0
 
LVL 2

Accepted Solution

by:
itnifl earned 0 total points
ID: 40449970
The answer to my initial question is to use gacutil.exe to install the dll, but after doing this I still have the same problem as described above.
0
 
LVL 2

Author Closing Comment

by:itnifl
ID: 40460409
Gacutil.exe can be used to install dlls to the GAC, but I can't see that it has helped me.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now