 |
|
 |
Also in this solution there is no use of custom properties. Custom properties doesn't work....
|
|
|
|
 |
|
 |
Hi all! This message is very old but topic is still very accurate...I've been looking around for several hours trying to expose C# custom events and properties to my VB6 app and I finally got it to work so I thought it is worth sharing so hopefully it'll save you time.
Example to add a RecordSaved event:
Perform the following steps within your c# usercontrol class,
---------------------------
Step 1 - Create your event
---------------------------
<pre lang="cs">[InteropFormEvent()]
public event RecordSavedEventHandler RecordSaved;
public delegate void RecordSavedEventHandler(object sender, System.EventArgs e);</pre>
Step 2 - Assuming you have a button on your usercontrol UI, put this in the Click event:
-----------------------------------------------------------------------------------------
<pre lang="cs">private void Button1_Click(object sender, EventArgs e)
{
if (null != this.RecordSaved)
this.RecordSaved(sender, e));
}</pre>
Step 3 - Make your event visible to COM
---------------------------------------
Add this :
<pre lang="cs">[DispId(3)]
void RecordSaved(object sender, System.EventArgs e)</pre>
to this block:
<pre lang="cs">public interface __usercontrolnamehere
{
[DispId(1)]
void Click();
[DispId(2)]
void DblClick();
//add additional events visible in VB6
}</pre>
That's it!
MORE
-----
To expose custom properties, you create your property as you normally would and then add a reference to it under this line (7 being the next logical number based on previous DispId values in the same block):
<pre lang="cs">//add additional properties visible in VB6</pre>
<pre lang="cs">[DispId(7)]
int myPropertyName { [DispId(7)] get; [DispId(7)] set; }</pre>
And voilà! Have fun! :)
|
|
|
|
 |
|
 |
I copied the 'InteropfromAddin.Addin' from binary, at "My Documents\Visual Studio 2005\Addins". When i restart the VS2005 designer it gives me following error - "The Addin in 'InteropForm Wrapper c# Class generator' failed to load or caused an exception. Would you like to remove this Add-in ?".
Amit
|
|
|
|
 |
|
 |
I am getting same error, did you ever get this fixed or find out why?
|
|
|
|
 |
|
 |
just in case someone else has the same problem. There is a .dll included in the project. I moved that .dll to the same folder as the addin. That fixed the error
|
|
|
|
 |
|
 |
Using VS 2008 and still get error. Anyone else see this in 2008 using Interop 2.0 toolkit.
|
|
|
|
 |
|
 |
Do you plan to make updates to this project for the 2.0 version of Interop Forms Toolkit?
Thanks for your time,
Brian Hughes
|
|
|
|
 |
|
 |
Same question here, particularly since 2.0 supports interop controls, not just forms.
|
|
|
|
 |
|
 |
Never mind, just discovered this: http://www.codeproject.com/useritems/VB6InteropToolkit2.asp Works great for controls.
|
|
|
|
 |
|
 |
hi leon
i have the addin that u have provided . i can see the 'smily face' in tool 'generate interopform wrapper classes'
project is reffreed in vb but i cant able to see the
form on with events.
pls help
|
|
|
|
 |
|
 |
Thanks a lot (i mean it) but:
TAB key doesn't work when C# form is used from VB6
I missed something?
Ganar o perder es cosa de dioses, a los hombres solo nos queda luchar...
|
|
|
|
 |
|
 |
Has anybody found a solution for the Tab Key???
|
|
|
|
 |
|
 |
Great work, but, although I can add more than one form to the project using the interopform toolkit, the client only ever sees the first form that was created.
There seems to be a problem with creating more than one c# coclass in a classlibrary. Even though you can create them the client only ever sees one.
This isn't a problem with vb.net.
Do you know if there is a work around to this problem.
many thanks,
Mark Edwards
|
|
|
|
 |
|
 |
Does anyone have any experience calling the .NET interopForm from Visual Studio 6 C++? If so, what is needed to get it to work from there?
|
|
|
|
 |
|
 |
As a company we would like to move all of our code to C#, but we share development with a third party who wants to stay at VB6. We currently supply them with a number of VB6 OCX controls which they embed in their applications. We would like to build C# controls but wrap them in a way such that they can continue to use them as OCXs.
I have experimented with the toolkit and been able to popup C# forms from within VB6 but this model and UI experience would be an unacceptable change to the users. I have searched around and come up with the following but none are great.
1. Create Web control inside an ASP.NET page and display it using the internet browser control in VB6.
2. Popup a frameless C# form and attempt to position and move it inline with the parent, yak!!
3. Create UI for the OCX in VB6 but delegate all functionality to a .NET library wrapped so the OCX can call it.
Any other ideas ?
Tanglesoft
|
|
|
|
 |
|
 |
There is old program and there is need to do new forms in c#!
How to open c# -form in MDIChild in VB6 ?
VB6 form is MDIParent!
-- modified at 3:26 Friday 8th December, 2006
|
|
|
|
 |
|
 |
Hey Leon,
Sounds great, but I'm not sure of what from the InteropFormCSBinaries.zip file gets moved to where. Could you be a bit more concise for a newbie.
Thanks a bunch
Skater
|
|
|
|
 |
|
 |
Hi Skater,
There are two template zip files in InteropFormCSBinaries.zip
I suggest you to put at "VB6 Interop Library C#.zip" into [C:]\Documents and Settings\[User Name]\My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual C#\Windows (Make sure to replace [C:] and [User Name] with actual drive and folder names). The other one ("C# Interop Form.zip") should go into ...\My Documents\Visual Studio 2005\Templates\ItemTemplates. AddIn (files InteropFormAddIn.AddIn and InteropFormAddIn.dll) should go into \My Documents\Visual Studio 2005\AddIns directory.
Hope it helps, if not, let me know.
Regards,
Leon
------------------------
Langleyben Leon
Software Architect
MCSD
SRL Group ltd
leon@srl.co.il
972-54-4860715
972-3-7662020
|
|
|
|
 |
|
 |
Hi Leon,
Thanks for your excellent post.
You created VB6 Interop form Library C#. I would like VB6 interop user control Library C#. Do you have it already?
Actually I would like to user C# user control in VB5 project.
Your any help would highly be appreciated.
I can be reached by Frank2u2u@yahoo.ca
Thank you very much.
Frank
|
|
|
|
 |
|
 |
I created a c# interop form with some buttons, labels and texboxes. I compile the solution and everything compiles. Then I create a new vb6 project referencing Microsoft Interop Library and my newly created C# interop Dll.
VB 6 code:
Private Sub Command1_Click()
Dim t As SalesUtility.Interop_frmSalesUtility
Set t = New SalesUtility.Interop_frmSalesUtility
t.Show
End Sub
I get a form to display but it is not the form with my buttons, labels and textbox.
Any help is appricaited.
|
|
|
|
 |
|
 |
Hi,
There was a problem with form initialization. InitializeComponent() was not called from C# form constructor. It is fixed now. You can download and use updated templates. To fix existing projects, add InitializeComponent() call to original C# form constructor. In your example add
public Interop_frmSalesUtility()
{
InitializeComponent();
}
to Interop_frmSalesUtility.cs
Thanks for noting this.
Your help is appreciated.
------------------------
Langleyben Leon
Software Architect
MCSD
SRL Group ltd
leon@srl.co.il
972-54-4860715
972-3-7662020
|
|
|
|
 |
|
 |
Hey Leon, nice work so far. Problem is I am reproducing the sample in the how-tos from the documentation, but when trying to use the Add-in, it just keeps generating the wrapper class in VB, even though my project was created from scratch as a VB6 Interop Form Library C#, using the template.
Can you point me where to go from here?
Mario Vasquez
|
|
|
|
 |
|
 |
Thanks Mario,
Please check that you are using my Add-In and not original one (from toolkit). You can recognized by siley icon in Tools menu (original one has no icon). I sugest you to rename InteropFormProxyGenerator.AddIn into InteropFormProxyGenerator.AddIn_ in ...\My Documents\Visual Studio 2005\Addins folder to be sure. Check that Add-In is loaded (in Add-In manager). If it fails to load for some reason (you can not see it in Tools menu), try to clear it by rynning
devenv /ResetAddin Microsoft.InteropFormTools.InteropFormProxyGenerator.Connect /ResetAddin InteropFormAddIn.Connect
command from Visual Studio Command Prompt.
Thanks again for your comment, please let me know how it goes
------------------------
Langleyben Leon
Software Architect
MCSD
Software Resources (S.A.B.) ltd
leon@srl.co.il
972-54-4860715
972-3-7662020
|
|
|
|
 |
|
 |
Thanks, for replying.
I was switching on and off the add-in distributed from Microsoft, and I thought the same (maybe the original add-in was kicking in), but it is not the case, I was using yours (smiley), because when I clicked on the old one, it didn't even create the files (an error shows "cannot create wrapper clases", or some like that).
Now, I did the renaming on the old addin, and reset the devenv as suggested, now the only addin appearing in the tools menu is yours, and when clicked, again creates the folder and the file... in VB.NET, therefore, it won't compile.
Double checking.... I downloaded the binaries, and the codeproject package contained the following files:
- C# Interop Form.zip
- VB6 Interop Form Library C#.zip
- InteropFormAddIn.AddIn
- InteropFormAddIn.dll
Are we complete? Is something missing?
The latter two were put in the ...\My Documents\Visual Studio 2005\Addins
Thanks again.
Mario Vasquez
|
|
|
|
 |
|
 |
Hi Mario,
I have just uploaded small bug fix that can solve possible language selection problem. Please try to download new version.
------------------------
Langleyben Leon
Software Architect
MCSD
SRL Group ltd
leon@srl.co.il
972-54-4860715
972-3-7662020
|
|
|
|
 |