Can be transfered for VB 6 with DLL that C # makes?

honestman
honestman used Ask the Experts™
on
I make a COMM class with C#.
I want to transfer the class in VB6.
How to do?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Re-write?
Top Expert 2006

Commented:

Author

Commented:
My meaning is COM port.
Because the MSCOMM in VB6 cann't open the COM port at 230400. I must write the code in C#.
Commented:
The .Net framework doesn't provide integral support for serial communications (connecting via COM Ports).  It can however be accomplished using one of a few possible methods. Two possible methods follow:

#1) using the MSCOMM Compent -- Judging by what you wrote, isnt' the solution you needed.

http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=320

#2) Using PInvoke to access Windows API function. An example of this can be found here: http://www.dotnet247.com/247reference/msgs/16/83976.aspx

If as I suspect the first method doesn't work for you, the second method would, but by the sounds of your situation, I wouldn't reccomend it.   Instead I would reccomend writing an ATL Com component in native C++ due to the fact that you are going to use this in a visual basic application.  When use an assembly as com from VB, the PInvoke layer of the .Net framework is used and creates a bit of a performance loss.  When you use PInvoke to access unmanaged API Function calls, you get a similar loss.  In this case going from Visual Basic to C# to Win32 API, you would be passing through PInvoke twice.  If you wrote an ATL com object in unmanaged c++, you would not take this toll.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial