Click here to Skip to main content
14,846,874 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questionsocket programming in forms app Pin
Cbrown33010-Sep-13 5:28
MemberCbrown33010-Sep-13 5:28 
AnswerRe: socket programming in forms app Pin
Richard MacCutchan15-Sep-13 21:24
mveRichard MacCutchan15-Sep-13 21:24 
Questioncan't get out of loop Pin
Member 1021996721-Aug-13 16:31
MemberMember 1021996721-Aug-13 16:31 
AnswerRe: can't get out of loop Pin
Richard MacCutchan21-Aug-13 21:30
mveRichard MacCutchan21-Aug-13 21:30 
QuestionIndirect assembly dependency issue Pin
Member 1016773115-Aug-13 5:40
MemberMember 1016773115-Aug-13 5:40 
AnswerRe: Indirect assembly dependency issue Pin
Pete O'Hanlon15-Aug-13 5:54
mvePete O'Hanlon15-Aug-13 5:54 
GeneralRe: Indirect assembly dependency issue Pin
John Schroedl15-Aug-13 7:23
professionalJohn Schroedl15-Aug-13 7:23 
Questionunhandled exception of type 'System.Runtime.InteropServices.SEHException' when trying to call C# dll from MFC Pin
PrasadHPShenoy5-Aug-13 23:04
MemberPrasadHPShenoy5-Aug-13 23:04 
Am getting 'An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in CallingExe.exe

Additional information: External component has thrown an exception.' error when i try to call a dll generated with C# in my MFC code.
Have successfully generated the .tlb file using RegAsm.exe and also installed it using gacutil. both these were successfull. Have attached my code for reference.

MFC Code:

#using <mscorlib.dll>
#import "C:\\Programing\\Projects\\Visual Basic\\native calls\\vchash\\ManagedDLL\\ManagedDLL\\bin\\Debug\\ManagedDLL.tlb" raw_interfaces_only

using namespace ManagedDLL;
void CCallingExeDlg::OnBnClickedOk()
{
    HRESULT hr = CoInitialize(NULL);
    ICalculatorPtr pICalc(__uuidof(ManagedClass));
}


C# Code:
using System;
using System.Runtime.InteropServices;

namespace ManagedDLL
{
    [ComVisible(true)]
    [Guid("1A9ECDD2-24FC-4f9b-97BF-BF170B16CB38")]
    // Interface declaration.
    public interface ICalculator
    {
        int Add(int Number1, int Number2);
    };
    [ComVisible(true)]
    [Guid("9CEFF09D-7140-451e-A85E-2341A7C978FA")]
    // Interface implementation.
    public class ManagedClass : ICalculator
    {
        public int Add(int Number1, int Number2)
        {
            return Number1 + Number2;
        }
    }
}

Am getting error in 'ICalculatorPtr pICalc(__uuidof(ManagedClass));' line of MFC code
Am stuck with this from past two weeks.
Any help would be greatly appreciated.
Dhamu

AnswerRe: unhandled exception of type 'System.Runtime.InteropServices.SEHException' when trying to call C# dll from MFC Pin
Richard MacCutchan14-Aug-13 21:15
mveRichard MacCutchan14-Aug-13 21:15 
Questiongot error while writing into excel file Pin
kumsudheer5-Aug-13 2:28
Memberkumsudheer5-Aug-13 2:28 
AnswerRe: got error while writing into excel file Pin
David Knechtges5-Aug-13 3:45
MemberDavid Knechtges5-Aug-13 3:45 
GeneralRe: got error while writing into excel file Pin
kumsudheer5-Aug-13 19:36
Memberkumsudheer5-Aug-13 19:36 
QuestionHow to add existing project in VS6.0 Pin
Shyam Kodase30-Jul-13 23:02
MemberShyam Kodase30-Jul-13 23:02 
AnswerRe: How to add existing project in VS6.0 Pin
NotPolitcallyCorrect30-Jul-13 23:43
MemberNotPolitcallyCorrect30-Jul-13 23:43 
AnswerRe: How to add existing project in VS6.0 Pin
Richard MacCutchan30-Jul-13 23:47
mveRichard MacCutchan30-Jul-13 23:47 
QuestionPointer in Managed Code Pin
NAVALMAN30-Jul-13 2:59
professionalNAVALMAN30-Jul-13 2:59 
AnswerRe: Pointer in Managed Code Pin
Richard MacCutchan30-Jul-13 5:54
mveRichard MacCutchan30-Jul-13 5:54 
GeneralRe: Pointer in Managed Code Pin
NAVALMAN31-Jul-13 22:54
professionalNAVALMAN31-Jul-13 22:54 
GeneralRe: Pointer in Managed Code Pin
Richard MacCutchan1-Aug-13 2:51
mveRichard MacCutchan1-Aug-13 2:51 
AnswerRe: Pointer in Managed Code Pin
jschell1-Aug-13 11:32
Memberjschell1-Aug-13 11:32 
GeneralRe: Pointer in Managed Code Pin
NAVALMAN1-Aug-13 19:30
professionalNAVALMAN1-Aug-13 19:30 
QuestionPreserving polymorphism across the managed/unmanaged boundary Pin
Member 1016773122-Jul-13 11:48
MemberMember 1016773122-Jul-13 11:48 
AnswerRe: Preserving polymorphism across the managed/unmanaged boundary Pin
David Knechtges23-Jul-13 3:25
MemberDavid Knechtges23-Jul-13 3:25 
AnswerRe: Preserving polymorphism across the managed/unmanaged boundary Pin
John Schroedl23-Jul-13 8:27
professionalJohn Schroedl23-Jul-13 8:27 
AnswerRe: Compiler Error Pin
Richard MacCutchan22-Jul-13 21:13
mveRichard MacCutchan22-Jul-13 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.