PtrToStringChars Cannot convert unsigned char * to System::String *

M

Madhu_TN

Hi All,
I am new to this board. I am trying to create a Crystal Report viewer into a
VS C++ Dot NET 2003 app ( This uses both managed and unmanaged code).

I get the following compilation error:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\
cstringt.h(875): error C2664: 'PtrToStringChars' : cannot convert parameter 1
from 'unsigned char *' to 'const System::String __gc *'

The code segemnt is:
#pragma once
#pragma managed
void CDailyRep::OnBnClickedNewreportsOk()
{
/*********************************************************/

CrystalDecisions::CrystalReports::Engine::ReportDocument * crReportDocument =
new ReportDocument();
// ReportDocument::FileName = "BATCH.RPT" ;
// ReportDocument::FilePath = "c:\\QpayReports_CR10\\" ;
crReportDocument->Load(L"C:\\QpayReports_CR10\\Batch.RPT",OpenReportMethod::
OpenReportByTempCopy);
// crReportDocument->Load(( System::String __gc*)L"c:\\QpayReports_CR10\\
BATCH.RPT"); // ,OpenReportMethod::OpenReportByTempCopy);
// crReportDocument->Load("c:\\QpayReports_CR10\\BATCH.RPT"); // ,
OpenReportMethod::OpenReportByTempCopy);
// crReportDocument->Load(reportDocument) ;

// char * file1 = "c:\\QpayReports_CR10\\BATCH.RPT";
// wchar_t *file1 = L"c:\\QpayReports_CR10\\BATCH.RPT";
// String* file = System::Runtime::InteropServices::Marshal.PtrToStringAnsi
(file1[0]);
// String* file = Marshal::ptrToStringAnsi("c:\\QpayReports_CR10\\BATCH.RPT")
;
// String* file = Marshal::ptrToStringAnsi(file1);
// String *file = __gc new String(file1); // char *.
// String *file = __gc new String("c:\\QpayReports_CR10\\BATCH.RPT"); // char
*.

// String *file = __gc new String("c:\\QpayReports_CR10\\BATCH.RPT"); // char
*.
// String *file
// crReportDocument->Load((String *)file);
// crReportDocument->Load(__gc new String("c:\\QpayReports_CR10\\BATCH.RPT"))
;
// crReportDocument->Load((__wchar_t)L"c:\\QpayReports_CR10\\BATCH.RPT");

My command lin ios :
/G7 /GA /I "C:\TUXEDO\include" /I "C:\Program Files\Common Files\Crystal
Decisions\2.5\managed" /AI "C:\Program Files\Common Files\Crystal Decisions\2.
5\managed\en" /AI ".\Release" /D "NDEBUG" /D "_DWIN32" /D "WIN32" /D
"_WINDOWS" /D "WINNT" /D "_AFXDLL" /D "_MBCS" /FD /MD /GS /J /Zc:wchar_t
/Yu"stdafx.h" /Fp".\Release/Qpay.pch" /Fo".\Release/" /Fd".\Release/vc7.0.
pbd" /W3 /nologo /c /Zi /clr /TP

No matter what i use, the agrument passed to PtrToStringChars is always an
unsigned char *. I am at the end of my wits can any one please help?
Thanks,
Madhu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top