473,406 Members | 2,220 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,406 software developers and data experts.

Calling C# dll from existing native application

Hi
Is there a preferable way to write a C# dll that should be called from an
existing application (running native code).

It is not possible to change this application and its source code isn't
available.

The dll performs the communication beteween the computer and a external
device (using a RS232) line.

The dll should have a few enties .
for example one looks like this
Bool Init(struct1* a, struct2* b);

From the application does the dll receive pointers to a structure
constisting of
- strings
- function pointers
- Bool, int..

The function pointers should be called from the dll (call backs), sometimes
on external events.
Some data (strings...) should be inserted by the dll into the application
structures.

What is the best way to do this?
The solution should be maintainable for the future as well.

Jan Lindh

The old school solution would to write the entire dll in normal C++.....
Jan 6 '08 #1
2 4699
Jan,

The only way to do this would be to create a native dll in C++ which
would make the appropriate calls to managed code. C# cannot export
functions from assemblies.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jan Lindh" <Jan Li***@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
Hi
Is there a preferable way to write a C# dll that should be called from an
existing application (running native code).

It is not possible to change this application and its source code isn't
available.

The dll performs the communication beteween the computer and a external
device (using a RS232) line.

The dll should have a few enties .
for example one looks like this
Bool Init(struct1* a, struct2* b);

From the application does the dll receive pointers to a structure
constisting of
- strings
- function pointers
- Bool, int..

The function pointers should be called from the dll (call backs),
sometimes
on external events.
Some data (strings...) should be inserted by the dll into the application
structures.

What is the best way to do this?
The solution should be maintainable for the future as well.

Jan Lindh

The old school solution would to write the entire dll in normal C++.....

Jan 7 '08 #2
Create a ActiveX Facade.
Jan,

The only way to do this would be to create a native dll in C++
which would make the appropriate calls to managed code. C# cannot
export functions from assemblies.

"Jan Lindh" <Jan Li***@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
>Hi
Is there a preferable way to write a C# dll that should be called
from an
existing application (running native code).
It is not possible to change this application and its source code
isn't available.

The dll performs the communication beteween the computer and a
external device (using a RS232) line.

The dll should have a few enties .
for example one looks like this
Bool Init(struct1* a, struct2* b);
From the application does the dll receive pointers to a structure
constisting of
- strings
- function pointers
- Bool, int..
The function pointers should be called from the dll (call backs),
sometimes
on external events.
Some data (strings...) should be inserted by the dll into the
application
structures.
What is the best way to do this?
The solution should be maintainable for the future as well.
Jan Lindh

The old school solution would to write the entire dll in normal
C++.....

Jan 8 '08 #3

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

Similar topics

0
by: Stephan | last post by:
Hello to all, I'm looking into providing mobile access to a web based administrative application currently running on .Net with MS SQL. The current architecture only supports the latest Internet...
18
by: Simula | last post by:
I am developing an HTML javascript application and I want to preserve state in a way that can be book-marked. I chose HTML anchors as a means of preserving state. When the application changes...
14
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
2
by: Pawan Aggarwal | last post by:
I'm having trouble with calling an exported function in a native DLL compiled with eMbedded Visual C++ in C# application in PocketPC 2002 OS. Problem Description follows: I have one exported...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: Bern McCarty | last post by:
What do you make of this? I cannot tell for sure but it almost seems as the the transition thunk to get back from the native bool method to the managed caller is looking at eax and, if any bit is...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
2
by: RalphTheExpert | last post by:
This thread is a continuation of a thread with the Subject "Unhandled exception - Different under debugger and non-debugger". (http://www.dotnetnewsgroups.com/newsgroupthread.asp?ID=186902) ...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.