Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS0433 #708

Closed
nczsl opened this issue Mar 18, 2023 · 3 comments
Closed

CS0433 #708

nczsl opened this issue Mar 18, 2023 · 3 comments

Comments

@nczsl
Copy link

nczsl commented Mar 18, 2023

类型“Uri”同时存在于“System.Private.Uri, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”和“System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中 [web.csx]csharp(CS0433)
image
image

@nczsl
Copy link
Author

nczsl commented Mar 19, 2023

I know where my problem is coming from because every time I open vscode, a folder called 'net461' is automatically created at a location such as 'C:\Users\hjjls\AppData\Local\Temp\dotnet-script\E\netenv\bofu\Auth'. This is the root of a series of problems I am experiencing because I have not installed any versions other than .NET 7. Therefore, if the script in the .csx file secretly decides to use another version such as net461, then it will produce the series of errors I mentioned earlier. Is there any way to solve this problem? Currently, I can only manually delete it, and deleting net461 can solve the errors such as duplicate assemblies that I mentioned earlier.

@filipw
Copy link
Member

filipw commented Apr 3, 2023

by default omnisharp will treat your scripts as net461 which is hardly what you want - it seems you want to have net7.0.
you should create a file omnisharp.json at the root of your script folder with the following content

{
  "script": {
    "enableScriptNuGetReferences": true,
    "defaultTargetFramework": "net7.0"
  }
}

You can also do it globally by adding this omnisharp.json to the %USERPROFILE%/.omnisharp/ folder

@nczsl
Copy link
Author

nczsl commented Apr 4, 2023

by default omnisharp will treat your scripts as which is hardly what you want - it seems you want to have . you should create a file at the root of your script folder with the following contentnet461``net7.0``omnisharp.json

{
  "script": {
    "enableScriptNuGetReferences": true,
    "defaultTargetFramework": "net7.0"
  }
}

You can also do it globally by adding this to the folderomnisharp.json`` %USERPROFILE%/.omnisharp/

Ok thank you, my problem seems to be solved!

@nczsl nczsl closed this as completed Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants