Bonjour,
je dois modifier une url d'appel à un webservice sur une application développée il y a 10 ans !
Je ne connais pas pas c# mais je fais avec !
J'ai installé la dernier version de visual studio code
J'ai à priori le framework 4 :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
c:\Windows\Microsoft.NET\Framework\v4.0.30319>reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Version
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
    Version    REG_SZ    4.8.09037
J'ai une url à modifier dans le workers.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
public Worker()
        {
 
            client = new RestClient("https://sdmp-mws.site.fr/MOB/index.php/");
            client.Authenticator = new HttpBasicAuthenticator("webservice", "merci");
        }
J'ai ceci dans lauch.json : je ne sais pas à quoi ça sert !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{ 
    {
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/bin/Debug/ClientSauvegardeEnsLyon.exe",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "console": "internalConsole"
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}
et task.json :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
   {
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe",
            "args": [
                "/t:build",
                "/p:Configuration=Debug",
                "/m"
            ],
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
 
}
J'ai ceci dans le csproj
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{F8EC6EA2-DE62-4430-9FB8-2317F0232804}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>WpfApplicationBackup</RootNamespace>
    <AssemblyName>ClientSauvegardeLyon</AssemblyName>
    <TargetFramework>net4.0</TargetFramework>
run avec debug donne ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
[Info  - 9:55:08 AM] [LanguageServerProjectSystem] Loading c:\Users\ydaoulat\Desktop\Client Sauvegarde de Lyon\WpfApplicationBackup\WpfApplicationBackup\WpfApplicationBackup\WpfApplicationBackup.sln...
[Error - 9:55:08 AM] [LanguageServerHost] Microsoft.CodeAnalysis.MSBuild.Rpc.RemoteInvocationException: An exception of type System.InvalidOperationException was thrown: Failed to find all versions of .NET Core MSBuild. Call to hostfxr_resolve_sdk2. There may be more details in stderr.
   at Microsoft.CodeAnalysis.MSBuild.Rpc.RpcClient.InvokeCoreAsync(Int32 targetObject, String methodName, List`1 parameters, Type expectedReturnType, CancellationToken cancellationToken) in /_/src/Workspaces/Core/MSBuild/Rpc/RpcClient.cs:line 163
   at Microsoft.CodeAnalysis.MSBuild.Rpc.RpcClient.InvokeAsync[T](Int32 targetObject, String methodName, List`1 parameters, CancellationToken cancellationToken) in /_/src/Workspaces/Core/MSBuild/Rpc/RpcClient.cs:line 114
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.OpenSolutionAsync(String solutionFilePath) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 103
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.OpenSolutionAsync(String solutionFilePath) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 116
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 157
 
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1229,5): error MSB3644: les assemblys de réfé 
       rence pour .NETFramework,Version=v4.0 sont introuvables. Pour résoudre le problème, installez le Developer Pack (kit SDK/Pack de ciblage) correspondant à cette ver 
       sion du framework, ou reciblez votre application. Vous pouvez télécharger plusieurs types de .NET Framework Developer Pack sur https://aka.ms/msbuild/developerpack 
       s [C:\Users\ydaoulat\Desktop\Client Sauvegarde  Lyon\WpfApplicationBackup\WpfApplicationBackup\WpfApplicationBackup\WpfApplicationBackup.csproj]
En fait je ne sais pas ou chercher ?
Comment lui dire de travailler à le framework 4 ensuite c'est docnet j'ai essayé le frameword 8 j'ai plein d'erreur !!!
Avec framework 4 On fait comment pour compiler ?
Merci