Friday 5 February 2016

[Solved] Could not load file or assembly 'NuGet.Core, Version

I was getting the same and resolved this issue by following these steps.

Solution: 

A. Check is available in GAC or not.
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\NuGet.Core\v4.0_1.6.30117.9648__31bf3856ad364e35\NuGet.Core.dll



or

B. Check is available in BIN folder of your application or not.
....\BIN\NuGet.Core.dll




If not you may download from http://docs.nuget.org/consume/installing-nuget
Install and you will find NuGet.Core.dll.
Now placed in any of the mentioned location.



Core Error:

Server Error in '/' Application.

Could not load file or assembly 'NuGet.Core, Version=1.6.30117.9648, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.Core, Version=1.6.30117.9648, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[FileNotFoundException: Could not load file or assembly 'NuGet.Core, Version=1.6.30117.9648, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
   System.Reflection.RuntimeAssembly.GetExportedTypes() +21
   System.Web.WebPages.ApplicationParts.ResourceAssembly.GetTypes() +13
   System.Web.WebPages.ApplicationParts.ApplicationPartRegistry.Register(ApplicationPart applicationPart, Func`1 registerPageAction) +116
   System.Web.WebPages.ApplicationPart.Register(ApplicationPart applicationPart) +51
   System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +110
   System.Web.WebPages.Administration.PreApplicationStartCode.Start() +28

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +155
   System.Web.WebPages.Deployment.PreApplicationStartCode.LoadWebPages(Version version) +238
   System.Web.WebPages.Deployment.PreApplicationStartCode.StartCore(IFileSystem fileSystem, String appDomainAppPath, String binDirectory, NameValueCollection appSettings, IEnumerable`1 loadedAssemblies, IBuildManager buildManager, Action`1 loadWebPages, Action registerForChangeNotification, Func`2 getAssemblyNameThunk) +256
   System.Web.WebPages.Deployment.PreApplicationStartCode.StartCore() +167
   System.Web.WebPages.Deployment.PreApplicationStartCode.Start() +33

[InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +547
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34209