AddIn with VB.net

 

Hallo,

I have written a view functions for SolidEdge in VB.net.

Now I want to create Addins to run this functions from SE, but I don´t no how to do it.

I have a sampleAddin  in VB 6.0, but it does not  work with VB.net 2005 .

Has anybody a SampleProject in VB.net to create Addins?

(Please excuse my bad english)

Nitram

 

Posted by: Martin Rendler
Post date: 8/29/2007 5:56:42 AM

7 REPLIES

RE: AddIn with VB.net

Hi Nitram and welcome to the forums.

 

It is certainly possible to write an addin with .NET, but it is a non-trivial task. My opinion on pure .NET addins is that they are unreliable. I can get them to work correctly for the most part but not without a lot of effort. I've developed what's called a C++ COM Shim for Solid Edge that works very reliably. In it's simplest form, you have 2 .dll's. A C++ .dll which is the actual Solid Edge Addin, and a .NET .dll which is consumed by the C++ .dll.

 

I do not have any templates available for the Shim approach but I can build one and send it to you. Don't let the C++ part scare you. The way I've written it, you will not really have to deal with the C++ side of things. It's there and just works. If you'll let me know what you want your addin named, I'll build one up for you.

 

Posted by: Jason Newell
Post date: 8/30/2007 12:15:26 PM

RE: AddIn with VB.net

 

Hi Nitram,

 

I can back up Jasons opinion that .Net addins are no longer stable, I have also started using c++ for my add-ins.

However, I couldn't live with out some of those really handy .Net classes and so I started using C++/CLI (.Net 2.0 C++). I have posted an example addin here. This uses global methods to call some c++/cli methods (the example just shows a .net form).

I have recently done a project that uses a similar approach but references a C# class library that I wrote - the addin calls a global method in the interop cpp file (TestForm.cpp in the example) and this in turn calls the method in the c# dll.

I personally find this the easiest approach, although I really dislike global methods (I couldn't get the project to compile when using a mixture of managed and non-managed classes).

 

Anyway, same offer as Jasons - if you want to go this way and need some more examples/help, just let me know.

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 8/30/2007 11:37:25 PM

RE: AddIn with VB.net

 

Hi,

thank´s a lot for the examples. I only want to place place Buttons with my own Icons in an Environiment (for example Part) to start either an Program (.exe) or a "Sub" i have written in vb.net.

I´m not firm in C++ and so I have  some Problems with the Example. It would be helpfull to get a reduced Example in an Environiment which sets  only one Button starting an extern Program.

Nitram

 

Posted by: Martin Rendler
Post date: 9/3/2007 10:33:23 PM

RE: AddIn with VB.net

Hi Nitram,

 

I'm pretty tied up at the moment but I should be able to get a scaled down version with what you want posted by the weekend.

 

Cheers

Calum

 

 

Posted by: Calum McLellan
Post date: 9/5/2007 8:44:59 AM

RE: AddIn with VB.net

 

Hi Nitram,

 

I updated the link above. There was not too much I could remove but I did my best. The parts that you need to look at are AddIn.cpp and interop.cpp. The definitions for the methods in interop.cpp are in stdafx.h.

In AddIn.cpp I call the interop methods in the OnCommand method. This handles the clicks on the add-ins buttons.

I have one method that just calls Process.Start to start C:\Test.exe and another that passes a string, opens a form with the string in the title and returns a string with the forms size.

The second method demonstates how to pass strings accross the managed/unmanaged boundary.

If you want to call a method in your vb.net dll then you need to go into the common properties section of the project properties and add a reference to the dll. You can then call the methods in the dll as I have called the Form.ShowDialog method.

C++ uses a double colon ( :: ) to seperate namespaces, a -> to dereference a pointer (a managed pointer is denoted by the ^ symbol, e.g. Form^ form = gcnew Form()Smiley Wink

and a . for calling a method or accessing a property on a value type (Structure), this can be seen in the call to Size.ToString().

The equivilent to the VB Imports statement is the following:

using namespace MyNamespace::MyOtherNamespace;

 

If you use this addin as a template you will need to change the Guids for the coclasses and the dll, as well as the program id etc. this is all in CLIAddIn.cpp, CLIAddIn.idl and CLIAddIn.rgs.

You will also need to change the strings for the commands in CLIAddIn.rc as Solid Edge only allows unique command ids (the first part of IDS_COMMAND_1 and IDS_COMMAND_2).

 

Hope this helps,

let me know if you have any trouble.

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 9/7/2007 10:57:16 AM

RE: AddIn with VB.net

Hi Jason,

 

I'm tring to create an addin with VB.NET 2005 too. My problem now in the register.bat. When I create the MSI file, the REGISTER.BAT file in not a valid file to run after the install process. I want create a REGISTER.EXE with VB.NET can you help me?

 

Best regards

Delki Trolese

(Sorry for my english)

 

Posted by: Delki Trolese
Post date: 9/11/2007 2:22:05 AM

RE: AddIn with VB.net

Hi Delki,

 

you could use an Installer class. Create a new dll and add an Installer to the project (Add -> new Item). Override the OnInstall method and call Process.Start() on the .bat file. You can then add the installer to the custom actions of your msi project (you could even pass the path to the .bat file in the CustomActionData - use [TARGETDIR] for the path to the installation folder).

 

You should probably also override OnRollBack and OnUninstall to call Unregister.bat.

 

This is all just off the top of my head so the names may not be 100% correct, but you should be able to find loads of examples for installer classes in google.

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 9/12/2007 9:24:43 AM