cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Active X

former_member682029
Contributor
0 Kudos

Hi

Anybody created your own ActiveX control to work with SBO?

Is it possible to build an ActiveX control in C#.net / VB.net for SBO 2007?

I do not need the SDK sample of Active X Tree view. Since this example is for loading the active X in SBO form.

Can anybody help me to download a sample active x (From scratch) working in SBO?.

Thank you

Anoop

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Are you interested about programming ActiveX and using it in SBO? If yes, answer is - yes, its possible and simple.

The hint that you must create new project as class type, delete the vb default file and add there user control, over that add wrapper (interface) and thats all. Ill try to find some testing project i made in the past and if I find it, will send it to your email.

former_member682029
Contributor
0 Kudos

Yes. Petr

I would like to do atleast one project. Actually I am done with the steps what you said here.

Created a sample active x project and loaded in sbo. It worked well with all the properties and methods loaded in the active X.

But

When I try to run the same addon again, it is showing this error <b>Error HRESULT E_FAIL has been returned from a call to a COM component.</b>

Here is the last three lines of codes I used. The error is in the second line

objActX.ClassID = "ActiveX.MyControl"
oMyControl  = objActX.Object 'Here it is throwing the above error 
oMyControl.Text = "It Worked!!!" 

The three lines will work well for the first time. Again if we try to execute, it fails.

If I restart SBO, It will work for first time.

Anoop

Former Member
0 Kudos

Ill tried to find it but without succes till now, Ill check on other compuetr and send you.

For the error, what you mean with firstime? What is scenario of multiple running? Send more code from sbo you have to better understand what you do.

former_member682029
Contributor
0 Kudos

Petr.

This addon is a simple one to load an active x control in a form.. When we close the form, the addon will end.

Once this cycle is working well.

If I try to run my addon again, it is failing and showing the above error.

The same error is showing if I try to load the activeX control in two forms.

In the first form it will work. Second form, it fail and showing same error.

Anoop

Former Member
0 Kudos

when you add 2 of this components on one form, works it?

I didnt understand well your explanation - when on form close event the addon is stopped, how do you start it again? Through addon manager?

former_member682029
Contributor
0 Kudos

Petr

I am in a development stage. I am running the addon from my Code. So just start running from visual studio and stopping it.

again starting.. stopping. this is the method of my execution.

When I tried to load two components in One form at a time, the first one only worked with out error.

Same error occurred in the case of second one.

Anoop

former_member682029
Contributor
0 Kudos

please mention your email address.

I will send you both my projects.

1. Active X

2. Addon

So that you can check when you get time.

Anoop

Former Member
0 Kudos

sent you mail

Former Member
0 Kudos

Hi Petr,

Could you please post the sample? I'm also interested in that subject.

Regards

Radek

Former Member
0 Kudos

solved, sent you mail.

Former Member
0 Kudos

Hi Radek,

I didnt find the source from the past i had, ask Anoop if he will be vilig to send his code to you (I cannot do it, its his code)

Former Member
0 Kudos

Anoop,

because i didnt answer if it works on your side I checked it again after restart pc and you are true, there was a problem with channels. So i tried to investigate it and found the problem place.

Becuase in channel you hadnt set the channel name, thats the reason of falling, because you cannot have two channel with same name. So I rewrote the passwofrdholder part (added try catch statement - will get the error description and changing the channel name) as:

public PasswordHolder()
        {
           try 
           {


            InitializeComponent();
            
            
            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
           
            provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
           
            // Creating the IDictionary to set the port on the channel instance.
            IDictionary props = new Hashtable();
            
            props["port"] = 0;
            props["name"] = DateTime.UtcNow.ToString();

            // Pass the properties for the port setting and the server provider in the server chain argument. 
            //(Client remains null here.)
            TcpChannel chan = new TcpChannel(props, null, provider);
            
            ChannelServices.RegisterChannel(chan, false);
           
               }
               catch (Exception e)
           {
               MessageBox.Show(e.Message );
               }
                
        }

Check it and let me know (maybe you found it already too).

former_member682029
Contributor
0 Kudos

Petr

Let me check it.. Actually after the last post, I didn't get time to check it.. Wanted to solve some other issues.

Any way I have to finish this work in one or two days. I will let you know what I found.

Thank you for your valuable help.

Anoop

former_member682029
Contributor
0 Kudos

WONDERFUL!!!!! Petr

It really worked well on my side too. You have got 100 points...

I am really happy since I got a workable Active X.

Really great work.. Thanks alot.

Anoop

moshe
Explorer
0 Kudos

Can one of you please post the code sample that handles the channels.

I didnt get to understand it completly, and it blocks the ability to run methods and properties of the activex

Tx

Yaron

Former Member
0 Kudos

Petr,

I am interesting in your solution, too. Can you send me it, please?

former_member682029
Contributor
0 Kudos

For creating activeX COM controls please go here.

http://www.csharphelp.com/archives/archive281.html

http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx

Follow the steps listed there.

Very important part while you use this in SDK is

1. Com Registration part

2. COM Unregistration part

3. Visibility of COM

4. Registration command using Regasm

These are well explained there.

In addition to these you must enable a remote channel to communicate with server.

For this, use this code in the constructor

BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
            provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            // Creating the IDictionary to set the port on the channel instance.
            IDictionary props = new Hashtable();
            props["port"] = 0;
            props["name"] = DateTime.Now.Ticks.ToString(); //DateTime.UtcNow.ToString();
            // Pass the properties for the port setting and the server provider in the server chain argument. 
            //(Client remains null here.)
            TcpChannel chan = new TcpChannel(props, null, provider);
            ChannelServices.RegisterChannel(chan, false);

Now you can use the activex.. If any question, contact me in the mail address provided here.

Anoop

moshe
Explorer
0 Kudos

Hi Anoop,

Tx for the reply.

As I understand this code should be in the ActiveX New Method as attached, but I cannt get read of the BinaryServerFormatterSinkProvider and TcpChannel underline even though I import the namespace System.Runtime.Remoting.Channels

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

'ChannelServices.RegisterChannel(new tcpchannel

Try

Dim provider As New BinaryServerFormatterSinkProvider()

provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full

' Creating the IDictionary to set the port on the channel instance.

Dim props As IDictionary = New Hashtable()

props("port") = 0

props("name") = DateTime.Now.Ticks.ToString()

'DateTime.UtcNow.ToString();

' Pass the properties for the port setting and the server provider in the server chain argument.

'(Client remains null here.)

Dim chan As New TcpChannel(props, Nothing, provider)

ChannelServices.RegisterChannel(chan, False)

Catch ex As Exception

End Try

End Sub

moshe
Explorer
0 Kudos

OK, I figured out the problem from the eboved reply.

After adding System.Runtime.Remoting as a .NET reference instead of only imported namespace, the undelines disapeared.

Problem Solved and I can use methods in the ActiveX !

Tx

Yaron

Answers (1)

Answers (1)

Former Member
0 Kudos

Does anyone know how to implement an event interface for the activex object?

So, how to listen in the application to events generated by the activex control hosted in Sbo?