473,320 Members | 1,979 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,320 software developers and data experts.

Using C# Classes in win 32 application

We have some old win32 apps and I still need to support these applications.
I'd like to do new and future enhancements in C#, if at all possible.

Is there a way to use a .net assembly in a normal windows 32 app?

Thanks
Wayne
Nov 16 '05 #1
12 2333
nal
No, due to the omnipotent CLR missing from non managed applications.

"Wayne" <Me******@community.nospam> wrote in message
news:u4***************@tk2msftngp13.phx.gbl...
We have some old win32 apps and I still need to support these applications. I'd like to do new and future enhancements in C#, if at all possible.

Is there a way to use a .net assembly in a normal windows 32 app?

Thanks
Wayne

Nov 16 '05 #2
What about COM-Callable Wrappers?

"nal" <nal@invalidaddress> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
No, due to the omnipotent CLR missing from non managed applications.

"Wayne" <Me******@community.nospam> wrote in message
news:u4***************@tk2msftngp13.phx.gbl...
We have some old win32 apps and I still need to support these

applications.
I'd like to do new and future enhancements in C#, if at all possible.

Is there a way to use a .net assembly in a normal windows 32 app?

Thanks
Wayne

Nov 16 '05 #3
"Wayne" <Me******@community.nospam> wrote in message
news:u4***************@tk2msftngp13.phx.gbl...
Is there a way to use a .net assembly in a normal windows 32 app?


Yep - all you have to is give it a COM wrapper, then it can be used by any
app which can instantiate a COM object.

http://www.15seconds.com/issue/040721.htm
Nov 16 '05 #4
nal
Yeah, probably using the type library exporter, but type libraries i.e your
COM callable wrappers may omit some information. So in essence, you can
drive a car with your feet, but that doesn't mean you should.
"Ivan A. Gavrilyuk" <iv************@hotmail.com> wrote in message
news:uf**************@TK2MSFTNGP12.phx.gbl...
What about COM-Callable Wrappers?

"nal" <nal@invalidaddress> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
No, due to the omnipotent CLR missing from non managed applications.

"Wayne" <Me******@community.nospam> wrote in message
news:u4***************@tk2msftngp13.phx.gbl...
We have some old win32 apps and I still need to support these

applications.
I'd like to do new and future enhancements in C#, if at all possible.

Is there a way to use a .net assembly in a normal windows 32 app?

Thanks
Wayne


Nov 16 '05 #5

"Wayne" <Me******@community.nospam> wrote in message
news:u4***************@tk2msftngp13.phx.gbl...
We have some old win32 apps and I still need to support these applications. I'd like to do new and future enhancements in C#, if at all possible.

Is there a way to use a .net assembly in a normal windows 32 app?
There are two main approaches:

1) Turn on managed extensions for your C++ app, and use the IJW features of
MC++.
2) Use a MC++ bridging DLL.

Are we talking just simple functions or .NET controls? Simple functions are
easy; embedding .NET controls in MFC is tricky (but can definitely be done).

Stu

Thanks
Wayne

Nov 16 '05 #6
Hi nal,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to utilize a model that was
written in C# with managed code in Win32 application written in unmanaged
code. If there is any misunderstanding, please feel free to let me know.

As far as I know, we can expose .NET class interfaces to COM. The link Mark
provided is quite useful. We after written the class, we can use regasm.exe
register the DLL on the machine.

Here is some other useful article which provides more information.

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconExposingNETFrameworkComponentsToCOM.asp

http://support.microsoft.com/default...b;en-us;817248

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #7
So from what I can tell this HAS to be done through Com, which results in
the C# Assembly being registered on the machine in question, is this
correct?

I was hoping there may be some LoadLib way of doing this, as the application
I currently have runs from a network share and requires no special installs
on the users machine. I would like to keep this modal going forward,
obviously the frame work would be there.

Thanks
Wayne
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:r$**************@cpmsftngxa06.phx.gbl...
Hi nal,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to utilize a model that was
written in C# with managed code in Win32 application written in unmanaged
code. If there is any misunderstanding, please feel free to let me know.

As far as I know, we can expose .NET class interfaces to COM. The link Mark provided is quite useful. We after written the class, we can use regasm.exe register the DLL on the machine.

Here is some other useful article which provides more information.

http://msdn.microsoft.com/library/de...us/cpguide/htm l/cpconExposingNETFrameworkComponentsToCOM.asp

http://support.microsoft.com/default...b;en-us;817248

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #8
Hi Wayne,

Yes, you understanding is correct. When we need to load some library that
was written in .NET, we have to have .NET framework installed on the client
machine. And to interop with Win32 app, it seems that we can only achieve
this through COM.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #9
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:r$**************@cpmsftngxa06.phx.gbl...
The link Mark provided is quite useful.


Generally speaking, I find the articles on www.15seconds.com to be really
helpful. I'm not a C# guru by any means, having made a living with VB since
version 3, and it always seems to me that these articles are just at the
level I require. I.e. techie enough for me to understand quickly, but not so
much that I have to spend hours poring over them, so that I can get to grips
with the basic concepts of what I'm looking for, and then delve deeper if I
need to.
Nov 16 '05 #10

"Wayne" <Me******@community.nospam> wrote in message
news:uK*************@tk2msftngp13.phx.gbl...
So from what I can tell this HAS to be done through Com, which results in
the C# Assembly being registered on the machine in question, is this
correct?
Is your application written in C++ or VB6?

If it's C++ you could go down either the managed C++ route or the COM route.
(NB you wouldn't have to make your application managed to use MC++; you
could use a bridging DLL instead).

If it's VB6 the COM is probably the best route although you could use a C++
bridging DLL and import it, but that wouldn't be pretty.

So no, a registered COM DLL is not your only option.

Here's an example I was involved with recently:

MFC application of about 500 KLOC. Wanted to use a C# component, and embed
it in an MFC view. We first tried turning on managed extensions, but that
increased the link time by about 10 minutes. The approach we are now using
is a partially managed bridging DLL, talking unmanaged to the MFC side, and
managed to C#. Nothing registered at all.

Stu

I was hoping there may be some LoadLib way of doing this, as the application I currently have runs from a network share and requires no special installs on the users machine. I would like to keep this modal going forward,
obviously the frame work would be there.

Thanks
Wayne
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:r$**************@cpmsftngxa06.phx.gbl...
Hi nal,

First of all, I would like to confirm my understanding of your issue. From your description, I understand that you need to utilize a model that was
written in C# with managed code in Win32 application written in unmanaged code. If there is any misunderstanding, please feel free to let me know.

As far as I know, we can expose .NET class interfaces to COM. The link

Mark
provided is quite useful. We after written the class, we can use

regasm.exe
register the DLL on the machine.

Here is some other useful article which provides more information.

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconExposingNETFrameworkComponentsToCOM.asp

http://support.microsoft.com/default...b;en-us;817248

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Nov 16 '05 #11
Actually its neither. The application is written in Delphi, Delphi for .net
(D8) allows you to export functions that can be used with Load Library,
however, we don't have D8, nor are we buying it just for this. So I guess I
will start looking at what it will take to get the Com Object registered on
each machine, as it is an internal app this shouldn't be to difficult.

thanks for all the information, and help. It is very appreciative.
Wayne
"Stu Smith" <st*****@nospam-digita.com> wrote in message
news:Oh*************@TK2MSFTNGP09.phx.gbl...

"Wayne" <Me******@community.nospam> wrote in message
news:uK*************@tk2msftngp13.phx.gbl...
So from what I can tell this HAS to be done through Com, which results in
the C# Assembly being registered on the machine in question, is this
correct?
Is your application written in C++ or VB6?

If it's C++ you could go down either the managed C++ route or the COM

route. (NB you wouldn't have to make your application managed to use MC++; you
could use a bridging DLL instead).

If it's VB6 the COM is probably the best route although you could use a C++ bridging DLL and import it, but that wouldn't be pretty.

So no, a registered COM DLL is not your only option.

Here's an example I was involved with recently:

MFC application of about 500 KLOC. Wanted to use a C# component, and embed
it in an MFC view. We first tried turning on managed extensions, but that
increased the link time by about 10 minutes. The approach we are now using
is a partially managed bridging DLL, talking unmanaged to the MFC side, and managed to C#. Nothing registered at all.

Stu

I was hoping there may be some LoadLib way of doing this, as the

application
I currently have runs from a network share and requires no special

installs
on the users machine. I would like to keep this modal going forward,
obviously the frame work would be there.

Thanks
Wayne
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:r$**************@cpmsftngxa06.phx.gbl...
Hi nal,

First of all, I would like to confirm my understanding of your issue.

From your description, I understand that you need to utilize a model that was written in C# with managed code in Win32 application written in unmanaged code. If there is any misunderstanding, please feel free to let me know.
As far as I know, we can expose .NET class interfaces to COM. The link

Mark
provided is quite useful. We after written the class, we can use

regasm.exe
register the DLL on the machine.

Here is some other useful article which provides more information.

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconExposingNETFrameworkComponentsToCOM.asp

http://support.microsoft.com/default...b;en-us;817248

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."



Nov 16 '05 #12

"Wayne" <Me******@community.nospam> wrote in message
news:eQ**************@TK2MSFTNGP11.phx.gbl...
Actually its neither. The application is written in Delphi, Delphi for ..net (D8) allows you to export functions that can be used with Load Library,
however, we don't have D8, nor are we buying it just for this. So I guess I will start looking at what it will take to get the Com Object registered on each machine, as it is an internal app this shouldn't be to difficult.

thanks for all the information, and help. It is very appreciative.
Wayne
That'll learn me to make assumptions. I tend to forget about non-MS dev
environments...

Stu


"Stu Smith" <st*****@nospam-digita.com> wrote in message
news:Oh*************@TK2MSFTNGP09.phx.gbl...

"Wayne" <Me******@community.nospam> wrote in message
news:uK*************@tk2msftngp13.phx.gbl...
So from what I can tell this HAS to be done through Com, which results in the C# Assembly being registered on the machine in question, is this
correct?


Is your application written in C++ or VB6?

If it's C++ you could go down either the managed C++ route or the COM

route.
(NB you wouldn't have to make your application managed to use MC++; you
could use a bridging DLL instead).

If it's VB6 the COM is probably the best route although you could use a

C++
bridging DLL and import it, but that wouldn't be pretty.

So no, a registered COM DLL is not your only option.

Here's an example I was involved with recently:

MFC application of about 500 KLOC. Wanted to use a C# component, and embed
it in an MFC view. We first tried turning on managed extensions, but that increased the link time by about 10 minutes. The approach we are now using is a partially managed bridging DLL, talking unmanaged to the MFC side,

and
managed to C#. Nothing registered at all.

Stu

I was hoping there may be some LoadLib way of doing this, as the

application
I currently have runs from a network share and requires no special

installs
on the users machine. I would like to keep this modal going forward,
obviously the frame work would be there.

Thanks
Wayne
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:r$**************@cpmsftngxa06.phx.gbl...
> Hi nal,
>
> First of all, I would like to confirm my understanding of your issue.
From
> your description, I understand that you need to utilize a model that

was > written in C# with managed code in Win32 application written in

unmanaged
> code. If there is any misunderstanding, please feel free to let me know. >
> As far as I know, we can expose .NET class interfaces to COM. The
link Mark
> provided is quite useful. We after written the class, we can use
regasm.exe
> register the DLL on the machine.
>
> Here is some other useful article which provides more information.
>
>

http://msdn.microsoft.com/library/de...us/cpguide/htm
> l/cpconExposingNETFrameworkComponentsToCOM.asp
>
> http://support.microsoft.com/default...b;en-us;817248
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Nov 16 '05 #13

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

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
43
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
5
by: Benne Smith | last post by:
Hi, I have three enviroments; a development, a testing and a production enviroment. I'm making a big application (.exe), which uses alot of different webservices. I don't use the webservices...
4
by: clintonG | last post by:
When using Visual Studio.NET I observe adding a new Web Form may have default References added such as... References o- System o- System.Data o- System.Drawing o- System.Web o- System.XML
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
3
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
1
by: Nijazi Halimaji | last post by:
Hi I have written an application and now I like to use some public classes from this application in VB6 (Like I use the Word.Application-Classes with createobject). In VB6 I made Active-X-exe...
2
by: Roy Chastain | last post by:
I have some 'base' schema definitions that are going to be in several projects in the future. The processing of resulting classes created by XSD will be consistent across the new projects. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.