Posted By: adrian.h | Sep 2nd, 2008 @ 12:11 PM
page 1 of 1
Comments: 15 | Views: 633
adrian.h
adrian.h
Would rather be camping or climbing!
Hi, this should be a stupidly simple question, but for some reason, I can't find reference to it anywhere.  Must be the keywords I'm using, cuz this is a big reason for the CLR.

I want to write an assembly like a COM or ActiveX control.  It needs to have usable controls, encapsulate the internals and expose a usage and event interface.  It should be able to be dropped into a VB and a LabVIEW application.

This is so simple, I don't know why I can't find any reference to it.

Any help would be greatly appreciated.


Adrian
If I'm understanding you correctly, search for "COM Interop"
As far as I know, there's no way to use a .NET assembly outside of .NET without making a COM interface for it, but I may be wrong.
Yggdrasil
Yggdrasil
Pour me a cab, 'cause I can't drink no more.

Didn't we have this here a few days ago?
You can't create ActiveX controls with .NET, unfortunately. What you CAN do is create a .NET component, with all the controls and events and so forth that you want. If LabVIEW is a .NET host, you can plunk those controls into it just like you would a COM component in a COM host. Looking here, it seems that LabVIEW can host .NET controls. This page mentions "all .NET components registered globally", so I'm guessing it looks in the GAC.
What you need to do is this:
1) Create a Windows Forms Class Library project in Visual Studio.
2) Design the user controls you want using C#/VB.Net, whatever.
3) Sign your assembly with a strong-name key (Right click on the project -> Properties -> Signing).
4) Register your component in the GAC by copying the DLL over into C:\Windows\assembly.
5) Follow the instructions in the link above to add it to your LabVIEW project.

Yggdrasil
Yggdrasil
Pour me a cab, 'cause I can't drink no more.
Don't create a Windows Forms app. Create a Windows Forms Control Library.
Also, I think "How to write a windows forms control" is a bit of a large topic to cover here. I found a quick tutorial here which doesn't cover much, but googling for "windows forms" and "tutorial" will probably net you a couple of more examples.,
Yggdrasil
Yggdrasil
Pour me a cab, 'cause I can't drink no more.

Hmm. What version of Visual Studio are you using? I'm on VS 2008 Professional, but it might not be included in VS Express.
If so, just create a standard Class Library and add a reference to System.Windows.Forms manually, and see if it lets you add a new User Control item to the project.

Yggdrasil
Yggdrasil
Pour me a cab, 'cause I can't drink no more.
In the toolbox, right click and Choose Items. There you have tabs on top to select COM components.
PerfectPhase
PerfectPhase
"This is not war, this is pest control!" - Dalek to Cyberman
To call a .Net component from COM you need to understand the COM Callable Wrapper (CCW) http://msdn.microsoft.com/en-us/library/f07c8z1c.aspx

To call a COM object from .Net you have to go through the Runtime Callable Wrapper (RCW) http://msdn.microsoft.com/en-us/library/8bwh56xe.aspx

To call an unmanaged dll from .Net you have to use Platform Invoke (PInvoke) http://msdn.microsoft.com/en-us/library/aa288468.aspx

What do you actually want to do?
page 1 of 1
Comments: 15 | Views: 633
Microsoft Communities