ActiveX with C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Raed Sawalha

    ActiveX with C#

    I created ActiveX as following:


    namespace BmpActiveXNET
    {
    public interface DesktopScreen
    {
    string getDesktopScree n();
    }
    [ClassInterface( ClassInterfaceT ype.AutoDual)]
    public class BmpActiveX:Desk topScreen
    {
    public string getDesktopScree n()
    {
    //Capture the client screen
    Bitmap bmp = BmpActiveXNET.C aptureScreen.Ge tDesktopImage() ;
    //Get the Image Bytes
    byte []BitmapBytes = GetBitmapBytes( bmp);
    //Return Bytes as String
    return GetBytesAsStrin g(BitmapBytes);
    }
    }
    }

    and register it using
    regasm BmpActiveXNET.d ll /tlb:CompNet.dll /codebase

    when try to create object from javascript
    var o = new ActiveXObject(" BmpActiveXNET.B mpActiveX");

    error generated (automation server can't create object )
    why this happened? whats wrong with what I did?
  • Dmytro Lapshyn [MVP]

    #2
    Re: ActiveX with C#

    Hi Raed,

    The ProgID of the ActiveX might not correspond to the
    "namespace_name .class_name" scheme.
    Check out the exported type library for the real ProgID of the registered
    ActiveX object.

    --
    Sincerely,
    Dmytro Lapshyn [Visual Developer - Visual C# MVP]


    "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
    news:D832A706-9A42-4CB9-BF10-3CB8D6EF7DB4@mi crosoft.com...[color=blue]
    >I created ActiveX as following:
    >
    >
    > namespace BmpActiveXNET
    > {
    > public interface DesktopScreen
    > {
    > string getDesktopScree n();
    > }
    > [ClassInterface( ClassInterfaceT ype.AutoDual)]
    > public class BmpActiveX:Desk topScreen
    > {
    > public string getDesktopScree n()
    > {
    > //Capture the client screen
    > Bitmap bmp = BmpActiveXNET.C aptureScreen.Ge tDesktopImage() ;
    > //Get the Image Bytes
    > byte []BitmapBytes = GetBitmapBytes( bmp);
    > //Return Bytes as String
    > return GetBytesAsStrin g(BitmapBytes);
    > }
    > }
    > }
    >
    > and register it using
    > regasm BmpActiveXNET.d ll /tlb:CompNet.dll /codebase
    >
    > when try to create object from javascript
    > var o = new ActiveXObject(" BmpActiveXNET.B mpActiveX");
    >
    > error generated (automation server can't create object )
    > why this happened? whats wrong with what I did?[/color]

    Comment

    • Raed Sawalha

      #3
      Re: ActiveX with C#

      May you provide me with more info for how to do this?

      i tried to use it in VB6 like following
      Private Sub Form_Load()
      Dim a As New BmpActiveX
      a.getDesktopScr een
      End Sub

      but error said
      RunTime Error -2147024894(8007 0002), or one of its dependencies was not found

      "Dmytro Lapshyn [MVP]" wrote:
      File Or Assembly name BmpActiveXNET[color=blue]
      > Hi Raed,
      >
      > The ProgID of the ActiveX might not correspond to the
      > "namespace_name .class_name" scheme.
      > Check out the exported type library for the real ProgID of the registered
      > ActiveX object.
      >
      > --
      > Sincerely,
      > Dmytro Lapshyn [Visual Developer - Visual C# MVP]
      >
      >
      > "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
      > news:D832A706-9A42-4CB9-BF10-3CB8D6EF7DB4@mi crosoft.com...[color=green]
      > >I created ActiveX as following:
      > >
      > >
      > > namespace BmpActiveXNET
      > > {
      > > public interface DesktopScreen
      > > {
      > > string getDesktopScree n();
      > > }
      > > [ClassInterface( ClassInterfaceT ype.AutoDual)]
      > > public class BmpActiveX:Desk topScreen
      > > {
      > > public string getDesktopScree n()
      > > {
      > > //Capture the client screen
      > > Bitmap bmp = BmpActiveXNET.C aptureScreen.Ge tDesktopImage() ;
      > > //Get the Image Bytes
      > > byte []BitmapBytes = GetBitmapBytes( bmp);
      > > //Return Bytes as String
      > > return GetBytesAsStrin g(BitmapBytes);
      > > }
      > > }
      > > }
      > >
      > > and register it using
      > > regasm BmpActiveXNET.d ll /tlb:CompNet.dll /codebase
      > >
      > > when try to create object from javascript
      > > var o = new ActiveXObject(" BmpActiveXNET.B mpActiveX");
      > >
      > > error generated (automation server can't create object )
      > > why this happened? whats wrong with what I did?[/color]
      >
      >[/color]

      Comment

      • Willy Denoyette [MVP]

        #4
        Re: ActiveX with C#


        "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
        news:D832A706-9A42-4CB9-BF10-3CB8D6EF7DB4@mi crosoft.com...[color=blue]
        >I created ActiveX as following:
        >
        >
        > namespace BmpActiveXNET
        > {
        > public interface DesktopScreen
        > {
        > string getDesktopScree n();
        > }
        > [ClassInterface( ClassInterfaceT ype.AutoDual)]
        > public class BmpActiveX:Desk topScreen
        > {
        > public string getDesktopScree n()
        > {
        > //Capture the client screen
        > Bitmap bmp = BmpActiveXNET.C aptureScreen.Ge tDesktopImage() ;
        > //Get the Image Bytes
        > byte []BitmapBytes = GetBitmapBytes( bmp);
        > //Return Bytes as String
        > return GetBytesAsStrin g(BitmapBytes);
        > }
        > }
        > }
        >
        > and register it using
        > regasm BmpActiveXNET.d ll /tlb:CompNet.dll /codebase
        >
        > when try to create object from javascript
        > var o = new ActiveXObject(" BmpActiveXNET.B mpActiveX");
        >
        > error generated (automation server can't create object )
        > why this happened? whats wrong with what I did?[/color]

        Where are these :
        GetDesktopImage , GetBitmapBytes, GetBytesAsStrin g ...methods stored? Same or
        another assembly?

        Willy.


        Comment

        • Raed Sawalha

          #5
          Re: ActiveX with C#

          GetDesktopImage is in other assembly(Captur eScreen.dll) and all others in
          same assembly

          "Willy Denoyette [MVP]" wrote:
          [color=blue]
          >
          > "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
          > news:D832A706-9A42-4CB9-BF10-3CB8D6EF7DB4@mi crosoft.com...[color=green]
          > >I created ActiveX as following:
          > >
          > >
          > > namespace BmpActiveXNET
          > > {
          > > public interface DesktopScreen
          > > {
          > > string getDesktopScree n();
          > > }
          > > [ClassInterface( ClassInterfaceT ype.AutoDual)]
          > > public class BmpActiveX:Desk topScreen
          > > {
          > > public string getDesktopScree n()
          > > {
          > > //Capture the client screen
          > > Bitmap bmp = BmpActiveXNET.C aptureScreen.Ge tDesktopImage() ;
          > > //Get the Image Bytes
          > > byte []BitmapBytes = GetBitmapBytes( bmp);
          > > //Return Bytes as String
          > > return GetBytesAsStrin g(BitmapBytes);
          > > }
          > > }
          > > }
          > >
          > > and register it using
          > > regasm BmpActiveXNET.d ll /tlb:CompNet.dll /codebase
          > >
          > > when try to create object from javascript
          > > var o = new ActiveXObject(" BmpActiveXNET.B mpActiveX");
          > >
          > > error generated (automation server can't create object )
          > > why this happened? whats wrong with what I did?[/color]
          >
          > Where are these :
          > GetDesktopImage , GetBitmapBytes, GetBytesAsStrin g ...methods stored? Same or
          > another assembly?
          >
          > Willy.
          >
          >
          >[/color]

          Comment

          • Willy Denoyette [MVP]

            #6
            Re: ActiveX with C#

            And this assembly is in the same directory as the client script?

            Willy.

            "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
            news:27E1AE03-68F8-452C-A962-99A059461213@mi crosoft.com...[color=blue]
            > GetDesktopImage is in other assembly(Captur eScreen.dll) and all others in
            > same assembly
            >
            > "Willy Denoyette [MVP]" wrote:
            >[color=green]
            >>
            >> "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
            >> news:D832A706-9A42-4CB9-BF10-3CB8D6EF7DB4@mi crosoft.com...[color=darkred]
            >> >I created ActiveX as following:
            >> >
            >> >
            >> > namespace BmpActiveXNET
            >> > {
            >> > public interface DesktopScreen
            >> > {
            >> > string getDesktopScree n();
            >> > }
            >> > [ClassInterface( ClassInterfaceT ype.AutoDual)]
            >> > public class BmpActiveX:Desk topScreen
            >> > {
            >> > public string getDesktopScree n()
            >> > {
            >> > //Capture the client screen
            >> > Bitmap bmp = BmpActiveXNET.C aptureScreen.Ge tDesktopImage() ;
            >> > //Get the Image Bytes
            >> > byte []BitmapBytes = GetBitmapBytes( bmp);
            >> > //Return Bytes as String
            >> > return GetBytesAsStrin g(BitmapBytes);
            >> > }
            >> > }
            >> > }
            >> >
            >> > and register it using
            >> > regasm BmpActiveXNET.d ll /tlb:CompNet.dll /codebase
            >> >
            >> > when try to create object from javascript
            >> > var o = new ActiveXObject(" BmpActiveXNET.B mpActiveX");
            >> >
            >> > error generated (automation server can't create object )
            >> > why this happened? whats wrong with what I did?[/color]
            >>
            >> Where are these :
            >> GetDesktopImage , GetBitmapBytes, GetBytesAsStrin g ...methods stored? Same
            >> or
            >> another assembly?
            >>
            >> Willy.
            >>
            >>
            >>[/color][/color]


            Comment

            • Raed Sawalha

              #7
              Re: ActiveX with C#

              no the ClientScript in folder and the assembly in other folder
              Thanks for replies , I did the following steps which solved my problem:
              1. Generate a key (sn -k mykey.key)
              2. then link the key path in the assembly
              3. register the assembly with GAC ( gacutil -i assemblypath)
              4. register the assembly in registery using (regasm assemname
              /tlb:assembname/codebase


              then try the clientscript and it is done

              "Willy Denoyette [MVP]" wrote:
              [color=blue]
              > And this assembly is in the same directory as the client script?
              >
              > Willy.
              >
              > "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
              > news:27E1AE03-68F8-452C-A962-99A059461213@mi crosoft.com...[color=green]
              > > GetDesktopImage is in other assembly(Captur eScreen.dll) and all others in
              > > same assembly
              > >
              > > "Willy Denoyette [MVP]" wrote:
              > >[color=darkred]
              > >>
              > >> "Raed Sawalha" <RaedSawalha@di scussions.micro soft.com> wrote in message
              > >> news:D832A706-9A42-4CB9-BF10-3CB8D6EF7DB4@mi crosoft.com...
              > >> >I created ActiveX as following:
              > >> >
              > >> >
              > >> > namespace BmpActiveXNET
              > >> > {
              > >> > public interface DesktopScreen
              > >> > {
              > >> > string getDesktopScree n();
              > >> > }
              > >> > [ClassInterface( ClassInterfaceT ype.AutoDual)]
              > >> > public class BmpActiveX:Desk topScreen
              > >> > {
              > >> > public string getDesktopScree n()
              > >> > {
              > >> > //Capture the client screen
              > >> > Bitmap bmp = BmpActiveXNET.C aptureScreen.Ge tDesktopImage() ;
              > >> > //Get the Image Bytes
              > >> > byte []BitmapBytes = GetBitmapBytes( bmp);
              > >> > //Return Bytes as String
              > >> > return GetBytesAsStrin g(BitmapBytes);
              > >> > }
              > >> > }
              > >> > }
              > >> >
              > >> > and register it using
              > >> > regasm BmpActiveXNET.d ll /tlb:CompNet.dll /codebase
              > >> >
              > >> > when try to create object from javascript
              > >> > var o = new ActiveXObject(" BmpActiveXNET.B mpActiveX");
              > >> >
              > >> > error generated (automation server can't create object )
              > >> > why this happened? whats wrong with what I did?
              > >>
              > >> Where are these :
              > >> GetDesktopImage , GetBitmapBytes, GetBytesAsStrin g ...methods stored? Same
              > >> or
              > >> another assembly?
              > >>
              > >> Willy.
              > >>
              > >>
              > >>[/color][/color]
              >
              >
              >[/color]

              Comment

              Working...