473,656 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DllImport question

Hi,

I was trying to link a UI I made in C# to the backend which is coded
as a DLL in VC++.

I used the DllImport attribute to invoke the dll functions. Is there
any similar mechanisms by which I can invoke member functions of
classes defined in the dll?

Is there any way I could instantiate an object of a class defined in
the dll?

I am new to C#/dll's et al so I am not too sure if these questions
make sense. But if anyone can provide some info on this and more
importantly provide pointers to articles/examples on these topics it
would be a tremendous help.

Thanks.
Nov 16 '05 #1
1 1192
Only if you expose the classes as managed objects. In VC++ 7.x you can do
this, but beyond simple calling of exports in DLLs C# will not talk to
anything that is not a managed library. That means you'd have to put a
wrapper around your C++ classes.

It's the same approach as COM, basically. VB6 could not talk to C++ classes
unless they were exposed somehow through COM.

--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Rookie" <do***********@ rediffmail.com> wrote in message
news:cf******** *************** ***@posting.goo gle.com...
Hi,

I was trying to link a UI I made in C# to the backend which is coded
as a DLL in VC++.

I used the DllImport attribute to invoke the dll functions. Is there
any similar mechanisms by which I can invoke member functions of
classes defined in the dll?

Is there any way I could instantiate an object of a class defined in
the dll?

I am new to C#/dll's et al so I am not too sure if these questions
make sense. But if anyone can provide some info on this and more
importantly provide pointers to articles/examples on these topics it
would be a tremendous help.

Thanks.

Nov 16 '05 #2

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

Similar topics

1
2079
by: Surendra Singhi | last post by:
Hello, When I create a dll project using Dev-C++ it creates a function like the one below: DLLIMPORT void HelloWorld () { MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION); } From my understanding off dllimport, it should be used for externally created functions. Is there any reason why Dev-C++ creates such a function? What is
15
4456
by: Jim | last post by:
I am extremely frustrated. I am building c# application for a call center and am using a third party API to access some hardware. When develop and test my class using the windows console the application runs flawlessly, but once I call the class from inside a c# windows application the program freezes, crashes etc... there must be a way to make this work inside a windows app as it run great as a command line app.
2
5782
by: Rookie | last post by:
Hi, I had a question on DllImport. On importing a function from a VC++ dll using DllImport (to a C# program), the function argument data types and the return types may be of a type that is not supported by C#. In this case if I am not mistaken the system performs default marshalling - matching the data types to its most similar equivalent in C#. Is this right? Also, I presume this can be overridden by using MarshalAs. Is this
9
4960
by: Ole Christensen | last post by:
I'm trying to make a sort of conditional compilation in my C# code because my app is intended to run on both a Pocket PC and on a normal desktop PC. My code uses a call to an API function that on the PPC is located in coredll.dll and on the desktop in kernel32.dll. I could make two versions of the DllImported funktions but then I would have to ask for the OS version in every call to the function. This however causes the code to look messy...
3
3455
by: Mark Jerde | last post by:
I'm sill learning VS .NET 2003, not an expert yet. I'm calling an unmanaged C++ DLL from C# using . When the whole project is done I will be calling a total of 5 C++ DLLs from C#. All the DLLs have the same signature, and I never have to call more than one DLL in the same program. (The DLLs parse and validate 5 different binary formats.) Originally I was expecting to have 5 different C# programs as the constants are different for each...
2
10473
by: Brian Anderson | last post by:
Hello, is it possible to use DllImport to call a DLL in ASP.NET ? Or is it necessarry that my DLL has to be copied into \System32 ? My DLL is a native C++ 7.1 DLL (not managed, no COM, no regsvr32) and uses Assembler to make some math in SSE. The result is given out as an Int. Using a C# console app (code below) it work fine & fast.
2
1958
by: hsharsha | last post by:
Consider the below code: extern __declspec(dllimport) int myvariable; template<const int *p> class MyClass{ public: static void myfunction(){ } }; int main(void){
1
5100
by: John Dinning | last post by:
(Using VS2005 C# and compact Framework. Target device is running CE5). I am creating a simple visual control (New Control Library project for smart device Windows CE 5), derived from Label, with a couple of extra properties. I need to call an external dll from this control, on a timer. When I insert the declaration for the external dll function and build the control project, strange things happen to any project that uses this control.
4
2018
by: =?Utf-8?B?TGVvbg==?= | last post by:
Hi, I have a C exported function in a DLL that has the following proto-type: int _cdecl MyFunction( LPCSTR fmt, ... ); Does anyone know the DllImport declaration for this so that I can call this in C#? Thanks.
1
4263
by: kardon33 | last post by:
Let me explain my problem, Im currently trying to use a Perl module that was built for a Windows OS that uses a .dll and .lib file. I have obtained the c header files that the modules were built with. I am trying to use SWIG to write my Perl mod with those files but I getting a bunch of errors with the "extern "C" __declspec(dllimport)" command kinda know that basics of the command, its used to declare vars from a .dll. If im wrong please...
0
8382
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
8297
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,...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
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...
1
6162
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
5629
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
4150
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...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.