I'm writing C# code in a script task in SSIS. I need to use the Newtonsoft JSON package in the code so i have installed it from NuGet. When it is first installed it works fine, but when I close my code and re-open it to make a change, I have to re-install the package using update-package -Reinstall as per the Some NuGet packages are missing from the solution in Visual Studio Application post.
Why do I have to do this every time? Am I doing something wrong?
Thanks for your help.
I found that adding the assembly to the GAC manually fixed the issue for me. To do this:
Open the "Developer Command Prompt for VS (SSDT)" in admin mode.
Run this command: gacutil -i "assembly name"
For the assembly name, I just needed to browse my local drive for a copy of the DLL i was adding and then use the full file path (C:...Newtonsoft.json.dll) in the "assembly name".
https://learn.microsoft.com/en-us/dotnet/framework/app-domains/how-to-install-an-assembly-into-the-gac
https://learn.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs
Try installing Json.Net from solution explorer:
json.net
How to Install Json.Net in Visual Studio Projects
Workaround
Instead of using Json.Net you can benefit from System.Web.Extension assembly which is a part of the .Net Framework, you can refer to the following link for a step by step guide on how to parse JSON using this assembly:
Importing JSON Files Using SQL Server Integration Services
Related
Intellisense has stopped working for me and whenever I run VSCode this error comes up in the OmniSharp Log.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj'.
/Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj
/Users/leogaunt/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1178,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /Users/leogaunt/Documents/Programming/Unity/Cube Stack/Assembly-CSharp.csproj
I have tried re-installing the plugin, and re-intsalling VSCode but it hasn't worked.
I know I have .NET Core installed as I am a Mac user and I know this because when I type dotnet --version in terminal it outputs:
3.1.401
I am programming in Unity and am creating a game for iOS.
Change the mono path to always, in C# extension config.
For anyone that uses VSCode v1.67.2 dotnet v3.x.x and OmniSharp v1.25.0 (or v1.23.17 and above).
The above accepted answer does not solve the issue.
The simplest thing to do is downgrade ms-dotnettools.csharp (C# Extension), the only issue is if you downgrade to any version above v1.23.16 it gives you "Can't install 'ms-dotnettools.csharp' extension because it is not compatible with the current version of Visual Studio Code (version 1.67.2)"
I suggest to downgrade it to version 1.23.16 and restart vscode.
Your Intellisense should start working.
My Environment
dotnet v3.1.417
VSCode v1.67.2
C# Extension v1.25.0 (now downgraded to v1.23.16)
Running in Remote Container on a Mac host.
Yes I am using 3+ year old dotnet version. It's a legacy software, it happens, everyone has skeletons in their systems ;)
Trust me it'll work, tried everything and then came to this
Go into VS code Preferences
Search for omnisharp.path and click on edit in settings.json
Add/edit line "omnisharp.path": "latest" (remember to add a comma at the end of the previous line)
Go back into settings and search omnisharp, scroll down till you find Use Global Mono, change that to Always
After this you will have to download Mono, mac's mono download link is this https://www.mono-project.com/download/stable/#download-mac
After the download finishes, set it up by opening the download file
Go back to settings.json and add mono's /bin path as "omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/6.12.0/bin" which is the default download path for mac, if you wanna confirm this, go into mac's disk space and then follow the above mentioned path)
Finally restart VS Code and it should work (in case it still doesn't, restart it again)
I downgraded the VS Code's C# extension to 1.24.3 from 1.25.0 and it worked.
I had the same Problem after fetching Unity from a git repository.
For me it worked to reset the .Net Version in Unity.
Edit -> Project Settings -> Api Compatibility Level
Switched that back and forth, restarted VSCode. The .csproj-file will file out all the missing dlls.
I solved this by uninstalling all SDK's and installed the older 4.7.1, then everything worked instantly.
I had the same problem. Here's how I fixed it:
I added all projects to the solution file (dotnet sln add <project name>) and opened the project in vs code by passing the path to vscode from terminal
(code <project path>).
The error says that OmniSharp is looking for Version=v4.7.1. You may want to install the latest version of it.
I downloaded Newtonsoft.Json.11.0.2 package by package manager console,
and it certainly showed that the package is installed in project.
However, when I try to use the package
using Newtonsoft.Json
visual studio keeps warning me the name is not found and draws red underline.
What should I do? uninstalling and reinstalling the package didn't work.
Make sure you have selected same project while installing package
Add a reference by clicking on your project in the solution explorer with right click -> References -> Newtonsoft Json.
Add it and compile.
Had the same issue, i notice that i have some bll files that have been installed
Microsoft.AspNetCore.Mvc.NewtonsoftJson
Newtonsoft.Json
Newtonsoft.Json.b..
i removed all the files exept 'Newtonsoft.Json' closed the vs.code reopened it and it worked!
I have a project that I have on TFS online. When Im trying to build the project, I get the following error:
Severity Code Description Project File Line
Error The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'file:///C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll' or one of its dependencies. Could not find the file. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. ContosoUniversity
Has this something to do with that Azure don't support ASP.NET 4.6?
Here was the fix for me. Using Nuget Package Manager, remove these two packages if referenced:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
After that, run a rebuild. This ensured that the build was not trying to use a specific build exe. Click here for the Diff against previous revision
No, it is not related to Azure Web Apps doesn't support ASP.NET 4.6. Actually, you get this error message because NuGet packages are checked into version control.
So, you need to remove folder TestProject\ContosoUniversity\packages from TFS and build again. See: BuildTasks.Csc task could not be loaded from the assembly?
I had the same problem sometime ago, to fix it:
make sure your packages are not under source control
Force restore all package, by deleting the package folder
restart your visual studio
In my case it got resolved by updating the below two Nuget packages to the latest version:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
Delete the packages folder or its contents, clean, rebuild solves the problem for me.
If you take a look at the file in reference it points you to a packages location. It turns out that NuGet packages is broken
To Resolve: you simply need to delete that packages folder (usually under project name \ project name \ packages.), then on build, Nuget will restore all the required packages.
I needed to update all my Nuget packages on my development box, then check the project in to TFS again.
For added peace of mind, I deleted the packages folder in the Team City build folder.
In case someone looks at this later on.
I was getting this issue only when building in DevOps.
But after manually deleting packages in my local build I started getting the same issue locally.
After removing the apparently missing NuGets using the NuGet manager the issue resolved it's self both locally and on azure.
Not sure what caused it but might save someone a headache in the future.
I was using .net 4.7.2
I'm trying to use R with C#. I'm using Unity and MonoDevelop on the C# side and I've R version 3.2.1. I've tried my best to follow instructions here: http://jmp75.github.io/rdotnet/getting_started/
But I'm stuck. Here's what I've done
download nuget.exe, put it in a folder already in PATH.
open CMD.exe
run nuget install R.NET.Community
If I try to reinstall R.NET.Community with the same command above, I got the message that it is already installed (which is good I guess).
My question : what now? I tried to run the RDotNet namespace, but it's not recognized. Obviously I need to set up something else, but I do not know where and what. Any lead would be appreciated!
I wouldn't expect just running the nuget install to add a reference into your project - the nuget installer is basically just downloading the package for you.
You could manually add a reference in your project to the relevant assembly file (.dll) that has been downloaded. However, it would be better to use a package manager within MonoDevelop. If you're using MonoDevelop 3.x or 4.5, you should use the NuGet MonoDevelop add-in and use that to manage the NuGet packages for your project. MonoDevelop 5.x has a NuGet package manager built in, apparently.
I am writing a Windows Phone app, at the beggining using VS 2010 Express for windows phone. Then I installed VS 2012 and i made a desktop app which consumed JSON/REST service using RestSharp. Due to lack of support for plugins in Express version, i got full VS 2010 Ultimate and installed Nuget. When I create a win phone library project, and i add a RestSharp package, it shows in References, but i cannot access any of it's classes (and using RestSharp is underlined in red color). Also, when i Remove it and add again from Add Reference i get an Incompatible reference error window:
RestSharp.WindowsPhone, Version=103.2.0.0, Culture=neutral, PublicKeyToken=null" is incompatible with
Windows Phone 7.1
In order to add it yourself you should to change the project's terget to a compatible framework first.
It also appears if i change the target to WP 7.0.
Has anyone solved similar problem?
In my case this was because there was a packages.config file in the project folder but not in the solution. This was why I could not add the reference again properly. Delete this file from the physical disk, and re-run your Install-Package command. It should add this correctly now.
Are you using source control?
The it might be possible that you have not yet set the solution to enable package restore (NuGet documentation).
Right click on the Solution node in Solution Explorer and select
Enable NuGet Package Restore.
After that Solution Explorer will contain a few items more and there will be a new folder packages that was automatically added to your solution folder. You will need this folder to add to your version control because it will contain your installed NuGet packages.
That's it.
If you want to know more, here's more details on what it (automatically) does for you:
It added a solution folder named .nuget containing NuGet.exe and a
NuGet.targets MsBuild file. It also changed every project in the
solution to import the NuGet.targets MsBuild task.
With this in place, any time a project is compiled, the build task
will look at each project's packages.config file and for each package
in that file, ensure that the corresponding package exists within the
packages folder. For any missing package, the build task will download
and unpack the package.
In the restore scenario, NuGet will grab the exact version when
restoring a package. It will not perform any upgrades.
Additionally, if you have the latest NuGet version installed, will now find a new option unter Tools -> Options... -> Package Manager -> General -> Allow NuGet to download missing packages during build that I would also suggest to use.
The name says it all. If the solution is configured to use a certain NuGet package but the package is not yet installed on your development machine, NuGet will download it automatically for you when you do your next build.