|
List Info
Thread: load a .NET assembly from a Delphi win 32 application without COM
|
|
| load a .NET assembly from a Delphi win
32 application without COM |

|
2006-04-19 08:14:52 |
|
Hello,
Is there a way to load a .NET assembly from a Delphi win 32 application without using COM?
I've found things like MSCOREE.DLL, ClrCreateManagedInstance and CorBindToRuntimeEx, but i can't put them together to get them working.
This is what i've got so far:
unit Unit3;
interface
type
InxInterface = Pointer;
TClrCreateManagedInstance = function(aTypeName: PWideChar; const aInterface: TGUID; out aObject):
HRESULT; stdcall;
function LoadManagedClass(aClassName, anAssemblyName: ShortString; const aInterface: TGUID): InxInterface; stdcall; Export;
implementation
uses
sysutils, stdctrls, windows, Dialogs;
function LoadManagedClass(aClassName, anAssemblyName: ShortString; const
aInterface: TGUID): InxInterface; stdcall; export;
var
netClass: WideString;
assembly: Integer;
ClrCreateManagedInstance: TClrCreateManagedInstance;
dllInst: HINST;
begin
result := nil;
assembly := -1;
anAssemblyName := ExtractFileName(anAssemblyName);
netclass := aClassName + ', ' + anAssemblyName;
dllInst := LoadLibrary('mscoree.dll');
if dllInst <> 0 then
begin
//GetProcAddress(dllInst, 'CorBindToRuntimeEx')
ClrCreateManagedInstance := TClrCreateManagedInstance(GetProcAddress(dllInst, 'ClrCreateManagedInstance'));
{ the dllInst does return a valid value
GetProcAddress(dllInst, 'ClrCreateManagedInstance') does return nil
}
if assigned(ClrCreateManagedInstance) then
assembly := ClrCreateManagedInstance(PWideChar(netclass), aInterface, Result);
end;
if assembly <> 0 then
end;
end.
So the dll is loadeds, but 'ClrCreateManagedInstance' is noit found.
Any suggestions, or even better a sample code would be appreciated.
Regards
Andries
---------------------------------
Blab-away for as little as 1¢/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice.
[Non-text portions of this message have been removed]
|
| load a .NET assembly from a Delphi win
32 application without COM |

|
2006-04-19 12:06:21 |
|
Hi Andries!
I m also looking for same.
I want to use .net assembly in delphi for win32 application.
Do you have any info on this topic to share.
I m doing this by creating c# dll,provide strong name, register this assembly and the created tlb of it. and using that tlb.
it goes ok but the problem is i can instantiate object of my c# class, access method,
but while running it gives an Access violation error.
can u help me to get rid of this problem.
Thanks
with regards
Bijal
Andries Bos <andriesbos yahoo.com> wrote:
Hello,
Is there a way to load a .NET assembly from a Delphi win 32 application without using COM?
I've found things like MSCOREE.DLL, ClrCreateManagedInstance and CorBindToRuntimeEx, but i can't put them together to get them working.
This is what i've got so far:
unit Unit3;
interface
type
InxInterface = Pointer;
TClrCreateManagedInstance = function(aTypeName: PWideChar; const aInterface: TGUID; out aObject):
HRESULT; stdcall;
function LoadManagedClass(aClassName, anAssemblyName: ShortString; const aInterface: TGUID): InxInterface; stdcall; Export;
implementation
uses
sysutils, stdctrls, windows, Dialogs;
function LoadManagedClass(aClassName, anAssemblyName: ShortString; const
aInterface: TGUID): InxInterface; stdcall; export;
var
netClass: WideString;
assembly: Integer;
ClrCreateManagedInstance: TClrCreateManagedInstance;
dllInst: HINST;
begin
result := nil;
assembly := -1;
anAssemblyName := ExtractFileName(anAssemblyName);
netclass := aClassName + ', ' + anAssemblyName;
dllInst := LoadLibrary('mscoree.dll');
if dllInst <> 0 then
begin
//GetProcAddress(dllInst, 'CorBindToRuntimeEx')
ClrCreateManagedInstance := TClrCreateManagedInstance(GetProcAddress(dllInst, 'ClrCreateManagedInstance'));
{ the dllInst does return a valid value
GetProcAddress(dllInst, 'ClrCreateManagedInstance') does return nil
}
if assigned(ClrCreateManagedInstance) then
assembly := ClrCreateManagedInstance(PWideChar(netclass), aInterface, Result);
end;
if assembly <> 0 then
end;
end.
So the dll is loadeds, but 'ClrCreateManagedInstance' is noit found.
Any suggestions, or even better a sample code would be appreciated.
Regards
Andries
---------------------------------
Blab-away for as little as 1¢/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice.
[Non-text portions of this message have been removed]
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: delphi-en-unsubscribe@yahoogroups.com
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "delphi-en" on the web.
To unsubscribe from this group, send an email to:
delphi-en-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
[Non-text portions of this message have been removed]
|
[1-2]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|