Problem passing bitmap paths from C++ to .NET DLL
-
Folks here is another one, I do all operations on bitmaps within .NET DLL project, while the DLL is being used by a C++ project(windows project to be exact). When I perform operations on bitmaps I have to pass locations of them from C++ project to .DLL. BSTR bla(L"C:\\temp\\TestDLL1.bmp_BGL.bmp"); BSTR bla1(L"C:\\temp\\TestDLL1.bmp_GDI.bmp"); HRESULT hr = myobject->Load2BitmapsfromFile(bla, bla1, 50, &m); Vb.NET DLL project is set to recieve these path locations as parameters and based on them create bitmaps and more. The problem raises when I run my C++ project and debug to realize that the strings used to pass bitmap locations to .DLL are now empty. Thus I got nothing useful from that method in DLL. Any commnets on this would be helpful. Thank you, Sincerely, Max Pastchenko
-
Folks here is another one, I do all operations on bitmaps within .NET DLL project, while the DLL is being used by a C++ project(windows project to be exact). When I perform operations on bitmaps I have to pass locations of them from C++ project to .DLL. BSTR bla(L"C:\\temp\\TestDLL1.bmp_BGL.bmp"); BSTR bla1(L"C:\\temp\\TestDLL1.bmp_GDI.bmp"); HRESULT hr = myobject->Load2BitmapsfromFile(bla, bla1, 50, &m); Vb.NET DLL project is set to recieve these path locations as parameters and based on them create bitmaps and more. The problem raises when I run my C++ project and debug to realize that the strings used to pass bitmap locations to .DLL are now empty. Thus I got nothing useful from that method in DLL. Any commnets on this would be helpful. Thank you, Sincerely, Max Pastchenko
mpastchenko wrote: Vb.NET DLL project Why are you being so cruel to C++, to make it talk to VB ? :P Seriously though, what's the reason for this ? You can write GDI+ code in C++, you don't need .NET at all. mpastchenko wrote: The problem raises when I run my C++ project and debug to realize that the strings used to pass bitmap locations to .DLL are now empty. The strings are constants and they are empty ? Or are you not looking at them properly ? Can the IDE show the contents of a BSTR ? If they are constants, they simply cannot be empty, as far as I can see. Why not debug the dll and see what ends up in VB.NET ? Or just put in a log file or something. Christian Graus - Microsoft MVP - C++
-
mpastchenko wrote: Vb.NET DLL project Why are you being so cruel to C++, to make it talk to VB ? :P Seriously though, what's the reason for this ? You can write GDI+ code in C++, you don't need .NET at all. mpastchenko wrote: The problem raises when I run my C++ project and debug to realize that the strings used to pass bitmap locations to .DLL are now empty. The strings are constants and they are empty ? Or are you not looking at them properly ? Can the IDE show the contents of a BSTR ? If they are constants, they simply cannot be empty, as far as I can see. Why not debug the dll and see what ends up in VB.NET ? Or just put in a log file or something. Christian Graus - Microsoft MVP - C++
In instead of having next programmer, work with GDI+ and put that constraint on him (this is a only a part of the project that will be used by someone else), I would rather contain all GDI+ in .NET thats why I am using paths (strings). So its easier for someone else, especially if not familiar with GDI+ directly to just say: LoadANDCompareMaps(bstingpath1, bstringpath2, etc) The solution to my priblem is quite simple: I was declaring my binary strings incorrectly correct syntax: BSTR bla = SysAllocString(L"C:\\temp\\TestDLL3.bmp_BGL.bmp"); Thank you Sincerely, Max Pastchenko P.S. I debugged on VB side with C++ executable and thats how I found that they were empty. And as far as i see C++ is talking to a .NET DLL which is created by VB.NET