DLL

  • Thread starter Thread starter [GHO]
  • Start date Start date
You could take a look on:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html
/vclrfcsharpspec_1_12.asp

In Visual Studio .NET:

Create your dll by using File -> New Project and than select from the
dialog:
- Project Type: "Visual C# Projects"
- Template: "Class Library"
- Type a name, select a location and press OK
Type your code and build. You will have your own dll.

Using the dll in your exe:
- Create your C# application
- Go into the Solution Explorer, right click on your project and select
"Add Reference". Than use Browse to locate your dll. After that you will be
able to use the classes and functions defined in your dll.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbtskaddingremovingreferences.asp

Note: If the namespaces are different, you will have to add an "using"
directive into your exe code.
Can some one send me a sample DLL file which wrote in C#
language.

Adrian Vinca [MSFT], Developer Division
--------------------------------------------------------------------
This reply is provided "AS IS", without warranty (express or implied).

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
I know All you sent me, but my problem is to create a general DLL, as on
MFC to be able to use it from any application not only C# application.

I always create MFC DLL , then add the *.lib then
"exten myDLLfunc()" , then copy my DLL to Aplication directory,
Now I can use this function.

Now what I'm asking for is how to do that by using C# language to create
a DLL file then using this DLL on MFC application
 
Hi Yosi,
So, you need to read about interop, and exposing .net assemblies to COM.

In general you have to right-click on your project, select
Properties/Configuration properties/Build, and there change Register for
Com interop to true.

Than, when you build the assembly, it will be registered, and you can
use that classes.

Actually this is simplest solution for beginning. This way the assembly
will be registered only on the dev machine.

If you want to distribute this with your app on other machines there are
2 possible solutions:
1. use a setup project from VS.Net, and on the properties of the dll
(when you add it there) set Register = vsdrpCOM. It should make all
necessary preparations.

2. If the first solution fails (it happen to me, so now I use this),
your install script have to run:
regasm.exe mydll.dll /tlb:myddl.tlb /codebase /silent

/codebase registers the dll for COM interop without the need of putting
your dll in GAC. This is not the recommended by MS way, but you may use
it.
You can do it without /codebase, but then your install script have to
install the dll in GAC.

This are only shortcuts, but before doing such a things I strongly
recommend to read the articles in MSDN, related to Interop, like:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vbcon/html/vbconcominteropinvisualbasicvisualc.asp

and search Google for more. I found this one helpful:

http://www.c-sharpcorner.com/Code/2002/April/COMInteropP2AJ.asp

Have fun
Cheers
Sunny
 
Why this not working well in WIN98????
-----Original Message-----
Hi Yosi,
So, you need to read about interop, and exposing .net assemblies to COM.

In general you have to right-click on your project, select
Properties/Configuration properties/Build, and there change Register for
Com interop to true.

Than, when you build the assembly, it will be registered, and you can
use that classes.

Actually this is simplest solution for beginning. This way the assembly
will be registered only on the dev machine.

If you want to distribute this with your app on other machines there are
2 possible solutions:
1. use a setup project from VS.Net, and on the properties of the dll
(when you add it there) set Register = vsdrpCOM. It should make all
necessary preparations.

2. If the first solution fails (it happen to me, so now I use this),
your install script have to run:
regasm.exe mydll.dll /tlb:myddl.tlb /codebase /silent

/codebase registers the dll for COM interop without the need of putting
your dll in GAC. This is not the recommended by MS way, but you may use
it.
You can do it without /codebase, but then your install script have to
install the dll in GAC.

This are only shortcuts, but before doing such a things I strongly
recommend to read the articles in MSDN, related to Interop, like:

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/vbcon/html/vbconcominteropinvisualbasicvisualc.asp

and search Google for more. I found this one helpful:

http://www.c- sharpcorner.com/Code/2002/April/COMInteropP2AJ.asp

Have fun
Cheers
Sunny


.
 
OMG REALLY!!!

I would consider .NET support on 9x as you get what you get if any.
 
Back
Top