how can I create DLL without having class - dll

can anyone give me some steps to create DLL without using class which means it will just have methods in the header file and source file would be only DLLmain() plus other methods. I'm using Visual Studio 2005 to create MFC DLL, but it always generates class. I never create DLL before but I was told that I can create DLL without class/object oriented concepts, just plain functions.
thanks.

For a regular Win32 DLL:
In the New Project wizard, under Visual C++ / Win32, choose Win32 Project.
Then in the next page, choose DLL as application type.
You may want to select Export functions as well to get sample code of exported variables, functions and classes.
From there on, simply delete what you dont need (such as classes).
I no longer have the Windows Mobile SDK installed, but I'm pretty sure you'll find the same kind of wizard to create a Windows Mobile DLL project.
Of course, if you don't want C++ classes, forget about MFC!

Related

Visual Basic 2010 Markdown implementation [duplicate]

I wanna use the C# code file in VB.Net project Which is windows based application. But that C# class is not using in VB.NET application. How Can I perform this task.
Thanks
Compile the C# class in it's own C# class library (DLL) and then in your VB project, add a reference to the C# DLL. You can then use the class in your VB project.
If, however, you want to include the source code of the C# class in your VB project then you will have to convert the class from C# to VB. There are various methods of doing this, such as the online tool Convert C# to VB.NET
It is very simple to combine your VB.net & C#.net project.
Step1- Add projects which you wanna combine to a single solution.
Step2- Within any one project VB/C# in which you want to call classes from other language project "Goto- Add Reference- Projects" and select the other project which will be automatically displayed.
Step3- After adding the reference just add "Imports (in VB)" or "using (in C#)" statements to your code.
Step4- bingooo!!! now you can use your VB/C# classes in another language.
(tip: You can go only in one direction here i.e. either you can use your C# classes in VB.net or vice versa.)
All the best
You can also add the reference for an executable, if it is a .NET assembly. So just compile your C# project and add it as reference into your VB project.
It is possible, check this:
http://bytes.com/topic/net/answers/49259-mixing-vb-net-c-same-project
However, it is possible to use
different languages in a single
project. You may need to write command
line build file to build the project.
In .NET framework SDK, there is one
sample on it. You could access it in
C:\Program Files\Microsoft Visual
Studio
.NET\FrameworkSDK\Samples\Technologies\CrossDevLan
guage.
This sample demonstrates the use
different development languages in a
single project. This sample creates
two assemblies. The first is a library
or DLL assembly that defines a simple
base class written in managed
extensions for C++. The second
assembly is an executable assembly
that defines three derived classes
written in C#, VB, and IL
(Intermediate Language). These types
derive from each other and ultimately
from the base class written in managed
C++. Finally, the executable creates
instances of each of the derived types
and calls a virtual method for each.
The .NET Framework is an environment
where various developers can work
together seamlessly while developing
in their language of choice.

vb.net: is it possible to import FreeImage.dll to vb.net?

I need to read\write tga files from vb,
I found TargaImage.dll, nice lib but it allows only read tga.
I found FreeImage, tryed to import it in vb, but it says:
FreeImage.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
I think I have to use , but absolutly dont know anything.
help plz:)
From looking at the way the distribution works, you have two options:
First, you could call the functions in the DLL directly using <DllImport> attributes. This is going to require a lot of learning of how to make calls to unmanaged DLLs, passing the right values, etc. Which is why I suggest the second option.
The second option is, you can use the .NET Wrapper project that is included in the distribution. If you're using a version of Visual Studio that supports multiple programming languages, just add the wrapper project to your solution and reference the wrapper project from the project that needs to use it.
If you're using Visual Studio Express, you won't be able to add a C# project to a VB solution. I'd suggest downloading C# Express, compiling the wrapper project, and then adding the compiled DLL to your VB.Net project.

change interop dll version created in vb6 when using in .net

I'm facing problem while reference vb6 dll in .net project. When ever i refer a vb6 dll in .net project the interop dll is created with same version(1.2.0.0). Its creating problem for me as the setup used to deploy the application at client side does not replace the dll if the version is same as before. I want to change the version of the interop dll (created using vb6 dll). I read it cam done using tlbIMP but how to create tlb file for vb6 dll. Or is there is any other way to achieve this.
Thanks
Saurabh
Here's a small batch file we use to create our interop dll so it's strongly named:
sn.exe -i MichiganLTAP.pfx MagicContainerName
tlbimp.exe ourVb6.dll /out:Our.Strongnamed.Interop.dll /asmversion:7.1.0.0 /keycontainer:MagicContainerName /machine:X86 /namespace:Our.Strongnamed /verbose /sysarray
sn.exe -d MagicContainerName
The important switch from your perspective is: /asmversion:7.1.0.0
You should be able to set that to whatever you want. Check out the MSDN Library page for more info on the switches available.
It makes very little sense to make the version number of the interop library different from the version number of the type library that was created by VB6. There is a one-to-one mapping between what's in the interop library vs the code you wrote in VB6. The interop library simply contains IL declarations for the VB6 COM interfaces, there is no actual code. The CLR uses it to quickly generate the RCW for the interface.
Change the type library version number in VB6 with Project + Properties, Make tab, Version number. Major and minor is what counts. Do this only when you make a change in the publicly visible VB6 classes. Doing so is required btw, it avoids DLL Hell.

How to use C# class in VB.NET project in windows application?

I wanna use the C# code file in VB.Net project Which is windows based application. But that C# class is not using in VB.NET application. How Can I perform this task.
Thanks
Compile the C# class in it's own C# class library (DLL) and then in your VB project, add a reference to the C# DLL. You can then use the class in your VB project.
If, however, you want to include the source code of the C# class in your VB project then you will have to convert the class from C# to VB. There are various methods of doing this, such as the online tool Convert C# to VB.NET
It is very simple to combine your VB.net & C#.net project.
Step1- Add projects which you wanna combine to a single solution.
Step2- Within any one project VB/C# in which you want to call classes from other language project "Goto- Add Reference- Projects" and select the other project which will be automatically displayed.
Step3- After adding the reference just add "Imports (in VB)" or "using (in C#)" statements to your code.
Step4- bingooo!!! now you can use your VB/C# classes in another language.
(tip: You can go only in one direction here i.e. either you can use your C# classes in VB.net or vice versa.)
All the best
You can also add the reference for an executable, if it is a .NET assembly. So just compile your C# project and add it as reference into your VB project.
It is possible, check this:
http://bytes.com/topic/net/answers/49259-mixing-vb-net-c-same-project
However, it is possible to use
different languages in a single
project. You may need to write command
line build file to build the project.
In .NET framework SDK, there is one
sample on it. You could access it in
C:\Program Files\Microsoft Visual
Studio
.NET\FrameworkSDK\Samples\Technologies\CrossDevLan
guage.
This sample demonstrates the use
different development languages in a
single project. This sample creates
two assemblies. The first is a library
or DLL assembly that defines a simple
base class written in managed
extensions for C++. The second
assembly is an executable assembly
that defines three derived classes
written in C#, VB, and IL
(Intermediate Language). These types
derive from each other and ultimately
from the base class written in managed
C++. Finally, the executable creates
instances of each of the derived types
and calls a virtual method for each.
The .NET Framework is an environment
where various developers can work
together seamlessly while developing
in their language of choice.

Using VS 2008 (vb.net) I need to create an object I can use in Classic ASP with CreateObject

I am very new to VB.net. I have written these objects in VB6 before. I'm just lost in VB.net, but (kicking and screaming) I have to learn how to do this. I've been googling for hours with only minor steps forward. Can anyone post a link that explains start to finish how to do this?
I have managed to write the class object, What I can not tell is how to register it and where the name1 and name2 in the CreateObject("Name1.Name2") come from.
Regsrv32 will not work. It says "Entry Point not found" and will not register it. Also, I can not drop it into the Assemblies directory. I read something about a regasm command one uses, but I can't seem to make this work either.
Thanks in advance for any assistance.
I am going to assume you are not trying to write a COM DLL but rather a complete project that call various sub assemblies like a VB6 EXE call a ActiveX DLL. If you can be more specific about what you are trying to do it would help me better.
Several points about VB.NET versus VB6.
1) For .NET only projects there is no registration. If a EXE or DLL references another .NET DLL the only requirement is that the DLLs be present in the parent's directory.
2) You can do a COM style registration for .NET apps only by registering the .NET assembly in the GAC. However there are several requirements for doing this. Do a search on the .NET GAC and it will give you the scoop on how to do this.
3) You can setup the .NET assembly to use COM in which case it will operate by the rules of COM including registration with regsvr.
You will find for .NET only project that #2, or #3 only come in rare instances. #1 will apply for 90% of your DLL assemblies. Of This is dependent on your project.
A common use for CreateObject is allow for plug-ins or installable libraries. .NET handles this through the Reflection API. With the reflection API you can look in a directory, go through each .NET DLL and see what them and create objects from what you find. Search for .NET Reflection to read up on this.
If your project is .NET only then I recommend that you create a Assembly that is reference by both the master assembly and the individual sub assembly that define the interfaces of the objects you are creating. This when you use the reflection API and determine the Object type you can assign it to a variable of that interface and code it noramlly with intellisense and other aids.
if you have old COM ActiveX Controls or DLLs .NET will generate a wrapper class that exposes the ActiveX Objects to .NET. I would spend some time learning how .NET does this. What I do create a dummy project and have .NET reference the ActiveX stuff I need. I then find the wrapper projects and DLL it made and move them into a central area. That why when I work on subsquent projects using the same ActiveX stuff I know where all the wrappers are.
You have to go to your class library properties and select the option "Register for COM interop". This will make your assembly available to COM.
You want to create what's called a COM Callable Wrapper (aka CCW) for your .NET component. This basically entails setting up some COM interfaces with some GUIDs and either enabling "Register for COM Interop" in the project properties (as mentioned) or using regasm.exe.