Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am Creating a small project which is created in C#. I am having a DLL file by the use of DLL file, I have to call the functions and methods and Make that project as a new DLL. I done this But the problem is The C# code is converted to net module it shows two errors. I am not clear about that kindly help me over it.

Code:

public int Add(int a, int b)
{
return a + b;
}


Errors:

Basic.cs(7,7): error CS0246: The type or namespace name 'Add' could not be
found (*are you missing a using directive or an assembly reference?*)

Basic.cs(22,9): error CS0246: The type or namespace name 'Add' could not
be found (are you missing a using directive or an assembly reference?)

Tried Methods:

1. I will add the reference via Project-> Add Reference.

2. The using Reference also used.
Posted

1 solution

Start differently: Use VS to add a new project to your solution, and tell it to create a class library. It will then create a project with a default "class1" which you can modify to fit your needs as it will contain a valid basic file framework. When you build it, it will produce a .NET DLL assembly for you that should work fine.

You can then add a reference to that project (or the built DLL) to your otehr project and access the methods either directly via their full name: MyAssemblyNamespace.MyClass.Add or by adding the appropriate using statement to your code:
C#
using MyAssemblyNamespace;
...
    MyClass mc = new MyClass();
    mc.Add(...);
 
Share this answer
 
Comments
ahamednafeel 19-May-15 23:49pm    
Boss am not creating a normal DLL. Am creating a Native DLL.
OriginalGriff 20-May-15 3:13am    
No, you aren't! :laugh:
C# does not create Native DLLs - it creates .NET DLL Assembly files.
To generate a native DLL, you pretty much have to use C++, not C#.

It is in theory possible to create a "native-a-like" DLL which can be called from Native apps, but it's not trivial at all:
https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports
ahamednafeel 20-May-15 21:59pm    
Yes, You are right.. Am creating a Native DLL by using CPP with the use of C# net module. I have an Issue. Is there any possibility to Merge a DLL file into Another??
OriginalGriff 21-May-15 5:18am    
I don't know of anything that automatically does that, and it wouldn't work anyway if your two DLL files are Native and .NET - the latter are not "real" DLLs, they are intermediate code assemblies and have totally different startup needs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900