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
779 Views

Similar Articles

[PageSpeed] 2

Reply:

Similar Artilces:

Toolbar 256 colors support in MFC
I am developing SDI base application (using MFC) in vs2k5. I want to add toolbar with the support of 256 colors, but when I add the new toolbar in Resource, its support 16 colors. Can you guide me the way to add toolbar supported with 256 colors? Regards, -aims www.codeproject.com/docking/truecolortoolbar.asp "Mohammad Omer" <momer114@gmail.com> wrote in message news:1169031749.896362.82460@v45g2000cwv.googlegroups.com... >I am developing SDI base application (using MFC) in vs2k5. I want to > add toolbar with the support of 256 colors, but when I add the new > to...

MFC Migration Kit still exists?
Does it still exist? Can I convert MSDN Win32 samples to MFC base? REFERENCE: --------------- Microsoft Visual C++/Microsoft Foundation Classes (MFC) Frequently Asked Questions Michael Pickens (mfc_faq@stingray.com) Version 5.6 Last updated: 7/14/98 ...says that: 13.5.6. What's the best way to convert my C Windows App to MFC? Microsoft and Symantec have jointly developed a tool that helps you make the move from a C Windows application to MFC. It's called the MFC migration kit. You can find it on the MSVC 2.x CD-ROM in the MFCKIT directory. The kit is also available from the Microsof...

MFC and SOAP #import problem
This is a stange thing I have come across, I have developed a project using SOAP and initially this project worked fine until i had to change some hard coded values and then i got errors I havent found a solution to, btw I havent really used soap with mfc before. error C4772: #import referenced a missing type library (didnt happen before, error not found in vc help, dll is mssoap30.dll) and lots of error C2440: return conversion errors because of the __missing_type__ subsitutions. Another further point when tryin to deploy the release version using a setup installer, it wont register mssoap...

global function for calling from the main to the dll
What is the right way to define a global function for calling from the main to the dll. I use a regular dll function (with MFC) which must return BOOL . I use the following definition: extern "C" BOOL __declspec(dllexport) CapturStartStop( CString WavFileName, unsigned SamplesPerSec, unsigned SampleLength, BOOL StartOrStop) Is that correct? regards Vinter "Vinter" <Vinter@malloc.com> wrote in message news:uvOEZJ#GFHA.1392@TK2MSFTNGP10.phx.gbl... > extern "C" BOOL __declspec(dllexport) CapturStartStop( CString > WavFileName, > unsign...

Is it Possible to call MFC dll from Win32 DLL?
Hi, I would like to know is there any way that i can use classes present in MFC Regular DLL to be accessible within my win32 DLL Yes. Theres nothing special about it. Expose the methods from your DLL and use it the way you normally would. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Schwang" <schwang_sam@yahoo.com> wrote in message news:eiD9ls5fEHA.2028@tk2msftngp13.phx.gbl... > Hi, > I would like to know is there any way that i can use classes present in MFC > Regular DLL to be accessible within my win32 DLL > > ...

Odd COleDropTarget behaviour in MFC MDI application
I have an MFC MDI app. For discussion purposes, we can assume it has a Main Frame, an MDIChild window, and a 'floating' tool window. (The tool window has the following style flags set: DS_SETFONT, DS_SETFOREGROUND, DS_FIXEDSYS, WS_POPUP, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_EX_TOOLWINDOW.) I derived a drag-handler class from COleDropTarget, one for the Main Frame and one for the tool window. I've overridden the OnDragEnter(), OnDragLeave(), OnDragOver(), and OnDrop() methods. I've declared one of these as a member/field in each of the Main Frame and tool window clas...

Any help using Crystal Report in MFC or anything ....
to create a report Best regard finalyvn There are several MFC sample apps on the CR website. "finalyvn" <trananhtai@hotmail.com> wrote in message news:eu6WwwQmDHA.3024@tk2msftngp13.phx.gbl... > to create a report > Best regard > finalyvn > > There is a printing support in latest version of HtmLayout (http://htmlayout.com). It is pretty easy to generate HTML programmaticly and use HtmLayout for viewing and printing your reports. Professional version of HtmLayout includes also methods for "HTML paginating". Never been easier. Andrew Fedoniouk. ...

Custom dll Request
I'm looking for someone to write a dll. I want my RMS POS to present a 3-choice dialog box at the beginning of every transaction. Button #1 - Sale/Return - would simply close the dialog and allow the cashier to ring up a sale or return. Buttons #2 & #3 - Delivery Order & Special Order - would trigger macros. An <ESC> keystroke would be handled the same as Button #1. The default should be Delivery Order. If you've got the time, skills and inclination to provide something like this, contact me and we can discuss terms... Tom -- The worst words in business: "...

Is it possible to make a MFC dialog In-Proc when called from and ATL COM from VB?
Hi, I have an ATL COM object that contains a MFC Dialog. One method of my ATL must allow me to display the dialog in modal (DoModal). I use this ATL COM in my VB app. I want to call the ATL Method from my VB app to make the MFC dialog appear in modal. The problem is : The dialog appears, but is not in-proc. So I receive a message each time I click on the parent window (not a beep sound, but really a message). Is it possible at all to make my dialog appear in-proc or it is a limitation of the COM (or VB) usage? Someone talked to me about In-Proc server, but I really don't understand ...

CDO error when calling Exchange server
I am running a utility called CDO Verify to test connections to my mailboxes from a server running Outlook2000 with CDO. Usually when the mailbox alias is wrong, I get LegacyDN = unknown. But sometime after a 5.5 - 2000 migration (not sure if that was it though) I am getting a nasty reply when running it: A COM exception occurred while verifying a mailbox's distinguished name.| |Source: Collaboration Data Objects| |Description: Network problems are preventing connection to the Microsoft Exchange Server computer. Contact your system administrator if this condition persists. [Microsoft Exch...

ANN: C# Online.NET en Espa�ol
PARA SER PUBLICADO INMEDIATAMENTE La primera referencia en Espa�ol en l�nea basada en la tecnolog�a Wiki sobre C# y .NET se encuentra en C# Online.NET Dallas, TX � Un nuevo concepto en referencias en l�nea para los lenguajes de programaci�n de Microsoft .NET est� siendo estrenado por primera vez por C# Online.NET�una nueva referencia en l�nea basada en la tecnolog�a wiki. C# Online.NET ofrece documentaci�n, tutoriales, y ejemplos de c�digo para los lenguajes .NET empezando con C#. "Comparado con Java," dice Will Wagers, fundador de C# Online.NET, "hay una escasez de ayuda en l...

Phone Call Parameter
Hi I have one simple Question. Is it possibel to genrate Links that fill my Phone Call Form. For example something like this http://crm/activities/phone/edit.aspx?Subject="Test"&PhoneNumber="123456789" My Problem ist I need Form that contains certain Information, but the user not always create this activities. So my Application has to check if, the user change something. When he change nothing i had to remove the activity, else i think i get a huge amount of activities that nobody need. Thank you for help ...

Assembly items?? what gives?
Howdy, assembly items seem incredibly limited, you can't print labels, you cant report on the items or generate a price list, and the help file refers to menus that don't exist (ie "When you go to the database menu and click on the item assemblies, you should see the new item in the item assemblies window") This is Bunk All I want is to be able to package skis and bindings, print a price list, and see some reporting about the package sales vs. item sales. LAME, LAME, and BUNK-- Jon Kahn Confluence Kayaks You are not alone. Search this group for similar posts an...

Calling the Immediate Window
I handle dozens of DBs for various offices in my organization. The biggest hurdle I face is when I have to update data for these back-ends, someone somewhere invariably has the DB open. I have a Master DB that I use to automate all the updating I have to do and have incorporated the "WhoIsInTheDatabaseLockFile" procedure to find the Machine Names of these users (none of these DBs use user-level security - I inherited them as is). I then have some code to open a cmd window and run the psloggedon.exe from SysInternals (now part of Microsoft) to get the actual username of the per...

Internationalization
I'm posting this in the MFC newsgroup because the application I'm working with is an MFC MDI one so apologies if it should be elsewhere. When I set the WS_EX_LAYOUTRTL in the CMainFrame PreCreateWindow function the window in mirrored as expected, as is the toolbar. I would like to stop the bitmaps on the toolbar getting reflected and have found articles on the MSDN site that talk about setting the LAYOUT_BITMAPORIENTATIONPRESERVED flag on the current device context. This may very well fix the problem but I don't know where I should be setting this flag, I have tried to do t...

Outlook, Redemption and C++
Does any have some sample C++ code that will make Redemption work or the sample Extended Mapi to get around the Outlook Send popup dialog? Thanks Tom G. ...

criteria 1(a,b,c), criteria 2 (T,F)
in cell A1: from a dropdown list - choose a, b or c in cell B1: from a dropdown list - true or false in cell C1: Results will depend on A1 and B1 - give 1, 2 or 3 You don't say how so a guess =IF(AND(A1="a",B1=TRUE),1,IF(AND(A1="b",B1=FALSE,2,3)) -- HTH Bob Phillips "Kikkoman" <Kikkoman@discussions.microsoft.com> wrote in message news:749D1904-D3CF-41C3-97CB-54DB9AB1EA05@microsoft.com... > in cell A1: from a dropdown list - choose a, b or c > in cell B1: from a dropdown list - true or false > in cell C1: Results will depend on A1 and B1 -...

Client calls a web method with missing parameter
Hi , My web service method which takes a string input parameter and returns a string was called by an application with a blank input parameter value. Client gets http 500 error instead of xml file with an error code and description. how do I trap this type of errors. My web service supports http get/post and soap protocols. Any help is appreciated. ...

OnClose() is not called!
I have a Dialog-based application and when I press the escape key OnClose() is not calledQ But when I click on the close button it works. What message is fired when I close the dialog with escape? -- cody [Freeware, Games and Humor] www.deutronium.de.vu || www.deutronium.tk codymanix In a dialog box, the escape key generates the WM_KEYDOWN with a WPARAM of 0x1b (ASCII code for ESC key). Somewhere in the internals of windows message processing (most likely IsDialogMessage handler) the ESC key is changed into a WM_COMMAND message from control with DLG ID of 2 (same as IDCANCEL). The MFC...

NetworkInformationException when calling GetAllNetworkInterfaces from a windows service
Hi News Group, I'm writing some code that discovers network interfaces and devices. It works correct when executed in a console application (managed) but it fails when executed from a managed windows service. The service is configured to run as local service so I guess that is enough permission to perform the operations. Does anybody know how to discover network info from a windows service and why my code does fail ??? See stack for info. Even though it's managed code I know that the underlying function is pure win api and the source of the error. System.Ne...

MFC & Guis
As we know MFC makes ugly guis. Is there a way to beauitfy mfc applications so that they look more professional? Maybe skinning tools? Third party gui librarieis? Thanks. Jessica Out of interest, can you link to something you regard as a good looking GUI, just for reference. "Jessica Weiner" <jessica@gmail.com> wrote in message news:jo0Bf.18723$dW3.8663@newssvr21.news.prodigy.com... > As we know MFC makes ugly guis. Is there a way to beauitfy mfc > applications so that they look more professional? Maybe skinning tools? > Third party gui librarieis? > &g...

is it possible to see an incoming phone call id in an excel cell?.
is it possible to see an incoming phone call id in an excel cell?... i ve caller id display installed on my phone line i can see the caller id on bt's little box also i ve tried few programs that gets caller id using modem info. but all these dont (cant) connect caller id infoin an excel cell which then retrieves info about customer who ownes the number. thanks ray Hi so you want a CTI solution? Never did this with Excel but as so many things it should be possible :-) - First it depends on your telephone system. What telephone solution are you using - If this is a professional telephon...

Passing 2 params from MFC/ActiveX to IE/Javascript engine
The code below works fine when I pass only one parameter to the Javascript function that sits on the currently displayed page in IE. However if I try to pass 2 parameters (as shown below), the 1st argument (rgvarg[1] ) is the only one that makes it to the Javascript function in IE. Same result if I swap those two arguments, only the first arg (rgvarg[1] ) survives. So I can pass the int, or the BSTR, but not both. Is than an IE-specific restriction? I haven't seen any generic COM postings on such an issue. Thanks Eric MS VC++ (2003) code: LRESULT CMyActiveXCtrl::OnReceivedMessage(WP...

displaying colors in an mfc application
Hi everyone, I'm working on an MFC application. The application is a treeview in which are represented some objects (persons, roles....). I have declared some bitmaps in the visual project to represent these objects. My problem is that some colors of the bitmaps are not displayed. I guess there is a palette problem or something like that. Does anybody have an idea of what the problem is? Thanks a lot for your help.... Fred Try using ILC_COLOR24 | ILC_MASK when you create your imagelist. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "fred" <fred@laposte.net> wrot...

Detect host of script calling a WSC
Hello, I have hundred of VBScripts and JScript scripts calling one WSC. The calling scripts are started with CScript or WScript as required in the current environment. The WSC starts helper VBScripts using shell.Run("scriptname.vbs"). Until WSH 5.6 these Scripts have been started with the same scripting host, that has been used from the outer scripts. Starting with WSH 5.7 the shell.Run() behaves different. It always use WScript as a host. I can not change the outer VBScripts for several reason, so I can't add a property to the WSC to pass the calling WScript...