473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C# Dll Question

I understand that C# does not generate dll's that can be called from other
application development platforms. So now I have to find another way to
write a client app that can be utilized within another environment and am
thinking about COM. Can anyone point me to a tutorial or advise me on where
to get started. I have a security component that use to be a dll that I
want to try rewriting in C# as a test to prove whether or not we can start
to utilize C# for some of our solutions.

Can anyone help me?

Thanks,

glenn
Nov 16 '05 #1
24 3250
"glenn" <gh******@softeksoftware.com> wrote in message
news:u1**************@TK2MSFTNGP10.phx.gbl...
I understand that C# does not generate dll's that can be called from other
application development platforms.
Huh? What exactly do you mean by "application development platforms"? If you
mean other languages, well all the .NET languages can interoperate with C#
seamlessly. If you mean things like COM applications, then C# can expose COM
interfaces (look up ComVisible). If you mean other operating systems then C#
can expose Web Services.
So now I have to find another way to
write a client app that can be utilized within another environment and am
thinking about COM. Can anyone point me to a tutorial or advise me on
where
to get started. I have a security component that use to be a dll that I
want to try rewriting in C# as a test to prove whether or not we can start
to utilize C# for some of our solutions.

Can anyone help me?

Thanks,

glenn

Nov 16 '05 #2
Any managed module written in any language will be able to use your
component (using C# or whatever). If you are asking to use a managed
component in an unmanaged envioronment, read the following in MSDN:

http://msdn.microsoft.com/library/de...alitytocom.asp

--------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #3
Well, we have been using Borland Delphi for the last 10 years. We are now
looking at the possibility of converting our application to C# and its my
job to see if this is something that can be done. In order to try to prove
my case, I wanted to rewrite a few of the dll's we have in delphi into C#
because they could be rewritten and replaced tomorrow and no one would be
the wiser. However, when I try to develop a dll in c# and then call that
dll from a delphi app, I get access violations when Delphi tries loading the
dll. Long before any functions are actually called.

I can find absolutely nothing so far to help me with this as all examples
have been between c# and c# with not even a mention that there might be
other program languages that exist.

Thanks,

glenn
"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Any managed module written in any language will be able to use your
component (using C# or whatever). If you are asking to use a managed
component in an unmanaged envioronment, read the following in MSDN:

http://msdn.microsoft.com/library/de...alitytocom.asp
--------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #4
You are jumping the gun here. I have never programmed in Borland Delphi
but I would certainly think unless they are going to support .net
framework, its unmanaged code.

That means if you write the same functionality in C#, you will need to
expose the components thru COM. However, I have no idea if Borland
Delphi can deal with a COM server. If it can, then on your existing
codebase, you will need to use COM to communicate with your newly
written C# component.

--------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #5
Ok,

Which leads to the original question. Delphi does support COM 100% as well
as DLL's but since c# does not support the old DLL processes which you seem
to have just confirmed, then COM is my only choice. So back to my original
question. How can I learn how to write a COM server in C#? I know how to
do this and have done it many times in Delphi but out of the 3000 pages of
text I have in 4 different c# books, not one single one even mentions COM.
Did Microsoft Rename the technology again? Is there somewhere I can go to
learn how to write a COM Server? I've been googling all morning and so far
have gotten no where.

Thanks,

glenn
"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
You are jumping the gun here. I have never programmed in Borland Delphi
but I would certainly think unless they are going to support .net
framework, its unmanaged code.

That means if you write the same functionality in C#, you will need to
expose the components thru COM. However, I have no idea if Borland
Delphi can deal with a COM server. If it can, then on your existing
codebase, you will need to use COM to communicate with your newly
written C# component.

--------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #6
Before you jump into this, you should make certain that if Delphi is
going to support .Net. If it is or is going to, it will be all mute
point as you can develop in C# or whatever to produce managed code and
consue it in Delphi.

If Delphi is not going to support managed code, then you will need to
write a COM server in managed code. The link I provided in my first
reply shows how to do it(ComVisible attribute).
since c# does not support the old DLL processes which you seem
to have just confirmed,


I am not what you mean here. You can call unmanaged DLLs using
interop/PInvoke in managed code(C#). That means your Delphi code
(whatever is exported by it) can be used in a managed code. If you have
a COM server in Delphi, you can use it in C#.

------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #7
I understand but you are backwards. I am trying to write a dll in C#
(managed code) and call that dll from Delphi 6 which is unmanaged. Delphi
2005 supports all the .NET stuff but our project is currently being managed
in Delphi 6 which does not.

So to recap. I want to write a dll in C# that performs a function that just
pops up a message box and says hello world. I then want to call that
function from inside my delphi application so that the message box pops up.

I'm also behind the times a little with all this managed code stuff so I'm
not sure what the differences are from what managed and unmanaged code
exactly means.

Thanks,

glenn

"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Before you jump into this, you should make certain that if Delphi is
going to support .Net. If it is or is going to, it will be all mute
point as you can develop in C# or whatever to produce managed code and
consue it in Delphi.

If Delphi is not going to support managed code, then you will need to
write a COM server in managed code. The link I provided in my first
reply shows how to do it(ComVisible attribute).
since c# does not support the old DLL processes which you seem
to have just confirmed,


I am not what you mean here. You can call unmanaged DLLs using
interop/PInvoke in managed code(C#). That means your Delphi code
(whatever is exported by it) can be used in a managed code. If you have
a COM server in Delphi, you can use it in C#.

------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #8
>I am trying to write a dll in C# (managed code) and call that dll from
Delphi 6 which is unmanaged.

What I said earlier about exposing functionality in C# thru COM still
applies. Thats because Delphi 6 is unmanaged and you need some sort of
common layer (COM in this case) between two components.
I'm also behind the times a little with all this managed code stuff so I'mnot sure what the differences are from what managed and unmanaged code exactly means.


There is a lot of difference between the two. If you have familiarity
with Java, it will be easy to migrate over.

I still believe your best bet is to use Delphi 2005 if it supports .Net
and unmangaged code in the same component. You need to find this out
before deciding about how to proceed.

---------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #9
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for COM
Interop" to "True".

Now when you build your project it will make it COM-compatible and register
it on your machine. You should now be able to reference the C# library in
your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
I understand but you are backwards. I am trying to write a dll in C#
(managed code) and call that dll from Delphi 6 which is unmanaged. Delphi
2005 supports all the .NET stuff but our project is currently being
managed
in Delphi 6 which does not.

So to recap. I want to write a dll in C# that performs a function that
just
pops up a message box and says hello world. I then want to call that
function from inside my delphi application so that the message box pops
up.

I'm also behind the times a little with all this managed code stuff so I'm
not sure what the differences are from what managed and unmanaged code
exactly means.

Thanks,

glenn

"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Before you jump into this, you should make certain that if Delphi is
going to support .Net. If it is or is going to, it will be all mute
point as you can develop in C# or whatever to produce managed code and
consue it in Delphi.

If Delphi is not going to support managed code, then you will need to
write a COM server in managed code. The link I provided in my first
reply shows how to do it(ComVisible attribute).
>since c# does not support the old DLL processes which you seem
> to have just confirmed,


I am not what you mean here. You can call unmanaged DLLs using
interop/PInvoke in managed code(C#). That means your Delphi code
(whatever is exported by it) can be used in a managed code. If you have
a COM server in Delphi, you can use it in C#.

------
Ajay Kalra
aj*******@yahoo.com


Nov 16 '05 #10
Thank you very much. That was what I was after....

glenn
"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for COM Interop" to "True".

Now when you build your project it will make it COM-compatible and register it on your machine. You should now be able to reference the C# library in
your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
I understand but you are backwards. I am trying to write a dll in C#
(managed code) and call that dll from Delphi 6 which is unmanaged. Delphi 2005 supports all the .NET stuff but our project is currently being
managed
in Delphi 6 which does not.

So to recap. I want to write a dll in C# that performs a function that
just
pops up a message box and says hello world. I then want to call that
function from inside my delphi application so that the message box pops
up.

I'm also behind the times a little with all this managed code stuff so I'm not sure what the differences are from what managed and unmanaged code
exactly means.

Thanks,

glenn

"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Before you jump into this, you should make certain that if Delphi is
going to support .Net. If it is or is going to, it will be all mute
point as you can develop in C# or whatever to produce managed code and
consue it in Delphi.

If Delphi is not going to support managed code, then you will need to
write a COM server in managed code. The link I provided in my first
reply shows how to do it(ComVisible attribute).

>since c# does not support the old DLL processes which you seem
> to have just confirmed,

I am not what you mean here. You can call unmanaged DLLs using
interop/PInvoke in managed code(C#). That means your Delphi code
(whatever is exported by it) can be used in a managed code. If you have
a COM server in Delphi, you can use it in C#.

------
Ajay Kalra
aj*******@yahoo.com



Nov 16 '05 #11
Well what do I need to add to be able to do this. When adding the change to
the assemblyinfo unit I get The type or name "ComVisible" could not be
found.

Tried from windows solution and dll solution. both same results
Thanks,

glenn
"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for COM Interop" to "True".

Now when you build your project it will make it COM-compatible and register it on your machine. You should now be able to reference the C# library in
your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
I understand but you are backwards. I am trying to write a dll in C#
(managed code) and call that dll from Delphi 6 which is unmanaged. Delphi 2005 supports all the .NET stuff but our project is currently being
managed
in Delphi 6 which does not.

So to recap. I want to write a dll in C# that performs a function that
just
pops up a message box and says hello world. I then want to call that
function from inside my delphi application so that the message box pops
up.

I'm also behind the times a little with all this managed code stuff so I'm not sure what the differences are from what managed and unmanaged code
exactly means.

Thanks,

glenn

"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Before you jump into this, you should make certain that if Delphi is
going to support .Net. If it is or is going to, it will be all mute
point as you can develop in C# or whatever to produce managed code and
consue it in Delphi.

If Delphi is not going to support managed code, then you will need to
write a COM server in managed code. The link I provided in my first
reply shows how to do it(ComVisible attribute).

>since c# does not support the old DLL processes which you seem
> to have just confirmed,

I am not what you mean here. You can call unmanaged DLLs using
interop/PInvoke in managed code(C#). That means your Delphi code
(whatever is exported by it) can be used in a managed code. If you have
a COM server in Delphi, you can use it in C#.

------
Ajay Kalra
aj*******@yahoo.com



Nov 16 '05 #12
SB
add a reference to System.Runtime.InteropServices in your AssemblyInfo.cs.
-sb

"glenn" <gh******@softeksoftware.com> wrote in message
news:uk**************@TK2MSFTNGP14.phx.gbl...
Well what do I need to add to be able to do this. When adding the change
to
the assemblyinfo unit I get The type or name "ComVisible" could not be
found.

Tried from windows solution and dll solution. both same results
Thanks,

glenn
"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for

COM
Interop" to "True".

Now when you build your project it will make it COM-compatible and

register
it on your machine. You should now be able to reference the C# library in
your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
>I understand but you are backwards. I am trying to write a dll in C#
> (managed code) and call that dll from Delphi 6 which is unmanaged. Delphi > 2005 supports all the .NET stuff but our project is currently being
> managed
> in Delphi 6 which does not.
>
> So to recap. I want to write a dll in C# that performs a function that
> just
> pops up a message box and says hello world. I then want to call that
> function from inside my delphi application so that the message box pops
> up.
>
> I'm also behind the times a little with all this managed code stuff so I'm > not sure what the differences are from what managed and unmanaged code
> exactly means.
>
> Thanks,
>
> glenn
>
> "Ajay Kalra" <aj*******@yahoo.com> wrote in message
> news:11*********************@g14g2000cwa.googlegro ups.com...
>> Before you jump into this, you should make certain that if Delphi is
>> going to support .Net. If it is or is going to, it will be all mute
>> point as you can develop in C# or whatever to produce managed code and
>> consue it in Delphi.
>>
>> If Delphi is not going to support managed code, then you will need to
>> write a COM server in managed code. The link I provided in my first
>> reply shows how to do it(ComVisible attribute).
>>
>> >since c# does not support the old DLL processes which you seem
>> > to have just confirmed,
>>
>> I am not what you mean here. You can call unmanaged DLLs using
>> interop/PInvoke in managed code(C#). That means your Delphi code
>> (whatever is exported by it) can be used in a managed code. If you
>> have
>> a COM server in Delphi, you can use it in C#.
>>
>> ------
>> Ajay Kalra
>> aj*******@yahoo.com
>>
>
>



Nov 16 '05 #13
Thanks that did it...

glenn
"SB" <st********@yahoo.com> wrote in message
news:OO**************@TK2MSFTNGP09.phx.gbl...
add a reference to System.Runtime.InteropServices in your AssemblyInfo.cs.
-sb

"glenn" <gh******@softeksoftware.com> wrote in message
news:uk**************@TK2MSFTNGP14.phx.gbl...
Well what do I need to add to be able to do this. When adding the change to
the assemblyinfo unit I get The type or name "ComVisible" could not be
found.

Tried from windows solution and dll solution. both same results
Thanks,

glenn
"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for
COM
Interop" to "True".

Now when you build your project it will make it COM-compatible and

register
it on your machine. You should now be able to reference the C# library
in your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
>I understand but you are backwards. I am trying to write a dll in C#
> (managed code) and call that dll from Delphi 6 which is unmanaged.

Delphi
> 2005 supports all the .NET stuff but our project is currently being
> managed
> in Delphi 6 which does not.
>
> So to recap. I want to write a dll in C# that performs a function that > just
> pops up a message box and says hello world. I then want to call that
> function from inside my delphi application so that the message box pops > up.
>
> I'm also behind the times a little with all this managed code stuff so I'm
> not sure what the differences are from what managed and unmanaged

code > exactly means.
>
> Thanks,
>
> glenn
>
> "Ajay Kalra" <aj*******@yahoo.com> wrote in message
> news:11*********************@g14g2000cwa.googlegro ups.com...
>> Before you jump into this, you should make certain that if Delphi is
>> going to support .Net. If it is or is going to, it will be all mute
>> point as you can develop in C# or whatever to produce managed code and >> consue it in Delphi.
>>
>> If Delphi is not going to support managed code, then you will need to >> write a COM server in managed code. The link I provided in my first
>> reply shows how to do it(ComVisible attribute).
>>
>> >since c# does not support the old DLL processes which you seem
>> > to have just confirmed,
>>
>> I am not what you mean here. You can call unmanaged DLLs using
>> interop/PInvoke in managed code(C#). That means your Delphi code
>> (whatever is exported by it) can be used in a managed code. If you
>> have
>> a COM server in Delphi, you can use it in C#.
>>
>> ------
>> Ajay Kalra
>> aj*******@yahoo.com
>>
>
>



Nov 16 '05 #14
Sorry, while it will compile now, the Register for COM option is greyed out
and set to false. I can't change it to true... Am I missing something?

glenn
"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for COM Interop" to "True".

Now when you build your project it will make it COM-compatible and register it on your machine. You should now be able to reference the C# library in
your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
I understand but you are backwards. I am trying to write a dll in C#
(managed code) and call that dll from Delphi 6 which is unmanaged. Delphi 2005 supports all the .NET stuff but our project is currently being
managed
in Delphi 6 which does not.

So to recap. I want to write a dll in C# that performs a function that
just
pops up a message box and says hello world. I then want to call that
function from inside my delphi application so that the message box pops
up.

I'm also behind the times a little with all this managed code stuff so I'm not sure what the differences are from what managed and unmanaged code
exactly means.

Thanks,

glenn

"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Before you jump into this, you should make certain that if Delphi is
going to support .Net. If it is or is going to, it will be all mute
point as you can develop in C# or whatever to produce managed code and
consue it in Delphi.

If Delphi is not going to support managed code, then you will need to
write a COM server in managed code. The link I provided in my first
reply shows how to do it(ComVisible attribute).

>since c# does not support the old DLL processes which you seem
> to have just confirmed,

I am not what you mean here. You can call unmanaged DLLs using
interop/PInvoke in managed code(C#). That means your Delphi code
(whatever is exported by it) can be used in a managed code. If you have
a COM server in Delphi, you can use it in C#.

------
Ajay Kalra
aj*******@yahoo.com



Nov 16 '05 #15
"glenn" <gh******@softeksoftware.com> wrote in message
news:O1*************@TK2MSFTNGP10.phx.gbl...
Sorry, while it will compile now, the Register for COM option is greyed
out
and set to false. I can't change it to true... Am I missing something?
Weird, mine doesn't go off even when I change my project type to Console. Do
you have any public classes in your code. If you do I'm not sure what the
problem is, probably some obscure setting somewhere. Doesn't really matter
anyway, since all that option does is automatically run regasm on your
assembly for you, so you can just do that manually.

glenn
"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for

COM
Interop" to "True".

Now when you build your project it will make it COM-compatible and

register
it on your machine. You should now be able to reference the C# library in
your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
>I understand but you are backwards. I am trying to write a dll in C#
> (managed code) and call that dll from Delphi 6 which is unmanaged. Delphi > 2005 supports all the .NET stuff but our project is currently being
> managed
> in Delphi 6 which does not.
>
> So to recap. I want to write a dll in C# that performs a function that
> just
> pops up a message box and says hello world. I then want to call that
> function from inside my delphi application so that the message box pops
> up.
>
> I'm also behind the times a little with all this managed code stuff so I'm > not sure what the differences are from what managed and unmanaged code
> exactly means.
>
> Thanks,
>
> glenn
>
> "Ajay Kalra" <aj*******@yahoo.com> wrote in message
> news:11*********************@g14g2000cwa.googlegro ups.com...
>> Before you jump into this, you should make certain that if Delphi is
>> going to support .Net. If it is or is going to, it will be all mute
>> point as you can develop in C# or whatever to produce managed code and
>> consue it in Delphi.
>>
>> If Delphi is not going to support managed code, then you will need to
>> write a COM server in managed code. The link I provided in my first
>> reply shows how to do it(ComVisible attribute).
>>
>> >since c# does not support the old DLL processes which you seem
>> > to have just confirmed,
>>
>> I am not what you mean here. You can call unmanaged DLLs using
>> interop/PInvoke in managed code(C#). That means your Delphi code
>> (whatever is exported by it) can be used in a managed code. If you
>> have
>> a COM server in Delphi, you can use it in C#.
>>
>> ------
>> Ajay Kalra
>> aj*******@yahoo.com
>>
>
>



Nov 16 '05 #16
Actually, I just created a brand new project and did what was said to do. I
haven't added or changed anything at this point...

thanks,

glenn

"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
"glenn" <gh******@softeksoftware.com> wrote in message
news:O1*************@TK2MSFTNGP10.phx.gbl...
Sorry, while it will compile now, the Register for COM option is greyed
out
and set to false. I can't change it to true... Am I missing something?
Weird, mine doesn't go off even when I change my project type to Console.

Do you have any public classes in your code. If you do I'm not sure what the
problem is, probably some obscure setting somewhere. Doesn't really matter
anyway, since all that option does is automatically run regasm on your
assembly for you, so you can just do that manually.

glenn
"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for
COM
Interop" to "True".

Now when you build your project it will make it COM-compatible and

register
it on your machine. You should now be able to reference the C# library
in your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
>I understand but you are backwards. I am trying to write a dll in C#
> (managed code) and call that dll from Delphi 6 which is unmanaged.

Delphi
> 2005 supports all the .NET stuff but our project is currently being
> managed
> in Delphi 6 which does not.
>
> So to recap. I want to write a dll in C# that performs a function that > just
> pops up a message box and says hello world. I then want to call that
> function from inside my delphi application so that the message box pops > up.
>
> I'm also behind the times a little with all this managed code stuff so I'm
> not sure what the differences are from what managed and unmanaged

code > exactly means.
>
> Thanks,
>
> glenn
>
> "Ajay Kalra" <aj*******@yahoo.com> wrote in message
> news:11*********************@g14g2000cwa.googlegro ups.com...
>> Before you jump into this, you should make certain that if Delphi is
>> going to support .Net. If it is or is going to, it will be all mute
>> point as you can develop in C# or whatever to produce managed code and >> consue it in Delphi.
>>
>> If Delphi is not going to support managed code, then you will need to >> write a COM server in managed code. The link I provided in my first
>> reply shows how to do it(ComVisible attribute).
>>
>> >since c# does not support the old DLL processes which you seem
>> > to have just confirmed,
>>
>> I am not what you mean here. You can call unmanaged DLLs using
>> interop/PInvoke in managed code(C#). That means your Delphi code
>> (whatever is exported by it) can be used in a managed code. If you
>> have
>> a COM server in Delphi, you can use it in C#.
>>
>> ------
>> Ajay Kalra
>> aj*******@yahoo.com
>>
>
>



Nov 16 '05 #17
"Ajay Kalra" <aj*******@yahoo.com> a écrit dans le message de news:
11**********************@z14g2000cwz.googlegroups. com...
I still believe your best bet is to use Delphi 2005 if it supports .Net
and unmangaged code in the same component. You need to find this out
before deciding about how to proceed.


There is absolutely no need to use D2005 as D6 is well able to cope with
using COM objects. Delphi has always been a very flexible development tool;
and has supported both COM and CORBA since either v3 or v4.

As the OP has discovered, all that is required is to create a COM interop
assembly which can then be used to create a type library using Delphi's COM
wizard.

Joanna

--
Joanna Carter
Consultant Software Engineer
Nov 16 '05 #18
> There is absolutely no need to use D2005 as D6 is well able to cope
with
using COM objects.

I think that was well understood based on OP's comments.
As the OP has discovered, all that is required is to create a COM interopassembly which can then be used to create a type library using Delphi's COM wizard.


I know almost nothing about Delphi than what OP mentioned. *If* Delphi
2005 supports .net and unmanaged code, I see no reason to go the COM
way. Why even bother? There is a *if* involved here and only someone
familiar with Delphi 2005 can answer that. What I am saying is not
different than MC++, where you can have managed wrapper over an
unmanaged object and use it in another managed assembly without using
COM.

---------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #19

It depends on whether the dll that you wish to use with C# is a COM dll
or win32 dll.

It its a COM dll, then you just add a reference to the dll from Visual
Studio.NET project. It will create Runtime Callable Wrappers and
Unwrappers (COM InterOp) for you. Tou do not need to do any extra
coding.

If its a Win32 dll, then you need to use DllImport attribute in C# for
each function in dll that you wish to expose to C# assembly.

e.g.
Say you have a dll named myLib.dll and you have a function called
Print inside it that you want to expose it to C#, then the code for it
is as follows.

using System;
using System.Runtime.InteropServices;

namespace HelloUtil
{
public class Echo
{
//This is how you register dll function with
//DllImport
[DllImport("myLib.dll")]
static extern void Print(string s);

string myString;

public Echo(string aString)
{
myString = aString;
}

public void Tell()
{
//This is actuall call to dll function
Print(myString);
}
}
}


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #20
Ok, I've created a dll in C# and set it up as a COM server. I then go to
delphi and try to import the type library which is generated and get the
following error in the mscorlib_TLB.pas unit...

Type Byte is not yet completely defined.

Any ideas on this?

Thanks,

glenn
"Joanna Carter (TeamB)" <jo*****@nospamforme.com> wrote in message
news:ui*************@TK2MSFTNGP15.phx.gbl...
"Ajay Kalra" <aj*******@yahoo.com> a écrit dans le message de news:
11**********************@z14g2000cwz.googlegroups. com...
I still believe your best bet is to use Delphi 2005 if it supports .Net
and unmangaged code in the same component. You need to find this out
before deciding about how to proceed.
There is absolutely no need to use D2005 as D6 is well able to cope with
using COM objects. Delphi has always been a very flexible development

tool; and has supported both COM and CORBA since either v3 or v4.

As the OP has discovered, all that is required is to create a COM interop
assembly which can then be used to create a type library using Delphi's COM wizard.

Joanna

--
Joanna Carter
Consultant Software Engineer

Nov 16 '05 #21
It does support it, there is no if there, but the problem is I'm not in
Delphi 2005. I'm in Delphi 6 and not until our project is rewritten will it
be in either C# or Delphi 2005 as I have not decided yet which one we will
be using.

I would like to use C#, but the database routines provided in Visual Studio
are weak at best compared to Delphi and I have not determined if we want to
manually code all our database stuff yet. Other than that I love C#, the
Visual Studio IDE though is so weak that it frustrates me. We're using
Delphi 6 and it is so much better than the Visual Studio stuff its
unbelievable. I know VS is much better than anything else Microsoft has
ever produced, but if any Microsoft developer were to ever compare it to
something like Delphi, I don't think they'd be praising it quite so much...

glenn

"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
There is absolutely no need to use D2005 as D6 is well able to cope

with
using COM objects.

I think that was well understood based on OP's comments.
As the OP has discovered, all that is required is to create a COM

interop
assembly which can then be used to create a type library using

Delphi's COM
wizard.


I know almost nothing about Delphi than what OP mentioned. *If* Delphi
2005 supports .net and unmanaged code, I see no reason to go the COM
way. Why even bother? There is a *if* involved here and only someone
familiar with Delphi 2005 can answer that. What I am saying is not
different than MC++, where you can have managed wrapper over an
unmanaged object and use it in another managed assembly without using
COM.

---------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #22
Thank you but as I stated, I'm wanting to call the dll from another
development platform and they work differently. The problem is the dll I
wrote in C# does not act like a normal Win32 dll and I don't know how to get
it to do so. So I am having to write it as a COM object so that I can
import it into Delphi and use it that way. Which is not a problem, just
trying to figure it all out...

glenn

"Ravindra Sadaphule" <rs********@gmail.com> wrote in message
news:u6**************@TK2MSFTNGP14.phx.gbl...

It depends on whether the dll that you wish to use with C# is a COM dll
or win32 dll.

It its a COM dll, then you just add a reference to the dll from Visual
Studio.NET project. It will create Runtime Callable Wrappers and
Unwrappers (COM InterOp) for you. Tou do not need to do any extra
coding.

If its a Win32 dll, then you need to use DllImport attribute in C# for
each function in dll that you wish to expose to C# assembly.

e.g.
Say you have a dll named myLib.dll and you have a function called
Print inside it that you want to expose it to C#, then the code for it
is as follows.

using System;
using System.Runtime.InteropServices;

namespace HelloUtil
{
public class Echo
{
//This is how you register dll function with
//DllImport
[DllImport("myLib.dll")]
static extern void Print(string s);

string myString;

public Echo(string aString)
{
myString = aString;
}

public void Tell()
{
//This is actuall call to dll function
Print(myString);
}
}
}


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #23
Ok, I got all this to work, but my next question is, how do I select a
class/function to export so that the delphi application can see it?

Thanks,

glenn

"Sean Hederman" <us***@blogentry.com> wrote in message
news:d1**********@ctb-nnrp2.saix.net...
In your C# DLL do the following:

AssemblyInfo.cs
----------------
[assembly: ComVisible(true)]

Then, right-click on the project in the Solution Explorer, select
Properties, choose Configuration Properties\Build, and set "Register for COM Interop" to "True".

Now when you build your project it will make it COM-compatible and register it on your machine. You should now be able to reference the C# library in
your Delphi code.

"glenn" <gh******@softeksoftware.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
I understand but you are backwards. I am trying to write a dll in C#
(managed code) and call that dll from Delphi 6 which is unmanaged. Delphi 2005 supports all the .NET stuff but our project is currently being
managed
in Delphi 6 which does not.

So to recap. I want to write a dll in C# that performs a function that
just
pops up a message box and says hello world. I then want to call that
function from inside my delphi application so that the message box pops
up.

I'm also behind the times a little with all this managed code stuff so I'm not sure what the differences are from what managed and unmanaged code
exactly means.

Thanks,

glenn

"Ajay Kalra" <aj*******@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Before you jump into this, you should make certain that if Delphi is
going to support .Net. If it is or is going to, it will be all mute
point as you can develop in C# or whatever to produce managed code and
consue it in Delphi.

If Delphi is not going to support managed code, then you will need to
write a COM server in managed code. The link I provided in my first
reply shows how to do it(ComVisible attribute).

>since c# does not support the old DLL processes which you seem
> to have just confirmed,

I am not what you mean here. You can call unmanaged DLLs using
interop/PInvoke in managed code(C#). That means your Delphi code
(whatever is exported by it) can be used in a managed code. If you have
a COM server in Delphi, you can use it in C#.

------
Ajay Kalra
aj*******@yahoo.com



Nov 16 '05 #24
I see. If Deplhi understands COM, then what you need to do in this case

1. Attach a strong name to C# dll and put it in GAC.
2. Use RegAsm tool to register the C# dll and create Type Library.
3. Reference this Type Library in ur Delphi code.

Cheers
Ravindra Sadaphule
MCSD.NET

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.