473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Exposing VB.NET object to COM in the old C format using Interop

I need to make the VB.NET object callable from a program called Trade Station. It is a stock analysis and trading tool that is very importiant to my company. They have a scripting languge called easy language that is built into the system. It is supposed to be capable of extending itself by calling external DLLs. It is very picky about what DLLs it will see though

Others have had success using C++ to write a DLL that will work with Easy Language, but I am hitting a brick wall with VB. I am not a strong C++ programmer, but I am very good at VB. I am hoping to find a way to make interop expose my VB DLL in the same way that the C++ DLL is exposed. Here is a snippet of code that is from a working C++ DLL. I hope it is meaningful. I am not sure :-(

-----------stdafx.h----------
// stdafx.h : include file for standard system include files
// or project specific include files that are used frequently, bu
// are changed infrequentl
/

#pragma onc

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows header
// Windows Header Files
#include <windows.h

// TODO: reference additional headers your program requires her
#define dll_entry( type ) extern"C" type __stdcal

-----------a.cpp----------
// a.cpp : Defines the entry point for the DLL application
/

#include "stdafx.h
#import "c:\Program Files\TradeStation\Program\TSKit.dll" no_namespac
#import "D:\documents\projects\TradeStationInterop\CSharp\ bin\Release\CSharp.tlb

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserve
return TRUE
double __stdcall MyTest(IEasyLanguageObject *pEL, int iNBars

CSharp::_Class1 *com_ptr
CoInitialize(NULL)
CSharp::_Class1Ptr p(__uuidof(CSharp::Class1))
com_ptr = p
double d = com_ptr->TestDouble()

return d
-----------stdafx.cpp----------
// stdafx.cpp : source file that includes just the standard include
// a.pch will be the pre-compiled heade
// stdafx.obj will contain the pre-compiled type informatio

#include "stdafx.h

-----------a.def----------
LIBRARY
EXPORT
MyTes


Jul 21 '05 #1
1 1895
Hello,

Thanks again for your post. Now I understand, you want to call a .NET
component from a scripting language which only supports calling unmanaged
DLL (with LoadLibrary, GetProcAddress calls). Now I'd like to share the
following information with you:

We are not able to expose VB .NET component to the unmanaged world like the
C++ unmanaged DLL directly. To work around the problem, you will need to
create an additional C++ unmanaged DLL which uses COM Interop to consume
.NET components and export functions to Easy Language scripting.

COM Interop Sample: COM Client and .NET Server
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcominteropsamplecomclientnetserver.asp

Please feel free to let me know if you have any problems or concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vince Zhang | last post by:
Hi, all I wanna make dso that implements OLEDBSimpleProvider interface to interact mshtml.dll. but meet problem in doing it. Could anybody help me? I do the following tasks: 1. use VS.NET IDE...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
8
by: John Brock | last post by:
I am creating an Excel workbook using VB.NET, and have run into a problem. Excel at times insists on reformatting data that I enter into cells, e.g., converting "01234" to "1234", and this screws...
1
by: Doug | last post by:
I need to make the VB.NET object callable from a program called Trade Station. It is a stock analysis and trading tool that is very importiant to my company. They have a scripting languge called...
8
by: Dave A | last post by:
I have a class called 'PrimaryKey' that represents the primary key of a table. PrimaryKeys can only be created and the class only implements .ToString(). The PrimaryKey class internally stores...
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
1
by: sahmad | last post by:
Hello All, I am writing a console based application using C# in which I want to implement a feature which could extract OLE objects from Word documents and then save it in DWG file format. The...
1
by: winston.heng | last post by:
Hi, Thanks for reading this posting. I have been cracking my head on solving the infinite loop when i call the following section code. Any help or advise is greatly appreciated =D Thanks in...
7
by: Raymond Chiu | last post by:
Dear all, I have written the following code in the button click event but find that excel session object always remain in the server as seen from taskmanager. Do you know why?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.