Kategorie szkoleń | Egzaminy | Kontakt
  • 1
  • 1
  • 47

Proszę o pomoc z COM, posiadam kod z obiektem KOM:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Windows.Forms;
 
 
 
namespace KontrolkaCOM
{
 
    [ComVisible(true), Guid("8D190EA5-7EF2-4DDF-9AEA-660D9D30B30D"), TypeConverter(typeof(ExpandableObjectConverter)), InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface IKontrolkaCOM
    {
        public GigitalGUS.DigitalGusClient servis;
 
         string Nazwa1 { get; set; }
         string Nazwa2 { get; set; }
         string Nazwa3 { get; set; }
 
         void TestowyMessage(string komunikat);
         int Oblicz(int a, int b);
 
         void Okno();
 
 
 
    }
 
 
    [ComVisible(true), Guid("5B5B05B0-BFAB-47D6-90A7-A2596026C0C4")]//,
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("KontrolkaCOM.Proc")]
    public class KontrolkaCOM : IKontrolkaCOM
    {
 
 
       // public GigitalGUS.DigitalGusClient servis = new GigitalGUS.DigitalGusClient();
 
        public string Nazwa1
        {
            get;
            set;
        }
 
        public string Nazwa2
        {
            get;
            set;
        }
 
        public string Nazwa3
        {
            get; set;
        }
 
        public void TestowyMessage(string komunikat)
        {
           MessageBox.Show(komunikat);
        }
 
        public int Oblicz(int a, int b)
        {
            return a * b;
 
        }
 
        public void Okno()
        {
 
            try
            {
                MessageBox.Show("dziala");
 
            }
            catch(Exception)
            {
                MessageBox.Show("bład");
            }
 
 
 
            Okno dial = new Okno();
 
            dial.ShowDialog();
        }
 
    }
}
 
 
/*
 
Dispatch x
    x.Create("KontrolkaCOM.Proc")
    x.Set("Nazwa1", "ala ma kota")
 
    message(x.Get("Nazwa1"))
    x.TestowyMessage("komunikat")
    int wynik = x.Oblicz(2,7)
    message kwota(wynik)
    error""
*/


za komentowana część na końcu, jest to sposób na uruchomienie w programie Symfonia.
Mój problem polega na tym że jak dodam do projektu referencję do web serwisu to kompilator informuje mnie że:

"Error    2    The type name 'GigitalGUS' does not exist in the type 'KontrolkaCOM.KontrolkaCOM'    D:\C#\!!GusServis\ClassLibrary1\ClassLibrary1\Service References\GigitalGUS\Reference.cs    32    56    KontrolkaCOM:



z tym błędem robiłem w ten sposób że w referencjach zamiast:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface IDigitalGusChannel : KontrolkaCOM.GigitalGUS.IDigitalGus, System.ServiceModel.IClientChannel {
 


dawałem:

 

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface IDigitalGusChannel : GigitalGUS.IDigitalGus, System.ServiceModel.IClientChannel {



Ale nie mogę zrobić nowej instancji ponieważ po dodaniu jej - za komentowana linia:

public GigitalGUS.DigitalGusClient servis = new GigitalGUS.DigitalGusClient();



i skompilowaniu niestety ale z poziomu Symfonii dostaje błąd z informacją że nie można utworzyć obiektu kom.

Próbowałem stworzyć dll z instancją serwisu i metodami, ale również to nie działa.

Bardzo proszę o pomoc w rozwiązaniu problemu.

Paweł_Jaroszek
  • Zapytał
  • @ Paweł_Jaroszek | 22.12.2015
    • 4
    • 0
    • 0
Zaloguj się aby zadać pytanie
Pokrewne

Odpowiedź (1)

  • 0
Paweł_Jaroszek
  • Odpowiedział
  • @ Paweł_Jaroszek | 29.12.2015
    • 4
    • 0
    • 0