Hi all
may I know how to use C# DLL inside my VC++ Project ?
Thanks in advance. 8 19858
Paul,
Please be more specific. Is this a Managed Extension application, or is this
a native C++ application. If this is a native application, then refer to the
article at http://msdn.microsoft.com/library/de...erTutorial.asp,
and if this is a managed application, then just make a reference to it and
use it like any other managed library.
Ben
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com... Hi all,
may I know how to use C# DLL inside my VC++ Project ??
Thanks in advance.
hi ben
pardon me for not being specific enough. actually, windows programming is new to me
i created my c# dll, and use regasm to register the dll
inside my VC++ project, it is a console application. i have added reference to the dll into the project. i also used #using <mydll.dll> directives
however, when i tried to access one of the methods inside mydll.dll, it returns C2039: 'getMsg' : is not a member of 'namespace_a::class_a
please advice again
thanks and cheers
----- Ben Rush wrote: ----
Paul
Please be more specific. Is this a Managed Extension application, or is thi
a native C++ application. If this is a native application, then refer to th
article a http://msdn.microsoft.com/library/de...erTutorial.asp
and if this is a managed application, then just make a reference to it an
use it like any other managed library
Be
"Paul" <an*******@discussions.microsoft.com> wrote in messag
news:75**********************************@microsof t.com.. Hi all may I know how to use C# DLL inside my VC++ Project ? Thanks in advance
Hi Paul,
Regasm is needed only when you need to expose the managed
types in your C# assembly to unmanaged (native) clients via COM interop.
If your VC++ project that consumes the C# dll is a Managed
Extensions project, then you do not need to register the types
with RegAsm. Can you post a brief snippet of code of the methods in class_a
?
Regards,
Aravind C
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com... hi ben,
pardon me for not being specific enough. actually, windows programming is
new to me. i created my c# dll, and use regasm to register the dll.
inside my VC++ project, it is a console application. i have added
reference to the dll into the project. i also used #using <mydll.dll>
directives. however, when i tried to access one of the methods inside mydll.dll, it
returns C2039: 'getMsg' : is not a member of 'namespace_a::class_a' please advice again.
thanks and cheers.
----- Ben Rush wrote: -----
Paul,
Please be more specific. Is this a Managed Extension application, or
is this a native C++ application. If this is a native application, then refer
to the article at http://msdn.microsoft.com/library/de...erTutorial.asp, and if this is a managed application, then just make a reference to
it and use it like any other managed library.
Ben
"Paul" <an*******@discussions.microsoft.com> wrote in message news:75**********************************@microsof t.com... > Hi all, >> may I know how to use C# DLL inside my VC++ Project ?? >> Thanks in advance.
Hi
thanks for your reply
Here's a snippet of the C# DLL code. I used regasm to register the DLL.
I also attached the code for my VC++ project. Sorry if it is too long
Thanks in advance
************************************************** ***********
// Win32TestProg.cpp : Defines the entry point for the console application
#include "stdafx.h
#using <mscorlib.dll
#using <myDLL.dll
using namespace System
int _tmain(int argc, _TCHAR* argv[]
HANDLE handle = CreateEvent(NULL, TRUE, FALSE, NULL)
myDLL::class_a *a
a= new myDLL_AZ::class_a()
a->registerEventHandler(handle)
while (true
int ret = WaitForSingleObject(handle, -1)
System::Console::WriteLine (a->getStateVar())
Console::WriteLine(a->getStateMsg())
ResetEvent(handle)
CloseHandle (handle)
return 0
************************************************** ***********
using System
using System.Runtime.InteropServices
namespace
public class class_
private static class_a m_instance = null
private static readonly object padlock = new object()
private CWin32 m_win32
private int MAX_HANDLE = 10
private IntPtr [] m_handle
private int m_num_handle = 0
private short m_state
private string m_statemsg
public class_a(
/
// TODO: Add constructor logic her
/
m_handle = new IntPtr[MAX_HANDLE]
m_win32 = new CWin32()
init()
public static class_a getInstance(
lock (padlock
if (m_instance == null
m_instance = new class_a()
return m_instance
private void init(
private void OnStateChanged(short state, string message
m_state = state
m_statemsg = message
//notify the source about the even
for (int cnt=0; cnt<m_num_handle; cnt++
m_win32.win32SetEvent(m_handle[cnt])
public short getStateVar ()
{
return m_state;
public string getStateMsg ()
{
return m_statemsg;
public int registerEventHandler (IntPtr handle
if(m_num_handle > MAX_HANDLE
return -1
m_handle [m_num_handle] = handle
m_num_handle++
return 1
/// <summary
/// This class export win 32 finction signature
/// </summary
public class CWin3
//D L L I M P O R T O F W I N 3
//CONSTAN
#region CONSTAN
public static readonly IntPtr InvalidHandleValue = new IntPtr(-1)
public const UInt32 FILE_MAP_READ = 0x04
public const UInt32 PAGE_READWRITE = 0x04
#endregio
//WIN3
#region DLL IMPORT
//SET EVEN
[DllImport("Kernel32.dll",CharSet=CharSet.Auto)
private static extern Boolean SetEvent(IntPtr hEvent)
//RESET EVEN
[DllImport("Kernel32.dll",CharSet=CharSet.Auto)
private static extern Boolean ResetEvent(IntPtr hEvent)
//OPEN EVEN
[DllImport("Kernel32.dll",CharSet=CharSet.Auto)
private static extern IntPtr OpenEvent(UInt32 dwDesiredAccess,Boolean bInheritHandle,String lpName)
//CREATE EVEN
[DllImport("Kernel32.dll",CharSet=CharSet.Auto)
private static extern IntPtr CreateEvent(IntPtr lpEventAttributes,Boolean bManualReset,Boolean bInitialState,String lpName)
//CLOSE HANDL
[DllImport("Kernel32.dll",CharSet=CharSet.Auto)
private static extern Boolean CloseHandle(IntPtr hObject)
//WAIT FOR SINGLE OBJEC
[DllImport("Kernel32.dll",CharSet=CharSet.Auto)
private static extern UInt32 WaitForSingleObject(IntPtr hHandle,Int32 dwMilliseconds)
#endregio
public CWin32(
/
// TODO: Add constructor logic her
/
public Boolean win32SetEvent(IntPtr hEvent
return CWin32.SetEvent(hEvent)
public Boolean win32ResetEvent(IntPtr hEvent
return CWin32.ResetEvent(hEvent)
hi aravind
have you seem the code snippet i sent earlier
hope to hear from you soon
thanks again
----- Aravind C wrote: ----
Hi Paul
Regasm is needed only when you need to expose the manage
types in your C# assembly to unmanaged (native) clients via COM interop
If your VC++ project that consumes the C# dll is a Manage
Extensions project, then you do not need to register the type
with RegAsm. Can you post a brief snippet of code of the methods in class_
Regards
Aravind
"Paul" <an*******@discussions.microsoft.com> wrote in messag
news:07**********************************@microsof t.com.. hi ben pardon me for not being specific enough. actually, windows programming i
new to me i created my c# dll, and use regasm to register the dll inside my VC++ project, it is a console application. i have adde
reference to the dll into the project. i also used #using <mydll.dll
directives however, when i tried to access one of the methods inside mydll.dll, i
returns C2039: 'getMsg' : is not a member of 'namespace_a::class_a please advice again thanks and cheers ----- Ben Rush wrote: ---- Paul Please be more specific. Is this a Managed Extension application, o
is thi a native C++ application. If this is a native application, then refe
to th article a
http://msdn.microsoft.com/library/de...erTutorial.asp and if this is a managed application, then just make a reference t
it an use it like any other managed library Be "Paul" <an*******@discussions.microsoft.com> wrote in messag news:75**********************************@microsof t.com.. Hi all may I know how to use C# DLL inside my VC++ Project ? Thanks in advance
Hi Paul,
I took a look at the code you sent.
As mentioned earlier, since the C# assembly is only consumed by
Managed C++ extensions project, you do not need to use Regasm.exe.
Some changes that you may need to make are:
Instead of myDLL::class_a, use the following since 'A' is your namespace
name.
A::class_a *a;
a= new A::class_a();
Also precede, your CreateEvent call with the CWin32:: declaration
in your managed c++ code, since in the C# example that you sent,
the CWin32 class declares this static method via PInvoke.
CWin32::CreateEvent(...);
Regards,
Aravind C
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com... hi aravind,
have you seem the code snippet i sent earlier ?
hope to hear from you soon.
thanks again.
----- Aravind C wrote: -----
Hi Paul,
Regasm is needed only when you need to expose the managed types in your C# assembly to unmanaged (native) clients via COM
interop. If your VC++ project that consumes the C# dll is a Managed Extensions project, then you do not need to register the types with RegAsm. Can you post a brief snippet of code of the methods in
class_a ?
Regards, Aravind C
"Paul" <an*******@discussions.microsoft.com> wrote in message news:07**********************************@microsof t.com... > hi ben, >> pardon me for not being specific enough. actually, windows
programming is new to me. >> i created my c# dll, and use regasm to register the dll. >> inside my VC++ project, it is a console application. i have added reference to the dll into the project. i also used #using <mydll.dll> directives. >> however, when i tried to access one of the methods inside
mydll.dll, it returns C2039: 'getMsg' : is not a member of 'namespace_a::class_a' >> please advice again. >> thanks and cheers. >> ----- Ben Rush wrote: ----- >> Paul, >> Please be more specific. Is this a Managed Extension
application, or is this > a native C++ application. If this is a native application,
then refer to the > article at > http://msdn.microsoft.com/library/de...erTutorial.asp, > and if this is a managed application, then just make a
reference to it and > use it like any other managed library. >> Ben >> "Paul" <an*******@discussions.microsoft.com> wrote in message > news:75**********************************@microsof t.com... >> Hi all, >>> may I know how to use C# DLL inside my VC++ Project ?? >>> Thanks in advance. >>>
Hi
I did A::class_a
However, inside my C# DLL, I am using external COM references (I added them manually into the C# Project). Inside A::Class_a, I have an instance of the 2 COM references. Initially, without adding the 2 COM references, my VC++ program will throw a FileNotFound Exception. So I added them
Inside my VC++ project, I also manually added my C# DLL in the VC++ project and used the "using <myDLL.dll> directive
However, this time, it throws TypeLoadException exception. When I trace the problem, it seem like it occur when I tried to instantiate the external COM object
Please advice and thanks again
Cheers
Pau
----- Aravind C wrote: ----
Hi Paul
I took a look at the code you sent
As mentioned earlier, since the C# assembly is only consumed b
Managed C++ extensions project, you do not need to use Regasm.exe
Some changes that you may need to make are
Instead of myDLL::class_a, use the following since 'A' is your namespac
name
A::class_a *a
a= new A::class_a()
Also precede, your CreateEvent call with the CWin32:: declaratio
in your managed c++ code, since in the C# example that you sent
the CWin32 class declares this static method via PInvoke
CWin32::CreateEvent(...)
Regards
Aravind
"Paul" <an*******@discussions.microsoft.com> wrote in messag
news:6C**********************************@microsof t.com.. hi aravind have you seem the code snippet i sent earlier hope to hear from you soon thanks again ----- Aravind C wrote: ---- Hi Paul Regasm is needed only when you need to expose the manage types in your C# assembly to unmanaged (native) clients via CO
interop If your VC++ project that consumes the C# dll is a Manage Extensions project, then you do not need to register the type with RegAsm. Can you post a brief snippet of code of the methods i
class_ Regards Aravind "Paul" <an*******@discussions.microsoft.com> wrote in messag news:07**********************************@microsof t.com.. hi ben pardon me for not being specific enough. actually, window
programming i new to me i created my c# dll, and use regasm to register the dll inside my VC++ project, it is a console application. i have adde reference to the dll into the project. i also used #using <mydll.dll>> directives however, when i tried to access one of the methods insid
mydll.dll, i returns C2039: 'getMsg' : is not a member of 'namespace_a::class_a please advice again thanks and cheers ----- Ben Rush wrote: ---- Paul Please be more specific. Is this a Managed Extensio
application, o is thi a native C++ application. If this is a native application
then refe to th article a http://msdn.microsoft.com/library/de...erTutorial.asp and if this is a managed application, then just make
reference t it an use it like any other managed library Be "Paul" <an*******@discussions.microsoft.com> wrote in messag news:75**********************************@microsof t.com.. Hi all may I know how to use C# DLL inside my VC++ Project ? Thanks in advance
Hi
can you help me ? I am getting TypeLoadException when trying to instantiate a class in the C# DLL. This class is from another external COM
I have sent you an earlier msg
Thank
----- Aravind C wrote: ----
Hi Paul
I took a look at the code you sent
As mentioned earlier, since the C# assembly is only consumed b
Managed C++ extensions project, you do not need to use Regasm.exe
Some changes that you may need to make are
Instead of myDLL::class_a, use the following since 'A' is your namespac
name
A::class_a *a
a= new A::class_a()
Also precede, your CreateEvent call with the CWin32:: declaratio
in your managed c++ code, since in the C# example that you sent
the CWin32 class declares this static method via PInvoke
CWin32::CreateEvent(...)
Regards
Aravind
"Paul" <an*******@discussions.microsoft.com> wrote in messag
news:6C**********************************@microsof t.com.. hi aravind have you seem the code snippet i sent earlier hope to hear from you soon thanks again ----- Aravind C wrote: ---- Hi Paul Regasm is needed only when you need to expose the manage types in your C# assembly to unmanaged (native) clients via CO
interop If your VC++ project that consumes the C# dll is a Manage Extensions project, then you do not need to register the type with RegAsm. Can you post a brief snippet of code of the methods i
class_ Regards Aravind "Paul" <an*******@discussions.microsoft.com> wrote in messag news:07**********************************@microsof t.com.. hi ben pardon me for not being specific enough. actually, window
programming i new to me i created my c# dll, and use regasm to register the dll inside my VC++ project, it is a console application. i have adde reference to the dll into the project. i also used #using <mydll.dll>> directives however, when i tried to access one of the methods insid
mydll.dll, i returns C2039: 'getMsg' : is not a member of 'namespace_a::class_a please advice again thanks and cheers ----- Ben Rush wrote: ---- Paul Please be more specific. Is this a Managed Extensio
application, o is thi a native C++ application. If this is a native application
then refe to th article a http://msdn.microsoft.com/library/de...erTutorial.asp and if this is a managed application, then just make
reference t it an use it like any other managed library Be "Paul" <an*******@discussions.microsoft.com> wrote in messag news:75**********************************@microsof t.com.. Hi all may I know how to use C# DLL inside my VC++ Project ? Thanks in advance This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kanaiya |
last post by:
how to use c# dll into visual c++ project.
With regards,
Gangani Kanaiya.
|
by: Paolo |
last post by:
I imported a VC++6.0 project into VC++7.1. The conversion operation makes a mess with Preprocessor Definitions, adding a "$(NoInherit)" for each file.
For example: I had a DLL project in VC++6.0...
|
by: kalyan. |
last post by:
hello,
i am working on WMA SDK.
i got the SDK from Microsoft under source development agreement .
The SDK has the project of WMA 9.1 built in VC 7.1
As i dont have VC 7 i found a tool to convert...
|
by: Al |
last post by:
Could anybody point me to some resource about how to call a VB.net DLL in
VC.net?
Thanks in advance.
Al
|
by: Dr. Zharkov |
last post by:
We want to export myArrayVB (2000, 2) of VB .NET 2003 in myArrayVó
of VC++ .NET 2003 on scheme "component - client". But there is an error.
For development of a component in VB .NET 2003 we...
|
by: Robert Ludewig |
last post by:
I have sucessfully imported and compiled a complex MFC 6.0 project from
vc++6.0 (MFC6.0) into vc++ 8.0 (MFC 8.0). It contains several
subprojects (libs and dlls). In vc++ 6.0 those project linked...
|
by: nmrcarl |
last post by:
I'm trying to upgrade a large project from VS 6.0 to VS 2005.
After fixing a lot of things that changed (mostly sloppy coding in the
original project that VS2005 didn't allow), I got the release...
|
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= |
last post by:
Is there a way to convert a VC++ MFC project into a VC++ .NET project?
If yes, how do I do it?
|
by: Norman Diamond |
last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet
Framework 2. Options are set in the setup project properties, so if these
two dependencies are not already installed then...
|
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
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |