Query: In my DLL, Could I have C++ file & C# file
In my DLL, Could I have C++ file that exports functions in traditional way using __declspec(dllexport), and have remaining code written in C# file?
This is because: myDLL is a bridge between two applications.
Application_1 wants me to export functions using __declspec(dllexport).
Application_2 has APIs exposed in C#.
Re: Query: In my DLL, Could I have C++ file & C# file
You can if you use C++/CLI.
Create an ordinary Win32 (native) dll project and set the "common language support" option in the project options to "common language support /clr".
Alternatively native C++ code can interact with C# dlls using COM. See here.
Darwen.
Re: Query: In my DLL, Could I have C++ file & C# file
Thanks darwen. but i am getting some build problem when i try to call the methods defined in the *.cs file.
i have opened *.cs file through 'File | New... | C# | C# Class file'
//myClass.cs file
using System;
/// <summary>
/// Summary description for Class1
/// </summary>
///
namespace mynameSpace
{
public class myClass
{
public myClass()
{
//
// TODO: Add constructor logic here
//
}
public int clConnect()
{
return 1;
}
public int clQuit()
{
return 1;
}
}
}
// cpp file has this
...
using namespace mynameSpace ;
int clConnect()
{
return myClass::clConnect();
}
int clQuit()
{
return myClass::clQuit();
}
//errors i am getting at build time of the DLL
1>.\export_functions.cpp(19) : error C2871: 'mynameSpace' : a namespace with this name does not exist
1>.\export_functions.cpp(27) : error C2653: 'myClass' : is not a class or namespace name
1>.\export_functions.cpp(35) : error C2653: 'myClass' : is not a class or namespace name
Re: Query: In my DLL, Could I have C++ file & C# file
Sorry : I missed an important point. You'll have to convert your C# code to C++/CLI.
Darwen.
Re: Query: In my DLL, Could I have C++ file & C# file
I've found these on some more searching :
http://www.codeguru.com/forum/showth...ight=netmodule
and
http://blogs.msdn.com/frankpr/archiv...27/198918.aspx.
However I'd still recommend just converting your C# code to C++/CLI.
Darwen.