By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.