Hi all,
I'm trying to use a .net api from unmanaged MFC code.
I'm trying to use ClrCreateManagedInstance api, but as shown above,
my
var pDisp equals null before the ClrCreateManagedInstance call.
Can you correct my code ? (Or any other way to do that ?)
#include "mscoree.h"
#pragma comment (lib, "mscoree.lib")
CComPtr<IDispatchpDisp;
HRESULT hr = S_OK;
hr = ClrCreateManagedInstance(L"System.Windows.Forms.Me ssageBox,
System.Windows.Forms, Version=2.0.50727.42, Culture=neutral,
PublicKeyToken=b77a5c561934e089",IID_IDispatch, (void**)&pDisp);
Thansk in advance for your help,
Best,
S. 4 3163
On 13 avr, 15:08, timor.su...@gmail.com wrote:
Hi all,
I'm trying to use a .net api from unmanaged MFC code.
I'm trying to use ClrCreateManagedInstance api, but as shown above,
my
var pDisp equals null before the ClrCreateManagedInstance call.
Can you correct my code ? (Or any other way to do that ?)
#include "mscoree.h"
#pragma comment (lib, "mscoree.lib")
CComPtr<IDispatchpDisp;
HRESULT hr = S_OK;
hr = ClrCreateManagedInstance(L"System.Windows.Forms.Me ssageBox,
System.Windows.Forms, Version=2.0.50727.42, Culture=neutral,
PublicKeyToken=b77a5c561934e089",IID_IDispatch, (void**)&pDisp);
Thansk in advance for your help,
Best,
S.
Let me add some information, if i try with System.Random that is part
of mscorlib
this :
hr =
ClrCreateManagedInstance(L"System.Random,mscorlib, PublicKeyToken=b03f5f7f11d50a3a",
IID_IManagedObject, (void**)&pWrap);
is working :)
but if i try with my own assembly :
hr = ClrCreateManagedInstance(L"MyAssembly.Class1,MyAss embly",
IID_IDispatch, (void**)&pDisp);
i have the hresult : E_NOINTERFACE value
Nb : my assembly isn't strong signed
Thanks for your answer
<ti*********@gmail.comwrote in message
news:11*********************@e65g2000hsc.googlegro ups.com...
On 13 avr, 15:08, timor.su...@gmail.com wrote:
>Hi all,
I'm trying to use a .net api from unmanaged MFC code.
I'm trying to use ClrCreateManagedInstance api, but as shown above, my var pDisp equals null before the ClrCreateManagedInstance call.
Can you correct my code ? (Or any other way to do that ?)
#include "mscoree.h" #pragma comment (lib, "mscoree.lib")
CComPtr<IDispatchpDisp; HRESULT hr = S_OK; hr = ClrCreateManagedInstance(L"System.Windows.Forms.Me ssageBox, System.Windows.Forms, Version=2.0.50727.42, Culture=neutral, PublicKeyToken=b77a5c561934e089",IID_IDispatch, (void**)&pDisp);
Thansk in advance for your help,
Best,
S.
Let me add some information, if i try with System.Random that is part
of mscorlib
this :
hr =
ClrCreateManagedInstance(L"System.Random,mscorlib, PublicKeyToken=b03f5f7f11d50a3a",
IID_IManagedObject, (void**)&pWrap);
is working :)
but if i try with my own assembly :
hr = ClrCreateManagedInstance(L"MyAssembly.Class1,MyAss embly",
IID_IDispatch, (void**)&pDisp);
What compiler version is your assembly built with? Did you call
CorBindToRuntimeEx? If not, the documentation indicates that the .NET 1.0
runtime gets loaded and you won't be able to load newer assemblies.
>
i have the hresult : E_NOINTERFACE value
Nb : my assembly isn't strong signed
Thanks for your answer
<ti*********@gmail.comwrote in message
news:11*********************@e65g2000hsc.googlegro ups.com...
On 13 avr, 15:08, timor.su...@gmail.com wrote:
>Hi all,
I'm trying to use a .net api from unmanaged MFC code.
I'm trying to use ClrCreateManagedInstance api, but as shown above, my var pDisp equals null before the ClrCreateManagedInstance call.
Can you correct my code ? (Or any other way to do that ?)
#include "mscoree.h" #pragma comment (lib, "mscoree.lib")
CComPtr<IDispatchpDisp; HRESULT hr = S_OK; hr = ClrCreateManagedInstance(L"System.Windows.Forms.Me ssageBox, System.Windows.Forms, Version=2.0.50727.42, Culture=neutral, PublicKeyToken=b77a5c561934e089",IID_IDispatch, (void**)&pDisp);
Thansk in advance for your help,
Best,
S.
Let me add some information, if i try with System.Random that is part
of mscorlib
this :
hr =
ClrCreateManagedInstance(L"System.Random,mscorlib, PublicKeyToken=b03f5f7f11d50a3a",
IID_IManagedObject, (void**)&pWrap);
is working :)
but if i try with my own assembly :
hr = ClrCreateManagedInstance(L"MyAssembly.Class1,MyAss embly",
IID_IDispatch, (void**)&pDisp);
Maybe ClrCreateManagedInstance doesn't load the assembly for you. Try
loading System.Reflection.Assembly from mscorlib, and call Assembly.Load.
See http://msdn2.microsoft.com/en-us/lib...ft(VS.80).aspx
>
i have the hresult : E_NOINTERFACE value
Have you set the COMVisibleAttribute on your class?
>
Nb : my assembly isn't strong signed
Thanks for your answer
<ti*********@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
Hi all,
I'm trying to use a .net api from unmanaged MFC code.
I'm trying to use ClrCreateManagedInstance api, but as shown above,
my
var pDisp equals null before the ClrCreateManagedInstance call.
Can you correct my code ? (Or any other way to do that ?)
#include "mscoree.h"
#pragma comment (lib, "mscoree.lib")
CComPtr<IDispatchpDisp;
HRESULT hr = S_OK;
hr = ClrCreateManagedInstance(L"System.Windows.Forms.Me ssageBox,
System.Windows.Forms, Version=2.0.50727.42, Culture=neutral,
PublicKeyToken=b77a5c561934e089",IID_IDispatch, (void**)&pDisp);
Thansk in advance for your help,
Best,
S.
You can't instantiate S.W.F.MessageBox, because it has a private constructor
:-)
Marcus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jason mazzotta |
last post by:
Hi,
I'm rather new to both MySQL and PHP. I've been trying to use PHP to
write to a MySQL database. I call mysql_pconnect to get a database
connection, but then when I call mysql_db_select, I get...
|
by: Jeff |
last post by:
Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
example if I type HostName.domain.com in my browser I want to return it
exactly as it appears in the location part of the browser...
|
by: Dave |
last post by:
I know that Remoting requires a host application on the
server. Is it possible to use COM+ as the host? If so,
where can a good example be found?
|
by: Tim |
last post by:
I am in the process of moving a site from one hosting company to another.
This site is fairly large, with hundreds of asp files, each with multiple
"include" statements.
The new host has a...
|
by: ytrewq |
last post by:
Should dynamic ("expando") properties be restricted to native and
user-defined objects? Or should host objects - such as references to
the browser or a plug-in or to the document and its elements -...
| |
by: Jeff |
last post by:
I have an ASP.NET web page accessing a SQL database. I've used VS to build
the app and stored it in the eNPTest02 directory of my localhost on my
development machine. The database is on the web. ...
|
by: Brian Henry |
last post by:
is there a way to get the host name of someone? like mine is
68-23-123-123-pitt-pa.adelphia.net?
Request.UserHostName doesn't seem to return the host name like it states in
the documentation,...
|
by: zxo102 |
last post by:
Hi,
I am doing a small project using socket server and thread in python.
This is first time for me to use socket and thread things.
Here is my case. I have 20 socket clients. Each client send a...
|
by: misha |
last post by:
Hello.
I was wandering if someone could explain to me (or point to some
manual) the process of mapping the addresses of host variables by DB2.
Especially I would like to know when DB2 decides to...
|
by: Krice |
last post by:
There is a component class inside the host class:
class Host
{
Component *c;
....
In some cases Component needs to call the host and
I guess the only way is that you pass the host for it:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |