How to use a DLL written in C# in other asp.net project? -



How to use a DLL written in C# in other asp.net project? -

i have file named common.cs contains commonly used functions this

public int getcolumnindexbynametemplatefield(gridviewrow row, string searchcolumnname) { int columnindex = 0; foreach (datacontrolfieldcell cell in row.cells) { if (cell.containingfield templatefield) { if (((templatefield)cell.containingfield).headertext.equals(searchcolumnname)) { break; } } columnindex++; } homecoming columnindex; }

now want create common.cs file alter common.dll, created class library project in copied code common.cs file, added necessary references , built generate dll file, pasted dll file project debug directory bin directory of asp.net project using common.cs whenever seek import dll using.

[dllimport("common.dll")] public static extern string newstring(string x);

where newstring function, error.

unable find entry point named 'newstring' in dll 'common.dll'.

i have checked posted questions on stackoverflow other guides on net tell how create , utilize dll don't know why getting error of guides show dll written in c++ dll written in c#, tell utilize __declspec(dllexport) tells function ready exported or can't utilize in c# dll suppose.

i think basic question first time creating dll in c# please help me out.

thanks.

ahmed if want turn project library (.dll), double click 'properties' folder in solution explorer. click drop-down project type , select 'class library' click build, rebuild solution recompile .dll.

note can create new asp.net project in same solution right clicking solution , clicking 'add project'. or can open new instance of visual studio. 1 time open asp.net project right click on references , click add together reference. click browse tab, navigate folder containing .dll , add together it. don't forget classes defined in .dll must marked public or not visible in other assemblies. don't forget using statements namespaces classes defined in.

when click 'run button' (the greenish arrow) run project in bold in solution explorer. if .dll bolded error cannot run class library must instead alter console application. if console application must have static void main() function defined knows start. can set project startup project right clicking in solution explorer , click 'set startup project'.

if wish run programme in solution, not want set start programme can right click, go debug , run. organizing like-projects in single solution can create maintaining them much easier.

hope helps.

c# asp.net dll dllimport

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -