MFC DLL Calling C# Assembly

I have been trying to get a simple mfc dll I wrote to add to numbers
call a C# assembly.  Here is a sample of my C++ code in my cpp file.

extern "C" _declspec(dllexport) int Calc(int no1,int no2)
      {
        //result = no1 + no2;
        return MangedAdder(no1, no2);
      }
#pragma managed

#using <mscorlib.dll>
#using <ControllerLibrary.dll>

int MangedAdder(int a, int b)
{
	  ControllerLibrary::DLLController *t = new        
ControllerLibrary::DLLController();
	  return t->AddNumbers(a, b);
}

All I really need is an extern function in a mfc dll that calls a
method in a C# assembly.  I don't even know if I need a managed
function inside my C++ dll to call the C# method.  The code above is
just based upon a sample I found on the internet.  The error I am
getting with the code above is the following:

fatal error C1107: could not find assembly 'ControllerLibrary.dll':
please specify the assembly search path using /AI or by setting the
LIBPATH environment variable

I have put the ControllerLibrary.dll assembly in the directory of my
mfc project.  I put the path to it in the LIBPATH.  I put the path in
using the /AI switch.  I have also given the assembly a strong name
and placed it in the gac.  None of those changes seemed to help.  I
would appreciate anyones suggestions or even better an example of code
that works which calls a C# method from a MFC DLL extern function. 
Thanks for any help.
0
dreck (1)
10/11/2004 12:48:22 AM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies
627 Views

Similar Articles

[PageSpeed] 5

Reply:

Similar Artilces:

ANN: xsdbXML release with C#/.NET port
ANN: xsdbXML release with C#/.NET port Part I: Announcement ==================== There is a new release of xsdbXML which provides bugfixes to the Python implementation and also provides a completely separate implementation in C#/.NET. The xsdb framework provides a flexible and well defined infrastructure to allow tabular data to be published, retrieved, and combined over the Internet. Read more and download at http://xsdb.sourceforge.net Part II: Discussion =================== The C# implementation is primarily a transliteration of the Python implementation. I hope to also do a java tr...

A strange problem with MFC
Hi, Rencently I met a strange problem. The code like below: CWinThread* pThread = AfxBeginThread(ThreadFunc, (LPVOID)this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); if(pThread->m_hThread != NULL){ pThread->m_bAutodelete = FALSE; pThread->ResumeThread(); } After the statement "pThread->m_bAutodelete = FALSE" executed, I found the value of pThread->m_hThread is 0. While pThread->m_bAutodelete is still 1! The code section located in a win32 static library, with /Md option.The host application(exe) is a win32 console application, with /Md option. There...

Unicode in MFC
Hi, I am new to MFC programming and I have a problem: when I try to write the caption of a button or something else in my own language(Farsi), in the design mode it shows the correct string but when I compile it it shows a '?' instead of every character. Can anyone please help me with that. > I am new to MFC programming and I have a problem: > when I try to write the caption of a button or something else in my > own language(Farsi), in the design mode it shows the correct string > but when I compile it it shows a '?' instead of every character. Can > anyone ple...

Macro calling another Macro
Is it possible to call one macro within another macro? If so, how? The macros would be located in the same workbook, but different sheets Thanks, John Sub Macro1() Do stuff here maybe Call Macro2() Perhaps do more stuff here. End sub -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) -------------------------------------------------------------...

return int value to OS in MFC App
Hi, Everybody. I have to make A MFC app to return int value to Operatiing System.. if i could use WinMain() function, this is not matter. but MFC does not reveal WinMain().... How can i solve this problem? Can Anybody help me with this problem? <flybluewing@bcline.com> wrote in message news:1189386249.923483.59250@y42g2000hsy.googlegroups.com... > Hi, Everybody. > > I have to make A MFC app to return int value to Operatiing System.. > > if i could use WinMain() function, this is not matter. > but MFC does not reveal WinMain().... > How can i solve this problem?...

mfc and IE activeX
I'm using VS 2003 and trying to use Internet Explorer in my MFC application but encountering problems If I built a very simple test dialog-application and drop in the IE it works exactly as expected. However, when I create a similar dialog box in my MFC application and call the ...DoModal() nothing appears at all - not even the dialog box itself. It's as if my application does not want to use ActiveX components - I also tried a couple of other Microsoft ActiveX controls and they have the same problem. I must be missing something obvious - any one with any ideas will be much ...

dlg DLL Message
I have just upgraded to office 2003 Professional. While using Publisher I have got a dialog box titled dlg DLL Message with the message "Version Error of ucf file" with an OK button. There appear to be no adverse effects and clicking OK clears the box again with no apparent effect. Does anyone know why this might be and how I stop it. regards ...

RegisterWindowMessage, HWND_BROADCAST between exe and dll issue
i have the following problem, that i've been looking at and googling about for past 4 days to no avail. i have an exe, let's call it exe1, that is ours, that runs as some user, "Administrator" in this particular case, on a given machine, that does following: UINT uiStringA = RegisterWindowMessage("StringA") and then has ON_REGISTERED_MESSAGE(uiStringA, stringAHandler); then i have a vendor's exe, that runs as a service under "System" user and that loads 1 standard c dll, which in turn loads 2nd dll, let's call it dll2, which is also ours and m...

Need Help with MFC!!
Hi all, need help esp. with Graphic part. When you right click on any drive on your machine and click properties, you get a tabbed dialog. I want to know how can I embed graphic image (pie chart) into my MFC Dialog? I have written code which displays the Disk Usage right now but don't know how to display that info as a PIE CHART!!!!!! besides what type of MFC Dialog application should I look fwd to build? I want exactly as the DRIVE properties. TIA -- ======== Regards Vai ======== Have you looked at the CDC::Pie method? joe On Wed, 12 May 2004 23:07:11 -0400, "Vai2000"...

MFC to Console.
Hello Group. I need to convert the code of WiniNet Async Demo from microsoft samples from MFC to a console function.. Someone can help me with the changes.. The code is posted here Regards /* Microsoft Corporation Copyright 1999-2002 */ /******************************************************************** ProjectName : AsyncDemo Purpose : This sample demonstrates how to submit two WinInet requests, using InternentOpenUrl, asynchronously. Notes : This sample does not handle any authentication. To properly handle authentication, the functions that handle specific protocols (like Ht...

msxml3.dll not present
when opening a report generated by Backup Exec I get msxml3.dll not present, I registered the dll again, I installed all versions of xml available to sbs2008. Symantec was unable to help me with the problem and adviced me to reinstall the entire suite. I was wondering if there is anything else I could do? msxml3 is definitely not a default OS dll and hasn't been for quite some time. In short, an app issue, so the app company is the best source for support and their advice should be followed. -Cliff "Ingmar Van Glabbeek" <ingmar.vg@gmail.com> wrote in...

Printer DLL's
Our Dynamics GP graphical reports do not print. They come up on the screen but will not print to a printer nor our PDF writer. Will come up in Microsoft XPS Document writer. After much troubleshooting (getting Microsoft involved), the final assessment is that a printer dll that several (maybe all) printers have in common must be corrupted. Question: Does anyone know of a way to identify/list dll's associated with a printer. We are in deep trouble here, not being to print invoices. MaryH, Print a test page. It will tell you the exact driver and version. To print a test page,...

XML and MFC
Hello guys, What source of knowledge would you point me to if you were about to integrate XML with MFC? Of course if there's any Microsoft documentation anywhere, please post me a link to it. Thank you in advance! :-) Yea, I wanna know it too. Who would give a hand? > What source of knowledge would you point me to if you were about to > integrate XML with MFC? Of course if there's any Microsoft documentation > anywhere, please post me a link to it. After digging left and right, I remained with two main options: - MSXML - MS, proprietary, COM, with all the implications:...

Data Migration Wizard for Microsoft Office Outlook with Business C
Is there anyone, who have experience, in using the "Data Migration Wizard for Microsoft Office Outlook with Business Contact Manager" to import data to Microsoft CRM? My question is primary, if it is simple to use the tool and if all information can be imported? Best Regard CD You use the Data Migration Wizard to picks up csv files, generate the data maps from the csv sample files and import/export data & data maps. you can use the tool from within outlook 2007 which is the one you have i assume. Yet, if you want to synchronise your contact list with CRM then you ...

dynamically managing of layout in MFC + GridBagLayout in MFC or C++
Hi, can anybody tell me how can I make or find a function in MFC to manage layout of a dialog that dynamically has been create and also the controls in the dialog? I am new in MFC, what I am lokking for is something like GridBagLayout in java? is there something like this in C++ MFC ? any idea plz? Thank u There is nothing like GridBagLayout in MFC. However, you can achieve the same functionality thru various means. You have to move the controls manually on resize of the dialog or window. Please see the following examples: http://www.codeproject.com/dialog/easysize.asp http://www.codepr...

Sending Window Messages from an MFC app to a Windows Firm tray application
Hello, I have an MFC MDI application and a Windows Forms (2.0) Tray Icon application. I want to run a command on the tray application via my MFC application. There is a "Register" context menu command on the tray icon application. I want to call the Register command from my MFC MDI application. I thought of a windows message. How do I do it? Is there any other better mechanism to do so? Thanks, Janiv Ratson. If you know the class of the window on the tray application you can use FindWindow() to get the window for the class. Then you can use either PostMessage() or SendMessag...

Console output from MFC dialog based app
Dear All, I have developed a MFC dialog based application. Now when I execute this app from command prompt, I need to write some text back to console. In console application we achieve this using functions like printf(), puts(), etc. Please let me know how do I achieve same in dialog based application since printf() and other functions are not working here. Thanks, Ajay You can't write to the same console window that you were ran from, but you can create a console window and write to that. Take a look at AllocConsole, ReadConsole, and WriteConsole. Here is an example: http://www....

Reporting back crashes in MFC-based products
Hello, We have a product written in MFC using Visual Studio 7.1. We are now planning to implement a feature that will detect a crash and report to us the cause of the crash and other meaningful information. The plan is to provide something similar to Window's error reporting tool. I found a 3rd party tool for Delphi that instruments the source code. When the program crashes, it provides information like the name of the function, module etc.. Is there something similar that I can use with MFC? The other option is to use MFC's Structured Exception Handling and try to get a memory dump...

Open C:/examplefile.xls or file.txt from another excel worksheet
Hey, people!! I need some help, I want to create an excel worksheet that checks which files are in a directory (C:\) and lists them in my worksheet. When I click on the listed files it takes me to the directory were they are located. If you can open the files when clicked even better!!! I consider myself average in vba now, but I need someone to tell me which function or built in procedure I should use. Thanks, Chay Chay, I'm not entirely sure everything you want to do here, but let me offer this as a start. This macro will list all the files in the "C: \" directory on ...

Outlook and "Bad Image" error (msimtf.dll)
I have a user in the office, with Windows XP Home (SP2) and Office 2002 (SP3). She's starting to get this message: "OUTLOOK.EXE - Bad Image. The application or DLL C:\WINDOWS \System32\msimtf.dll is not a valid Windows image. Please check this against your installation diskette." every time she starts up Outlook, sometimes two or three of them in a row she has to OK. They'll also pop up now and then while using Outlook. This only started happening a couple of days ago, and she hasn't installed or uninstalled any software lately, and nothing else unusual has happened wit...

Excel VBA 2003: how do I call an Analysis ToolPak function within
Analysis ToolPak is installed in my application and I need to use the result of EOMONTH function in a UDF I am writing. These functions are clearly not amongst the properties/methods of APPLICATION.WORKSHEETFUNCTIONS. I tried this syntax: PrevMthEnd = [atpvbaen.xla]!EOMONTH(Date, -1) but it also does not work. How should it actually be worded? In addition to 'installing' the Analysis ToolPak along with 'Analysis ToolPak - VBA', in the VB Editor, set a Reference (Tools --> References) to atpvbaen.xls It should be in the list of available library refere...

Access and MFC
I would like to use some MFC capabilities from within Access. In PDC05/PRS313, Nick Kramer gave examples of using HWND's to create mixed Win32/Windows Presentation Foundation applications. I remember reading recently somewhere that Microsoft has released the MFC for general use. Can anyone provide information about (or even verify) the MFC release? Thanks, James A. Fortune CDMAPoster@FortuneJames.com MPAPoster@FortuneJames.com Microsoft Cabinet SDK: http://msdn2.microsoft.com/en-us/library/ms974336.aspx ...

bug of MFC ActiveX Control?
i create a default MFC activex control by wizard, i just check the windowlessActivate option, because i want to create a transparent control. but when i use the control in vb, the form_keydown event will be triger twice. i recompile the control after comment the follow line: dwFlags |= windowlessActivate; all things is ok. can someone confirm this "bug"? -- ף���ˣ� Maybe my english is so poor? Or something else? "sPhinX" <s5689412@163.com> д���ʼ� news:eQ$NrxkcFHA.4040@TK2MSFTNGP14.phx.gbl... > i create a default MFC activex control by wizard, > i just ch...

The procedure entry point RtlUnhandledExceptionFilter could not be located in the dynamic link library ntdll.dll.
I have found a 'ntdll.dll' file, but that didn't help. This shows up in Outlook. W. Kirk Crawford Rochester Hills, Michigan --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004 I found it, http://www.jrsoftware.org/iskb.php?uxtheme W. Kirk Crawford Rochester Hills, Michigan "W. Kirk Crawford" <wkc@comcast.net> wrote in message news:xoidnaqrja3VPVncRVn-hg@comcast.com... > I have found a 'ntdll.dll' file, but that didn't help. > ...

MFC Application has encountered a problem and needs to close. HELP
This is driving me nuts. Whenever I run my program in release configuraiton it always crashes with the above error message offering me an option to send a message to Microsoft. I have discovered it is an access violation (code 5). Whenever I run the program in debug configuration it runs OK. I have two main questions: 1 How can the program behave so differently in the two configurations? I can find no explanation of this in the help files. 2 How can I get useful information about the access violation? I cannot save the crash dump produced which the exception handler offers to send to ...