473,806 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help, may be easy for you , I'm getting nuts.

Hi,

I have this DLL made with VB.NET made as a Class Library project. I
know this is managed code.

I have my other made with VC++.NET, unmanaged code.

The point is that I want to use function within my DLL in the VC++ project.

I've been reading document over the internet and this
http://msdn.microsoft.com/msdnmag/is...A/default.aspx

but I can't find a tutorial explaining how to integrate and use my
VB.NET DLL in VC++. There is text that says that I should import the
DLL content but it is not clear for me.

Does any of you would have a good reference to suggest to me?

I appreciate, thank you

Marty
Nov 17 '05 #1
3 1420
You have to write a mixed-mode DLL in C++ ( I don't think you can use
any other language, but I may be wrong here). I've done this before. The
mixed-mode DLL exports a pure C interface, and the C functions are
calling into the managed interface using Managed C++ (or C++/CLI once
VC++ 2005 is out).

extern "C"
{
__declspec(dlle xport) bool __stdcall Convert([...])
// unmanaged function exported from the DLL
{
try
{
[...] just write your managed code here
return true;
}
catch(...)
{
}
return false;
}
}

You just have to solve the data marshalling, converting managed arrays
to unmanaged, and so on. It depends what you want to pass to the
function and what you want to return. For example, managed data can be
pinned and the pinned pointer passed to an unmanaged function:

MemoryStream __gc* managed_stream = new MemoryStream;
[...]
unsigned char managed_array __gc[] = managed_stream->GetBuffer();
unsigned char __pin* ptr = &managed_arr ay[0];
unmanaged_callb ack(ptr, static_cast<uns igned>(managed_ stream->Length));

You could be more specific if you have trouble with a certain detail.

Tom
Marty wrote:
Hi,

I have this DLL made with VB.NET made as a Class Library project. I
know this is managed code.

I have my other made with VC++.NET, unmanaged code.

The point is that I want to use function within my DLL in the VC++ project.

I've been reading document over the internet and this
http://msdn.microsoft.com/msdnmag/is...A/default.aspx

but I can't find a tutorial explaining how to integrate and use my
VB.NET DLL in VC++. There is text that says that I should import the
DLL content but it is not clear for me.

Does any of you would have a good reference to suggest to me?

I appreciate, thank you

Marty

Nov 17 '05 #2
Hi Tamas,

Thank you for your infromation.

It all start from there, I wanted to add a socket handler in my VC++
program, I've tried with this code that I got from the VC++ help file
(at end of email).

But I couldn't make it work, so I thaught to use the one I already made
in VB.NET, so I get to write my previous email.

What is better or easier? To integrate the code just below to my VC++
project?

Thanks for your help.

Marty

void main() {
try {
// Set the TcpListener on port 13000.
Int32 port = 13000;
IPAddress* localAddr = IPAddress::Pars e(S"127.0.0.1") ;

// TcpListener* server = new TcpListener(por t);
TcpListener* server = new TcpListener(loc alAddr, port);

// Start listening for client requests.
server->Start();

// Buffer for reading data
Byte bytes[] = new Byte[256];
String* data = 0;

// Enter the listening loop.
while (true) {
Console::Write( S"Waiting for a connection... ");

// Perform a blocking call to accept requests.
// You could also user server.AcceptSo cket() here.
TcpClient* client = server->AcceptTcpClien t();
Console::WriteL ine(S"Connected !");

data = 0;

// Get a stream Object* for reading and writing
NetworkStream* stream = client->GetStream();

Int32 i;

// Loop to receive all the data sent by the client.
while (i = stream->Read(bytes, 0, bytes->Length)) {
// Translate data bytes to a ASCII String*.
data = Text::Encoding: :ASCII->GetString(byte s, 0, i);
Console::WriteL ine(String::For mat(S"Received: {0}",
data));
// Process the data sent by the client.
data = data->ToUpper();

Byte msg[] = Text::Encoding: :ASCII->GetBytes(data) ;

// Send back a response.
stream->Write(msg, 0, msg->Length);
Console::WriteL ine(String::For mat(S"Sent: {0}", data));
}

// Shutdown and end connection
client->Close();
}
} catch (SocketExceptio n* e) {
Console::WriteL ine(S"SocketExc eption: {0}", e);
}

Console::WriteL ine(S"\nHit enter to continue...");
Console::Read() ;
}
Nov 17 '05 #3
ok, I finally find out to make it compile without erros, the first
bottleneck is passed.

Have a good day.

Marty

Marty wrote:
Hi Tamas,

Thank you for your infromation.

It all start from there, I wanted to add a socket handler in my VC++
program, I've tried with this code that I got from the VC++ help file
(at end of email).

But I couldn't make it work, so I thaught to use the one I already made
in VB.NET, so I get to write my previous email.

What is better or easier? To integrate the code just below to my VC++
project?

Thanks for your help.

Marty

void main() {
try {
// Set the TcpListener on port 13000.
Int32 port = 13000;
IPAddress* localAddr = IPAddress::Pars e(S"127.0.0.1") ;

// TcpListener* server = new TcpListener(por t);
TcpListener* server = new TcpListener(loc alAddr, port);

// Start listening for client requests.
server->Start();

// Buffer for reading data
Byte bytes[] = new Byte[256];
String* data = 0;

// Enter the listening loop.
while (true) {
Console::Write( S"Waiting for a connection... ");

// Perform a blocking call to accept requests.
// You could also user server.AcceptSo cket() here.
TcpClient* client = server->AcceptTcpClien t();
Console::WriteL ine(S"Connected !");

data = 0;

// Get a stream Object* for reading and writing
NetworkStream* stream = client->GetStream();

Int32 i;

// Loop to receive all the data sent by the client.
while (i = stream->Read(bytes, 0, bytes->Length)) {
// Translate data bytes to a ASCII String*.
data = Text::Encoding: :ASCII->GetString(byte s, 0, i);
Console::WriteL ine(String::For mat(S"Received: {0}",
data));
// Process the data sent by the client.
data = data->ToUpper();

Byte msg[] = Text::Encoding: :ASCII->GetBytes(data) ;

// Send back a response.
stream->Write(msg, 0, msg->Length);
Console::WriteL ine(String::For mat(S"Sent: {0}", data));
}

// Shutdown and end connection
client->Close();
}
} catch (SocketExceptio n* e) {
Console::WriteL ine(S"SocketExc eption: {0}", e);
}

Console::WriteL ine(S"\nHit enter to continue...");
Console::Read() ;
}

Nov 17 '05 #4

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

Similar topics

3
1076
by: cazman | last post by:
Hi all, Let's say I have this: 1 2 fruit 154 4 5 fruit 178 1 2 vegetable 456 4 5 vegetable 458 1 2 nuts 123 4 5 nuts 485
1
1129
by: Mike | last post by:
I have a web page that displays contact people in a drop down. the users selects a person then clicks the go button. The datagrid should pop with all the information on the select contact person, correct? Well, now my issue. I have 5 contact names in the drop down, (pop from DB) when I select one nothing happens except for one name. I only get information back for only one person, nothing happens if i select a different name. The grid...
2
2300
by: Lior | last post by:
Hi, I have an ASP.NET website that crashes under heavy load. I use a SQL Server DB. I get around 5500 hits per day. I keep getting the timeout expieried connection pool error. Sometimes it even throws and error about a DataReader connection being already open even though I only use Data Sets in my code. Please take a look and see if you can find my leak because I'm going nuts here and am losing hope... I keep blaming the server and the...
6
1351
by: Benjamin Walling | last post by:
We have 109 remote offices all running Sybase ASA Server. We collect data from these offices and consolidate it into our main server. I have written a program that will read from each office and synchronize the data. It takes a while to run because each office only has a 128k Frame Relay. I have two database classes: one for accessing the office, one for accessing the main server. The database classes expose simple functions of...
21
1835
by: Marina | last post by:
I've spent 2 months working on this Access 2003 db, get something done and then the 'boss' wants something different that what was originally stated, or wants to add this or that. It's been nuts, but it's finally done. Now he has decided, after telling me that this is what he didn't want at the beginning of the project, that he wants to be able to access the db online and to create one that he can have uploaded to a server and work on...
0
2188
by: Billie Boy | last post by:
Hi to all. I’m new here and am coming to you from Melbourne Australia. So a big HELLO 2 ALL. Now I am encountering an annoying problem in the SQL builder of the copy of VB.6 that I am using at home. My problem is that it’s driving me NUTS NUTS NUTS. I am connected to a data connection within my computer that accesses tables & views from a MS Access file.
8
2195
by: john | last post by:
To test a new piece of software designed to help with (among other things) eCommerce WWW site development. The software is fairly easy to use but you must fit a profile. Retail price is 120 GBP and I'll email full releases to anyone who helps FOC of course: Profile: I'm looking for someone who fits a profile - You must be willing to spend some time with the software and report back
20
4314
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site is structured as an upside-down tree, and (if I remember correctly) never more than 4 levels. The site basically grew (like the creeping black blob) ... all the pages were created in Notepad over the last
6
1611
by: tims | last post by:
Hi, I'm working on an easy assignment only I can't get it working properly. All the program needs to do is accept the user-input value and display a message that many times. What I'm having trouble with is the syntax for getting the message to display x amount of times per the user-inputted variable. I'm sure this is an easy solution but I'm going nuts trying to figure it out. Any help is greatly appreciated. Oh and I'm working in C++ 2003.
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.