Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2006

Tip: Looking for answers? Try searching our database.

Invoking C# object from C++ DLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel F. Devine - 13 Apr 2006 22:50 GMT
I wish to provide a C++ DLL interface for non-framework clients to access a
C# DLL - is this possible?  I have had some limited success by using a pimpl
idiom to cross from unmanaged to managed - but anything more than a simple
message output yields an exception.  I cannot debug past the C++/C#
boundary.

I have put this question to Microsoft support and while they tell me that I
SHOULD be able to do this and I SHOULD be able to debug across the boundary
they cannot tell me how to do it although they have had my sample code for
two days now.  Can anyone shed some light on this?

Thanks for any help.
Dmytro Lapshyn [MVP] - 14 Apr 2006 13:56 GMT
Hi Daniel,

Consider making your C# class library COM-visible. I think all mainstream
programming languages are able to consume COM nowadays, and it's fairly easy
to do since COM visibility is supported by .NET Framework and SDK tools.

>I wish to provide a C++ DLL interface for non-framework clients to access a
> C# DLL - is this possible?  I have had some limited success by using a
[quoted text clipped - 9 lines]
>
> Thanks for any help.
Daniel F. Devine - 14 Apr 2006 14:48 GMT
> Hi Daniel,
>
[quoted text clipped - 18 lines]
>>
>> Thanks for any help.

Thanks for the reply.  Actually I can do this with COM but was looking for a
solution that avoided COM for deployment reasons.  I am not sure if this can
be done BUT Microsoft Tech support ensures me that it can be done although
to date they have not shown me why my sample stub blows up with an
EEFileLoadException.  There seems to be virtually no documentation on this
error that I can find.  If it can't be done that would be most helpful to
know as I would stiop wasting my time and look for another solution.
Dmytro Lapshyn [MVP] - 14 Apr 2006 15:59 GMT
Can you please post your code that gives you the EEFileLoadException here?

> Thanks for the reply.  Actually I can do this with COM but was looking for
> a solution that avoided COM for deployment reasons.  I am not sure if this
[quoted text clipped - 4 lines]
> helpful to know as I would stiop wasting my time and look for another
> solution.
Daniel F. Devine - 14 Apr 2006 16:25 GMT
> Can you please post your code that gives you the EEFileLoadException here?
>
[quoted text clipped - 6 lines]
>> would be most helpful to know as I would stiop wasting my time and look
>> for another solution.

Sure - but first I'll psedocode it because even as a small testbed it is
somewhat complex

C++ DLL interface exposes invokeCrystal

               invokeCrystal is in a C++ compilation unit - pure C++

                                 ManagedReport *mr  =  new ManagedReport();

                                  mr->ViewReport();

                                 delete mr;

ManagedReport object is defined in a separate compilation unit compiled with
/clr

                                ViewReport()
                             {
                                ManagedCrystalObject ^mo = gcnew
ManagedCrystalObject
                             }

In the C# class ManagedCrystalObject a Winform hosting the Crystal Viewer is
to be displayed.

In the invocation of ViewReport I get the exception :  EEFileLoadException
Also to note is that I cannot step into the managed code unit from the
unmanged code unit.

If you still need the code I will upload it.

Thanks for your responses
Dmytro Lapshyn [MVP] - 17 Apr 2006 11:08 GMT
Now I see you are using the IJW technology, and I don't have any experience
with this one :-(
What I can tell is: The EEFileLoadException error means that the CLR could
locate the assembly with the managed class, but couldn't load it for some
reason.

This link might help:

http://doc.trolltech.com/3.3/activeqt-dotnet.html

Also, do a Google search on IJW.

>> Can you please post your code that gives you the EEFileLoadException
>> here?
[quoted text clipped - 41 lines]
>
> Thanks for your responses
Daniel F. Devine - 17 Apr 2006 20:07 GMT
> Now I see you are using the IJW technology, and I don't have any
> experience with this one :-(
[quoted text clipped - 54 lines]
>>
>> Thanks for your responses

Thanks-

I am discovering that EEFileLoadException ALSO occurs when ANY error occurs
in the Managed class - a managed client debug session will yield the proper
exception in the Managed class - but when called from the Unmanaged class -
blindly, I cannot debug into it -any exception will trigger the
EEFileLoadException in the C++ class.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.