How to use C# DLL in MFC

Hi all,
          I developed one C# DLL. now i want to use that DLL to my MFC
application created using vc++. Can any one help me how to load those
DLL's....


Thanks in advance,
SaranG


0
6/18/2008 8:57:05 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
969 Views

Similar Articles

[PageSpeed] 54

SaranG(Saravanan) wrote:
> Hi all,
>           I developed one C# DLL. now i want to use that DLL to my MFC
> application created using vc++. Can any one help me how to load those
> DLL's....
> 
> 
> Thanks in advance,
> SaranG
> 
> 
I think you could do that through COM interop.

Regards,
F.
0
6/18/2008 4:50:53 PM
Firstly, this is the wrong newsgroup for this question...anyways...

you can make you C# classes accessible to C++ app by registering them as
COM components.
Go to project properties/build and Select the "Register For COM Interop"
option in the Output section.

or if you like command prompt follow these steps:

You can also select the class which will be com visible. use the
ComVisible attribute on the class too.

Please note that for making a class COM visible

-the classes must use a default constructor with no parameters.
-Any type that is to be exposed must be public.
-Any member that is to be exposed must be public.
-Abstract classes will not be able to be consumed.

these steps are from the command line.
Let say your code is in myDLL.cs, then first you need to compile it

csc /t:library myDLL.cs


then you need to use the Type Library Exporter Utility.

tlbexp myDLL.dll /out:myDLL.tlb

Next you need to create a resource script (myDLL.res) with the following
Interface Definition Language (IDL) definition:

IDR_TYPELIB1 typelib "myDLL.tlb"

Then you recompile the application with the new resource file added
csc /t:library myDLL.cs /win32res:myDLL.res

after this is done you can use the class in C# as a COM component in C++
applicaiton


SaranG(Saravanan) wrote:
> Hi all,
>           I developed one C# DLL. now i want to use that DLL to my MFC
> application created using vc++. Can any one help me how to load those
> DLL's....
> 
> 
> Thanks in advance,
> SaranG
> 
> 
0
tech-talk (3)
6/18/2008 7:08:34 PM
If you are running VS2005 or greater, you can make your MFC a managed app 
and reference the c# assembly. If not, you have to use COM interop.

--
Ajay

"SaranG(Saravanan)" <infosarang@gmail.com> wrote in message 
news:d808b293-bea5-41a9-8105-de09b43ea3a4@s33g2000pri.googlegroups.com...
> Hi all,
>          I developed one C# DLL. now i want to use that DLL to my MFC
> application created using vc++. Can any one help me how to load those
> DLL's....
>
>
> Thanks in advance,
> SaranG
>
> 

0
ajaykalra (6842)
6/18/2008 11:15:43 PM
On Jun 18, 4:15 pm, "Ajay Kalra" <ajayka...@yahoo.com> wrote:
> If you are running VS2005 or greater, you can make your MFC a managed app
> and reference the c# assembly. If not, you have to use COM interop.
>
> --
> Ajay
>
> "SaranG(Saravanan)" <infosar...@gmail.com> wrote in message
>
> news:d808b293-bea5-41a9-8105-de09b43ea3a4@s33g2000pri.googlegroups.com...
>
> > Hi all,
> >          I developed one C# DLL. now i want to use that DLL to my MFC
> > application created using vc++. Can any one help me how to load those
> > DLL's....
>
> > Thanks in advance,
> > SaranG


Special Thanks to all of friends who helps me to load the DLL in from
C#... It works well....
0
6/20/2008 7:51:23 AM
Reply:

Similar Artilces:

Looking for Visual C++ 4.2
Does anyone have a copy of this dated compiler lying around? I'm after this specific version. Trent ...

How do I get info on using list builder
are there classes I can take or somewhere I can access extra info b4 I sign up? http://office.microsoft.com/en-us/assistance/HA011109511033.aspx -- JoAnn Paules MVP Microsoft [Publisher] "Mike R" <Mike R@discussions.microsoft.com> wrote in message news:2A44E94C-15D1-4430-8132-D33B543EE295@microsoft.com... > are there classes I can take or somewhere I can access extra info b4 I > sign up? Been there, really does not have a "training module" for list builder. There are alot of issues with list builder type products like constant contact, I would like...

how do i use juno email with outlook?
please advise if i can use juno email with microsoft office 2003 outlook? are they compatible? do i have to do anything special..like notify juno, etc. thank you. "bear2005" <bear2005@discussions.microsoft.com> wrote in message news:77AA6056-3AE8-4EFB-B04D-B4D12A7272B2@microsoft.com... > please advise if i can use juno email with microsoft office 2003 > outlook? > are they compatible? do i have to do anything special..like notify > juno, etc. > thank you. When I looked about 2 weeks ago, Juno did not provide FREE access to their POP3 and SMTP server w...

Use dropdown list from Form
Can I make a selection from a dropdown list while using data input form ? You could try John Walkenbach's Enhanced Data Form. It's a free add-in that allows combo boxes, so it could display a list of items. http://j-walk.com/ss/dataform/index.htm Gerrym wrote: > Can I make a selection from a dropdown list while using > data input form ? -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html ...

installing network service dll (vmnetbridge.dll) fails to copy into system32
Trying to install a network service vmnetbridge.dll fails with err msg. "An error occured while copying file vmnetbridge.dll. Cannot copy file to destination directory. c:\windows User is in local admin group. UAC is set to OFF. Driver is digitally signed by Vmware, inc. Please advice how to rectify. QA4Ever ...

Using Access to design a form and then publish it
I am trying with little success to utilise Access where a form can be designed and then this form can be sent to an e-mail address as an attachment where the form would look and react the same. e.g. the mail recipient would be able to enter information into the form just as if they where in Access, I then require the information to be received back into the database. Is there a straight forward way to do this, (the only way I can see at the moment is to use Data Access Pages!) (I do not want to use Infopath as the form design tool!!) -- djb ---------------- This post is a suggestion fo...

How can I tranfer my data to my.swf in MFC program.?
I have my.swf and my.exe (MFC). I want to send to my.swf an data of my.exe. But I don't know it. Please tell me some idea.. (I want just simple flash/MFC code.. just...) On Mar 15, 7:07 am, "keandi" <kea...@lycos.co.kr> wrote: > I have my.swf and my.exe (MFC). > > I want to send to my.swf an data of my.exe. > But I don't know it. > > Please tell me some idea.. > > (I want just simple flash/MFC code.. just...) Post this in a .swf ng instead. See if ShockWave Flash object has an object model that you can use to do this. --- Ajay This mig...

Using Outlook 2003 with ISA proxy problem #2
Hi, I'm using Outlook 2003 on my notebook (logged on with local administrator user) to check mail from SMTP/POP3 server through LAN connection but it reported that cannot connect. Our LAN using ISA proxy server, I tried both methods of using firewall (using default ISA client, and using manual proxy by enter ISA server address/port in IE) but cannot resolve problem. I guess that the problem due to I've not logged on by network domain user (ISA server ask for username for first time I open IE), so is there other way to solve my issue? Thanks, Tien, Can you telnet to the POP3 serv...

marshalling cascading C structures
Folks, consider these cascading C structures: typedef struct A_ { int a1; } A; typedef struct B_ { int numA; A *As; } B; typedef struct C_ { int numB; B *Bs; } C; which have been allocated dynamically. How can I marshal this in VB.net 2008? I tried this: <StructLayout(LayoutKind.Sequential)> _ Public Structure A Public a1 As Integer End Structure <StructLayout(LayoutKind.Sequential)> _ Public Structure B Public numA As Integer <MarshalAs(UnmanagedType...

How to share com component between C# and VBA
Hi All, Have a C# app which makes a call to VBA macro using in-memory excel. I am unable to share the data between C# and VBA macro by using the same COM component. Both C# and VBA invoked this COM component through interop layer. Please advise. Submitted via EggHeadCafe - Software Developer Portal of Choice Using SQL Server Notification Services Platform http://www.eggheadcafe.com/tutorials/aspnet/ecbc1965-42af-4376-b400-4aae5e12f872/using-sql-server-notifica.aspx "Sridhar Yada" wrote in message news:201011193338sridhar.yada@nomura.com... > Please advi...

MFC API
hi, can anyone suggest a link to where i can find an extensive MFC API? For example, i spent about 20 minutes trying to find exactly what arguments AfxMessageBox function took. I found it on somebody's page embedded in an example, but there's got to be some place online that has got it all laid out & easy to find. thanks, grant h. "Grant H." <grant_holler@yahoo.com> wrote in message news:7dedb20a.0401190906.67467fd0@posting.google.com... > hi, > > can anyone suggest a link to where i can find an extensive MFC API? > For example, i spent about 20 min...

Using Javascript to Disable a Toolbar Button
I used the ISV.Config file to add a Toolbar Button to the Opportunity Form called "Create Billing Profile". I only want to enable this button when an Opportunity is set to Closed and Won. Is there a way to use Javascript to enable and disable a Toolbar Button? I tried to pass in an Id for the Toolbar Button in my ISV.Config file, but got an error. Thanks so much in advance for any ideas you might have. Sincerely, Robyn To get the correct id open a form that has the button on it and press Ctrl+N (new windows). This will open a new window with the same form but with the IE ...

Using colored paper
Hello, Is there any option to preview how a document may look when printing on colored paper? Once the color from the document mixes with the paper color, you don't necessarily get text/images in the color they appear on your screen. You could draw a rectangle on the Master page, fill it with any color. When you are ready to print, view, ignore Master Page. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Vespasian" <Vespasian@discussions.microsoft.com> wrote in message news:7164BA00-0501-4FAC-A53D-6B75D0928...

Using ODBC in MOPS2007?
I am curious about possible uses of the ODBC option for opening project in MSP2007 Server. What are the possible advantages or usage scenarios? Thanks for the general education. Hi Quizzed, ODBC was dropped from Project Server 2003 because it was too "chatty" and "heavy" as a protocol to work in the new web based, vpn based world. These are the cons. -- Regards, Ben. http://www.applepark.co.uk http://appleparkltd.spaces.live.com/ "Quizzed again" wrote: > I am curious about possible uses of the ODBC option for opening project in &g...

Can OWA be used to access more than one mailbox at the same time?
Is it possible to access multiple mailboxes with a single log in. Like the way with Outlook it is possible to view multiple mailboxs at the same time. Not sure if it'd be the same time - but you can access another user's mailbox if you have permissions - using the complete URL to such a mailbox. For instance, server.domain.com/exchange/secondusername. You can't open both in the same OWA window like Outlook allows you to do by adding additional mailbox(es). -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: www.exchangepedia.com/blog ------------------------...

using a custon Avery 8876 template to create membership cards. I .
shI created a unique template in Publisher for Avery 8876 business cards, which I am using for Memberhsip cards instead. I am only able to see and edit a single "representative " card. How can I enter individual members names on each sheet before I print it? Do a mail merge. Please be aware that if you do a Print Preview, you will only see a single name, not all of the members. -- JoAnn Paules MVP Microsoft [Publisher] "HOT FLASH" <HOT FLASH@discussions.microsoft.com> wrote in message news:525B2114-7F9C-4C08-8A7D-45D7A5EF0F07@microsoft.com... > shI crea...

use arrow keys to tab to specific cells
I was able to use my arrow keys to tab to specific cells, now it moves the entire worksheet instead. How to I enable my arrow keys to move to cells? Hi, On the keyboard tap 'Scroll Lock' key. Mike "mary ellen" wrote: > I was able to use my arrow keys to tab to specific cells, now it moves the > entire worksheet instead. How to I enable my arrow keys to move to cells? SCROLL lock is ON. (Key near to Print Screen in your keyboard) Turn it OFF -- Jacob "mary ellen" wrote: > I was able to use my arrow keys to tab to specific c...

MFC apps spawned by NT services
Hi, Q164166 states that an assertion may occur in wincore.cpp when a service launches a mfc application. Well, frankly, I can't reproduce this behaviour. Some time ago I made a service which is able to launch any win32 program, mfc apps, too. Is the KB article out-of-date? I think the operative word is "may" as opposed to "will." "Carmen Neumann" <mola@italia.it> wrote in message news:d9rkn7$946$1@online.de... > Hi, > > Q164166 states that an assertion may occur in wincore.cpp when a service > launches a mfc application. ...

Use of Excel for Mailing List
Does the latest vesion of excel delete mailing list duplications automatically? No.. Regards, Peo Sjoblom "tjd" wrote: > Does the latest vesion of excel delete mailing list duplications automatically? But if you want help working with duplicates, take a trip to Chip Pearson's site: http://www.cpearson.com/excel/duplicat.htm He has a bunch of techniques for working with duplicates. tjd wrote: > > Does the latest vesion of excel delete mailing list duplications automatically? -- Dave Peterson ...

can I use both Excel 2003 and Excel 2010 on the same pc ?
Can I use both Excel 2003 and Excel 2010 on the same pc ? I have licenses for both. Thanks, Lynn Yes, you can. Install 2003 first then 2010. Gord Dibben MS Excel MVP On Tue, 30 Nov 2010 15:31:05 -0600, Lynn McGuire <lmc@winsim.com> wrote: >Can I use both Excel 2003 and Excel 2010 on the same pc ? > >I have licenses for both. > >Thanks, >Lynn And install them in separate folders - even better is on separate partitions. -- Jim Cone Portland, Oregon USA "Lynn McGuire" <lmc@winsim.com> wrote in message news:id3qet$43g$1@news.eternal-septembe...

Can Clip Art be used with, Outlook Express?
"Fizzle" <Fizzle@discussions.microsoft.com> wrote in message news:2E7AC754-9AF7-4BDE-B099-1C8102EE9E95@microsoft.com... > Hi - This is a group to support Outlook from the Office group of programs. Outlook Express is a part of Internet Explorer and is a quite different program, despite its similar name.. You will probably get a faster and more expert answer if you post this to an Outlook Express news group. Try posting in one of these newsgroups: microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x microsoft.public.windows.inetexplorer.ie55.outlookexpre...

Automatic Calendar entry from E-Mail Using Macros?
Hi Folks, I'd like to be able to automatically enter and remove calendar entries based on the content of an e-mail received by a public folder. This is primarily to control staff holidays and automate the process so that no human intervention is required other than checking who has what left in the way of days. Any Pointers appreciated so I don't re-invent the wheel! Cheers J jb@jb.com wrote: > Hi Folks, > > I'd like to be able to automatically enter and remove calendar entries based > on the content of an e-mail received by a public folder. This is primarily &g...

unable to login to exchange 2003 server using outlook client
All, I have a windows 2003 exchange server on a secure network. My windows 2000 EX is a DC that's belong to a 2003 AD (test.com). We have our local dns and the DNS is forward to a BIND DNS. The exchange server is using the BIND DNS not the local dns All the workstations on the WAN is using the BIND DNS too. When I try to use the outlook client(2000,xp) I got the error message prompt that the username, password or the domain name is incorrect, even though I was and always being able to login using the same account name and password, domain name on some of the workstations that's...

create template in publisher for use in word???
I have created a document in publisher, but how do i save it as a template which can be openned and used in microsoft word 2000? I have to ask - why didn't you create it in Word if you wanted to use Word for the finished product? -- JoAnn Paules MVP Microsoft [Publisher] "Jo" <Jo@discussions.microsoft.com> wrote in message news:C010FD99-674C-46D6-8386-343D52557F0A@microsoft.com... >I have created a document in publisher, but how do i save it as a template > which can be openned and used in microsoft word 2000? ...

How can web use Shamsi Calendar
hi i need to use sahmsi calendar on my project how can i use shamsi calendar? Hello Ali, There is no other built-in calendar type except for Gregorian in MS Project desktop. There is an add-in for Hijri Calendar at the download center but none for Shamsi. You can make an internet search on ""Shamsi for Microsoft Project" to find a third party add-in. Regards. Ismet Kocaman "ali rezaiy" wrote: > hi i need to use sahmsi calendar on my project > how can i use shamsi calendar? > ...