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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
the only way i know of to call a .net assembly from com or other is to
create a registry entry for the assembly

has this been explored? others may have better advice.

Doug said:
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 :-(
 
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/default.asp?url=/library/en-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.
 
Hi,

How are things going? I would appreciate it if you could post here to let
me know the status of the issue. If you have any questions or concerns,
please don't hesitate to let me know. I look forward to hearing from you,
and I am happy to be of assistance.

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.
 
Back
Top