Bonjour a tous !
Je ne parviens pas a utiliser une dll dans mon projet.
Cette dll est une dll que j'ai fait moi même, elle contient 3 fichiers (2 classes et 1 interface) :
Profiler.cs
MyScope.cs
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace Profiler { public static class Profiler { private static MyScope scoTmp; private static ArrayList tabSco = new ArrayList(); // Retrieve an IScope by its name in the current context // Param: Scope name static IScope Get(string name) { int i; int nbSco; scoTmp = null; i = 0; nbSco = tabSco.Count; while (i < nbSco) { if (((MyScope)tabSco[i]).Name == name) { scoTmp = ((MyScope)tabSco[i]); i = nbSco; } i++; } Console.WriteLine("Scope " + scoTmp.Name + " trouvé"); return scoTmp; } // Start or continue an IScope in the current context // Param: Scope name // Return: The IScope created or continued static IScope Start(string name) { scoTmp = ((MyScope)Profiler.Get(name)); if (scoTmp != null) { scoTmp.Start(); Console.WriteLine("Scope " + name + " continué ou commencé"); } else { scoTmp = new MyScope(name); tabSco.Add(scoTmp); Console.WriteLine("Scope " + name + " créé"); } return scoTmp; } // Close the IScope // Param: The scope static void Close(IScope scope) { scope.Stop(); Console.WriteLine("Scope " + ((MyScope)scope).Name + " fermé"); } // Close the scope by its name in the current context // Param: Scope name static void Close(string name) { scoTmp = ((MyScope)Profiler.Get(name)); if (scoTmp != null) scoTmp.Stop(); Console.WriteLine("Scope " + name + " fermé"); } // Close the last opened scope static void Close() { ((MyScope)tabSco[tabSco.Count - 1]).Stop(); Console.WriteLine("Dernier scope fermé"); } // Export all measures in a CSV format static void ExportCsv() { Console.WriteLine("Fichier .csv en cours d'export..."); } } }
et IScope.cs
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 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Profiler { class MyScope : IScope { private string name; public string Name { get { return this.name; } set { this.name = value; } } public MyScope() { } public MyScope(string name) { this.name = name; } public void Start() { } public void Stop() { } } }
Donc nous somme bien d'accord que ma classe Profiler possèdes des méthodes (static certes, mais méthodes tout de même).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Profiler { interface IScope { void Start(); void Stop(); } }
Ensuite, j'ai fait un projet (un simple Main(string[] args)) :
J'ai bien ajoute mon fichier Profiler.dll en référence a mon projet TestProfiler0 (Clique droit sur le nom du projet -> Ajouter une référence -> Parcourir -> Chemin vers Profiler.dll (C'est le bon dossier j'ai vérifier 5 fois avec les dates de modifications)).
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 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Profiler; namespace TestProfiler0 { class Program { static void Main(string[] args) { Profiler.Profiler.Close(); //Erreur ici => 'Profiler.Profiler' ne contient pas de définition pour 'Close' Console.WriteLine("Hello !"); Console.ReadKey(); } } }
J'ai teste de mettre juste Profiler.Close() (mais dans le namespace il n'y a pas de classe Close) et faire une instanciation de Profiler.Profiler (Je sais que en static ça marcherai encore moins mais bon... dans le désespoir ^^')
Comme vous pouvez le voir j'ai rajoute un using Profiler; mais ça ne fonctionne toujours pas.
Dans Visual Studio lorsque je fais Profiler. => Il voit juste ma classe Profiler mais de type Object sans les méthodes (Juste les méthodes classique de Object => Equals() // ReferenceEquals()). En revanche il ne détecte pas ma classe MyScope.
Comment dois-je faire pour pouvoir utiliser correctement les classes de mon Profiler.dll ?
Je suis certain que c'est un oublie tout bête, mais je ne trouve pas...
D'avance merci pour votre aide et votre lecture.
Cordialement,
Rhoblik.
PS : Je vous demande pardon pour les accents en moins, ainsi que la qualité du code qui n'est pas complet.
Partager