Bonjour, j'ai récupéré un exemple de programme en C# qui utilise un DLL pour convertir des points de localisation cartographique, et en faite je souhaite l'incorporer dans mon programme en VB.NET, alors j'ai éssayé ceci

le programme en C# :
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ConversApi;
 
namespace Exemple
{
    class Program
    {
        static void Main(string[] args)
        {
            Conversion Conv = new Conversion();
 
            if (File.Exists("Convers.xml")) // Configuration à partir d'un fichier xml
            {
                Conv.ReadXml("Convers.xml");
            }
            else // Configuration manuelle
            {
                // Ajout des ellipsoïdes
 
                Conv.AddEllipsoid("WGS84", "WGS 1984", 6378137, 6356752.314245, 0);
                Conv.AddEllipsoid("CLRK80IGN", "Clarke 1880 IGN", 6378249, 6356515, 0);
 
                // Ajout des systèmes géodésiques
 
                Conv.AddDatum("WGS84", "World Geodetic System 1984", "WGS84", 0, 0, 0);
                Conv.AddDatum("NTF", "Nouvelle Triangulation Française", "CLRK80IGN", -168, -60, 320);
 
                // Ajout des projections
 
                Conv.AddProjection("UTM.WGS84", "Universal Transverse Mercator / WGS84;UTM;WGS84;0.9996");
                Conv.AddProjection("LT2E", "Lambert France zone II étendue;LAMBCC2;NTF;45.5356108°;47.4145652°;2.2014025°;52g;6e5;2.2e6");
 
            }
 
            // Point à convertir en Lambert II étendu (kilomètres)
 
            Location from = new Location(869.269, 2078.565, "LT2E", Units.KM);
 
            // Résultat en Lat / Lon WGS84 (degrés minutes secondes, Greenwich)
 
            Location to = new Location(0,0,"WGS84",Units.DMS,Meridians.GREENWICH);
 
            // Conversion et affichage du résultat
 
            Conv.Convert(from, to);
            from.Format(Conv);
            to.Format(Conv);
 
            Console.WriteLine("Lambert II étendu : X = {0} Y = {1}", from.sXLon, from.sYLat);
            Console.WriteLine("WGS84             : {0} {1}", to.sYLat, to.sXLon);
 
            // Conversion en UTM
 
            to.Key = "UTM.WGS84";
            to.Unit = Units.MT;
            to.Mer = Meridians.NONE;
 
            Conv.Convert(from, to);
            to.Format(Conv);
 
            Console.WriteLine("UTM / WGS84       : {0:00}{1} {2} {3}", to.Zone, to.Designator, to.sXLon, to.sYLat);
 
            Console.Read();
            }
    }
}
et la transformation en vb.net :
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.IO
Imports ConversApi
 
Public Class Form1
    Dim Conv As New Conversion()
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If File.Exists("Convers.xml") Then
            ' Configuration à partir d'un fichier xml
            Conv.ReadXml("Convers.xml")
        Else
            ' Configuration manuelle
            ' Ajout des ellipsoïdes
 
            Conv.AddEllipsoid("WGS84", "WGS 1984", 6378137, 6356752.314245, 0)
            Conv.AddEllipsoid("CLRK80IGN", "Clarke 1880 IGN", 6378249, 6356515, 0)
 
            ' Ajout des systèmes géodésiques
 
            Conv.AddDatum("WGS84", "World Geodetic System 1984", "WGS84", 0, 0, 0)
            Conv.AddDatum("NTF", "Nouvelle Triangulation Française", "CLRK80IGN", -168, -60, 320)
 
            ' Ajout des projections
 
            Conv.AddProjection("UTM.WGS84", "Universal Transverse Mercator / WGS84;UTM;WGS84;0.9996")
 
            Conv.AddProjection("LT2E", "Lambert France zone II étendue;LAMBCC2;NTF;45.5356108°;47.4145652°;2.2014025°;52g;6e5;2.2e6")
        End If
 
        ' Point à convertir en Lambert II étendu (kilomètres)
 
        Dim from As New Location(869.269, 2078.565, "LT2E", Units.KM)
 
        ' Résultat en Lat / Lon WGS84 (degrés minutes secondes, Greenwich)
 
        Dim [to] As New Location(0, 0, "WGS84", Units.DMS, Meridians.GREENWICH)
 
        ' Conversion et affichage du résultat
 
        Conv.Convert(from, [to])
        from.Format(Conv)
        [to].Format(Conv)
 
        Label1.Text = "Lambert II étendu : X = {0} Y = {1}" & from.sXLon & from.sYLat
        Label2.Text = "WGS84             : {0} {1}" & [to].sYLat & [to].sXLon
 
        ' Conversion en UTM
 
        [to].Key = "UTM.WGS84"
        [to].Unit = Units.MT
        [to].Mer = Meridians.NONE
 
        Conv.Convert(from, [to])
        [to].Format(Conv)
 
        Label3.Text = "UTM / WGS84       : {0:00}{1} {2} {3}" & [to].Zone & [to].Designator & [to].sXLon & [to].sYLat
 
    End Sub
End Class
j'ai rajouter la référence à "ConversApi.dll" mais c ne fonctionne pas l’obtient ce message au lancement :

System.InvalidOperationException was unhandled
Message="Une erreur s'est produite lors de la création du formulaire. Pour plus d'informations, consultez Exception.InnerException. L'erreur est*: Impossible de charger le fichier ou l'assembly 'ConversApi3, Version=3.0.5.0, Culture=neutral, PublicKeyToken=null' ou une de ses dépendances. Tentative de chargement d’un programme de format incorrect."
Source="WindowsApplication4"
StackTrace:
à WindowsApplication4.My.MyProject.MyForms.Create__Instance__[T](T Instance) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 190
à WindowsApplication4.My.MyProject.MyForms.get_Form1()
à WindowsApplication4.My.MyApplication.OnCreateMainForm() dans C:\Users\laurent\Documents\Visual Studio 2005\Projects\WindowsApplication4\WindowsApplication4\My Project\Application.Designer.vb:ligne 35
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
à WindowsApplication4.My.MyApplication.Main(String[] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 81
à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()