1. Can't debug DLL's with "Multi-threaded Debug DLL" under VS 2003
Hi,
For some strange reason debugging a DLL only works for me when I
compile with Single-Threaded or Multi-Threaded, not with
Multi-Threaded DLL.
I have done the following in Visual Studio 2003:
I created a Win 32 DLL project with the project wizard (console
project with application setting "DLL" and "export symbols") and a Win
32 console project (console project with application setting "console
application").
The wizard will generate one mini function (called fnsomething) in the
DLL project. I will call just that from the console main project.
I make the console project dependant of the DLL project so the export
library of the DLL project gets used automatically.
I set the compile options for both projects to "Multi-Threaded Debug",
compile the DLL project and copy the DLL to the executable directory
of the console project.
Single stepping through the DLL function works fine.
But when I change both projects to "Multi-Threaded Debug DLL",
single-stepping doesn't work anymore (sure I copied the DLL again
after recompiling the DLL project). At program start VS doesn't say
"debug symbols" loaded anymore for the loaded DLL, now it says only
"exports loaded", which means it can't find the symbols anymore. But
the .pdb file is still there.
Has anyone a explanation for this?
Regards,
Gunter
2. Can't debug DLL's with "Multi-threaded Debug DLL" under VS C++ 2003 - Visual Studio
3. C# program can't find namespace of classes in C++ dll
4. Yet Another: Can't call C++ dll functions from C#
5. Can't pass simple array to a C++ DLL
I am having some problems with passing an array to a C++ dll. I have tried
2 techniques, and neither work.
Here is my DLL:
__declspec(dllexport) int Test(short* pArray)
{
short First;
short Second;
short Third;
First = pArray[0];
Second = pArray[1];
Third = pArray[2];
return 0;
}
Very simple, get a pointer and store the first 3 int16's pointed to by the
pointer.
Here is my definition in VB.Net:
<DllImport(MYDLLSHORT, _
CallingConvention:=CallingConvention.Cdecl)> _
Friend Function Test(ByRef MyArrayPointer As IntPtr) As Integer
End Function
Here is my test code:
Dim Test1(100) As Short
Test1(0) = 3
Test1(1) = 2
Test1(2) = 1
' pin variable and create GC handle instance
Dim gh As GCHandle = GCHandle.Alloc(Test1, GCHandleType.Pinned)
' get address of variable
Dim AddrOfTest1 As IntPtr = gh.AddrOfPinnedObject()
Test(Test1)
When I run the code and break inside the Test function, I find that pArray
does not point to the array. The variables First, Second, and Third are
loaded with the first 3 int16's but the array is not there. If it worked
correctly, First would be 3, Second would be 2, and Third would be 1.
So I changed to this VB code:
Dim AddrOfTest1 As IntPtr = Marshal.AllocHGlobal(200)
Marshal.Copy(Test1, 0, AddrOfTest1, 100)
The same thing happens. The C code loads First, Second, and Third with the
first 3 16 bit words pointed to by the pointer, but it is not the array
data.
The array data should be 3, 2, 1, followed by 98 words of 0.
Can you tell me why the pointers returned by AllocHGlobal and
AddrOfPinnedObject are not pointing to my array?
Thank you for your help.
Clark
6. Can't access COBOL DLL from C# program
I get an error when trying to add a reference to a DLL program from a Realia
COBOL program that is 32 bit. The error message says "Please make sure the
file is accessible and that it is a valid assembly or COM component. I can
access this file using C++ but not C#. My COBOL DLL program passes data by
reference. My coding is shown below:
[DllImport("progcmp1.dll", CharSet=CharSet.Auto, EntryPoint="TRANPROG",
CallingConvention=CallingConvention.StdCall)]
public static extern void TRANPROG(string parms);
private void OnSubmit(object sender, EventArgs e)
{
StringBuilder parms = new StringBuilder("00000000", 87);
TRANPROG(parms.ToString());
}