.NETGURU
Calling a .NET assembly through PURE UNMANAGED code
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.clr.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Nadav (VIP)
Hi,

I am tiring to load an assembly from memory ( e.g.
System.Reflection.Assembly.Load( byte[] ), this works fine through managed
and mixed code. NOW, I am tiring to achieve the same thing through PURE
UNMANAGED code, I can't use com or com interop, does some one have an idea
how to achieve what was just described? ( through unmanaged code )
Is it possible to call a managed assembly through PURE UNMANAGED code? how?
( if at-all )

Again, I can't use COM so COM Interop will not satisfy my needs

--
Nadav
http://www.ddevel.com
Reply to this message...
 
    
Stu Smith
"Nadav" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Why do you want to do this? The only way I can think of is to use a
mixed-mode bridging DLL.

[Original message clipped]

Reply to this message...
 
    
Brian Tyler
With a lot of work, sure - you will need to host the CLR.

The problem is that to call any managed code from unmanaged code will
require a CLR to be running in that process. If you were to expose your
assembly via COM then the COM runtime system handles it for you. Since you
say that you cannot do this, it is up to you to create an instance of the
CLR and have it load up the assembly.

Out of curiosity, why can't your unmanaged application make COM calls?

"Stu Smith" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Stu Smith
"Brian Tyler" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> With a lot of work, sure - you will need to host the CLR.

No need to host the CLR, MC++ will do this for you. If you make a mixed-mode
DLL (using MC++), you can call .NET (obviously), but if you present an
entirely unmanaged C++ interface (using the pimpl idiom for example), then
you can call that from unmanaged C++.

ie a bit like this:

// UnmanagedInterface.h

class InternalDetails; // Keep it anonymous

class UnmanagedInterface
{
public:
void DoSomething();
private:
InternalDetails *m_pInternalDetails;
}

---

// UnmanagedInterface.cpp

#include "InternalDetails.h"

void UnmanagedInterface::DoSomething()
{
m_pInternalDetails->DoSomething();
}

---

// InternalDetails.h / .cpp

class InternalDetails
{
public:
void DoSomething()
{
m_pManagedClass->Whatever();
}

private:
gcroot<ManagedClass *> m_pManagedClass;
}

Stu

[Original message clipped]

Reply to this message...
 
    
Brian Tyler
I thought that only worked if the EXE was made via VC++.NET. So if I have a
standard, old style C++ EXE and use LoadLibrary to bring in a VC++.NET
mix-mode dll - it will automatically start and initialize the CLR?

Brian

"Stu Smith" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Stu Smith
"Brian Tyler" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
> I thought that only worked if the EXE was made via VC++.NET. So if I have
a
[Original message clipped]

Hmmm.... I don't know. I'd hope so, but without testing I can't be sure.

OP: Nadav: has any of this been of any use, or are we barking up the wrong
tree?

[Original message clipped]

Reply to this message...
 
    
Ronald Laeremans [MSFT] (VIP)
Yes, it will. It has nothing to do with the calling application.

Ronald Laeremans
Visual C++ team

"Stu Smith" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Reflection.Assembly




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification