Avatar of itnifl
itnifl
Flag for Norway asked on

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

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?
.NET ProgrammingSystem ProgrammingC#

Avatar of undefined
Last Comment
itnifl

8/22/2022 - Mon
David Johnson, CD

personally I don't like bloating the GAC and only install .dll's on an as needed basis.
itnifl

ASKER
OK, I understand. Do you have a suggestion for a better solution for me? Would be nice to get this working :p
Jacques Bourgeois (James Burger)

"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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
CtrlAltDl

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."
itnifl

ASKER
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...
ASKER CERTIFIED SOLUTION
itnifl

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
itnifl

ASKER
Gacutil.exe can be used to install dlls to the GAC, but I can't see that it has helped me.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.