on 08-21-2009 10:24 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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).
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
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
102 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.