|
Hi,
I'm having trouble in transferring arrays of short integers from C++ library to C# application.
I got the sources of a library, written in C++, that defines interface in IDL file.
The original methods transfer "basic" objects, such as BOOL and BSTR.
I need to add a new method to the interface for transferring two arrays of short integers.
For that purpose, I create two safe arrays and populate them with the numbers.
However, when I try to invoke the C# method I get TypeMismatch error code (when I pass only the string objects, it works OK).
The C++ code includes the following definition in IDL file:
library CodecLib
{
...
dispinterface _ILiveEvents
{
properties:
methods:
...
[id(4), helpstring("method DataReady")] HRESULT DataReady([in] BSTR strForward, [in] SAFEARRAY(short) FwdBuffer, [in] BSTR strReturn, [in] SAFEARRAY(short) RetBuffer);
};
...
};
The following C# code implements the interface defined in the IDL file:
private void DataReady(string sForward, Array ForwardData,
string sRetrun, Array ReturnData)
{
...
}
The following C++ code prepares the data in the safe arrays:
void CLive::DataReady(short *pFwdBuf, short *pRetBuf, int nBufferSize)
{
long lIndex;
SAFEARRAYBOUND ArrayBound[2];
ArrayBound[0].cElements = nBufferSize;
ArrayBound[0].lLbound = 0;
ArrayBound[1].cElements = nBufferSize;
ArrayBound[1].lLbound = 0;
m_pFwdBuffer = SafeArrayCreate(VT_I2, 1, &ArrayBound[0]);
m_pRetBuffer = SafeArrayCreate(VT_I2, 1, &ArrayBound[1]);
// Set data in safe arrays
for (lIndex=0; lIndex<nBufferSize; lIndex++)
{
SafeArrayPutElement(m_pFwdBuffer, &lIndex, &pFwdBuf[lIndex]);
SafeArrayPutElement(m_pRetBuffer, &lIndex, &pRetBuf[lIndex]);
}
// Send data to clients
Fire_DataReady(m_strForward, m_pFwdBuffer, m_strReturn, m_pRetBuffer);
// Release safe arrays
SafeArrayDestroy(m_pFwdBuffer);
SafeArrayDestroy(m_pRetBuffer);
m_pFwdBuffer = NULL;
m_pRetBuffer = NULL;
}
The following C++ code distributes the data to the clients.
However, calling Invoke() returns TypeMismatch error, with uArgErr equals to 3:
HRESULT Fire_DataReady(BSTR strForward, SAFEARRAY *pFwdBuf,
BSTR strReturn, SAFEARRAY *pRetBuf)
{
HRESULT hr = S_OK;
T * pThis = static_cast<T *>(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
if (pConnection)
{
CComVariant avarParams[4];
avarParams[0] = strForward;
avarParams[0].vt = VT_BSTR;
avarParams[1] = pFwdBuf;
avarParams[1].vt = VT_ARRAY;
avarParams[2] = strReturn;
avarParams[2].vt = VT_BSTR;
avarParams[3] = pRetBuf;
avarParams[3].vt = VT_ARRAY;
CComVariant varResult;
unsigned int uArgErr;
DISPPARAMS params = { avarParams, NULL, 4, 0 };
hr = pConnection->Invoke(4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, &uArgErr);
}
}
return hr;
}
|
|
|
|
|
Dear Mr.Lampors,
Hi, I'm Monalisa. I want to ask for a guidance in terms of understanding the program. If you don't mind, I want to ask the algorithm of visible watermarking text to image using DCT (step by step/ details). thanks a lot for your kindly response and help..
Best Regards,
Monalisa
|
|
|
|
|
Hello, sorry for the late response but for some reason new posts here stopped coming to my e-mail..
I have to say I'm a little confused. Visible watermarking and DCT? DCT is used for embedding some text invisibly inside the image in the frequency domain.
For a visible text watermark DCT is not used. I just draw it over the image in any place the user wants it..
|
|
|
|
|
Dear Mr. Lampors
I want to ask for a guidance in terms of understanding your program. If you don't mind, could you sent me the algorithm of DCT for visible watermarking text to image (step by step/ details).Thanks for your kindly response.
Best regards,
Monalisa
Monalisa
|
|
|
|
|
Plz do some thing i need it for study
|
|
|
|
|
What file not found?? I tried them, it works for me..
Codeproject had some technical issues, please try it again..
If the problem exists report it, or tell me to report it.
|
|
|
|
|
Thanks for reply
it was some technical issue
Thanks again
|
|
|
|
|
How can i run the exe file of Porpocune ?
Monalisa
|
|
|
|
|
You should be able to run it after you download it and unzip it.
But if you get errors for missing dlls, then you should download all the 3 files of the Required dlls, unzip them, and put the dlls in the same folder with the exe file.
|
|
|
|
|
This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem..
Thats the answer...
Can u help me ???
Thx before...
Monalisa
|
|
|
|
|
|
yes, i did...
i already put dlls into Excutable's folder..
is it true ??
thx
Monalisa
|
|
|
|
|
d:\Lisa\Porcupine\cximage599c_full\Source\Matrix.cpp(1030): error C2316: 'CFileException &' : cannot be caught as the destructor and/or copy constructor are inaccessible
i cannot understand this...
what does i have to do in order to correct this statement ???
this is the error statement that i found when i running Porcupine's program.
can u help me ? because it's very important for me..
thanx for your help..
Monalisa
|
|
|
|
|
It's been quite some time since i wrote the program.. I used visual studio 6 and afterwards visual studio 2005. It may probably be a compiler issue. Try VS6 and if it isn't working VS 2005..
|
|
|
|
|
Hi Lampros,
I have followed your instruction in compiling the code. I am using VC++ 6.0 First I have downloaded the CxImage Library and do a batch build. everything goes smoothly. Then I have placed the Porcupine source files and the required LIB's and do a compilation. I get the following errors:-
eikonaView.cpp
d:\watermark\cximage\eikonaview.cpp(409) : warning C4018: '<' : signed/unsigned mismatch
lumiance.cpp
d:\watermark\cximage\lumiance.cpp(63) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
MainFrm.cpp
Generating Code...
Compiling...
mass.cpp
Matrix.cpp
d:\watermark\cximage\matrix.cpp(677) : error C2374: 'i' : redefinition; multiple initialization
d:\watermark\cximage\matrix.cpp(669) : see declaration of 'i'
d:\watermark\cximage\matrix.cpp(714) : error C2374: 'i' : redefinition; multiple initialization
d:\watermark\cximage\matrix.cpp(706) : see declaration of 'i'
I got rid of the error "error C2374: 'i' : redefinition; multiple initialization" by putting a
#define for if(0);else for
in the matrix.cpp file declaration. After that I get the following error message:
Deleting intermediate files and output files for project 'eikona - Win32 Debug'.
--------------------Configuration: eikona - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
BlowFish.cpp
ChildFrm.cpp
dctdialog.cpp
dpassword.cpp
eikona.cpp
eikonaDoc.cpp
d:\watermark\cximage\eikonadoc.cpp(1393) : warning C4244: '=' : conversion from 'double' to 'unsigned char', possible loss of data
d:\watermark\cximage\eikonadoc.cpp(1496) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
Generating Code...
Compiling...
eikonaView.cpp
d:\watermark\cximage\eikonaview.cpp(409) : warning C4018: '<' : signed/unsigned mismatch
ftpaccess.cpp
ImInfo.cpp
jpegquality.cpp
lumiance.cpp
d:\watermark\cximage\lumiance.cpp(63) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
MainFrm.cpp
Generating Code...
Compiling...
mass.cpp
Matrix.cpp
Mixer.cpp
noise.cpp
password.cpp
pixelcolor.cpp
Generating Code...
Compiling...
progress.cpp
psnr.cpp
quickmenu.cpp
result.cpp
rotate.cpp
seed.cpp
Generating Code...
Compiling...
spatialtext.cpp
statistical.cpp
technical.cpp
text.cpp
textr.cpp
thresh.cpp
Generating Code...
Compiling...
urldialog.cpp
WebGrab.cpp
Generating Code...
Linking...
Creating library Debug/eikona.lib and object Debug/eikona.exp
eikona.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::Scanf(char const *,void *)" (?Scanf@CxMemFile@@UAEJPBDPAX@Z)
eikonaDoc.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::Scanf(char const *,void *)" (?Scanf@CxMemFile@@UAEJPBDPAX@Z)
eikonaView.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::Scanf(char const *,void *)" (?Scanf@CxMemFile@@UAEJPBDPAX@Z)
mass.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::Scanf(char const *,void *)" (?Scanf@CxMemFile@@UAEJPBDPAX@Z)
eikona.obj : error LNK2001: unresolved external symbol "public: virtual char * __thiscall CxMemFile::GetS(char *,int)" (?GetS@CxMemFile@@UAEPADPADH@Z)
eikonaDoc.obj : error LNK2001: unresolved external symbol "public: virtual char * __thiscall CxMemFile::GetS(char *,int)" (?GetS@CxMemFile@@UAEPADPADH@Z)
eikonaView.obj : error LNK2001: unresolved external symbol "public: virtual char * __thiscall CxMemFile::GetS(char *,int)" (?GetS@CxMemFile@@UAEPADPADH@Z)
mass.obj : error LNK2001: unresolved external symbol "public: virtual char * __thiscall CxMemFile::GetS(char *,int)" (?GetS@CxMemFile@@UAEPADPADH@Z)
eikona.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::DestroyFrames(void)" (?DestroyFrames@CxImage@@QAE_NXZ)
eikonaDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::DestroyFrames(void)" (?DestroyFrames@CxImage@@QAE_NXZ)
eikonaView.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::DestroyFrames(void)" (?DestroyFrames@CxImage@@QAE_NXZ)
mass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::DestroyFrames(void)" (?DestroyFrames@CxImage@@QAE_NXZ)
eikonaView.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::AlphaCreate(void)" (?AlphaCreate@CxImage@@QAE_NXZ)
mass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::AlphaCreate(void)" (?AlphaCreate@CxImage@@QAE_NXZ)
Debug/eikona.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
eikona.exe - 15 error(s), 4 warning(s)
I tried all sorts of combinations but I failed to make it work.
Can anyone help me in solving the problem.
With Regards,
Sarbashish Bhattacharjee
|
|
|
|
|
have you installed .net framework? and project's related dll for image working?
|
|
|
|
|
Hi,
I got exactly the same issue after having downloaded your exe and also adding all DLL in same directory.
Could you just detail how to install .Net framework ?
With regards
PY
PYC
|
|
|
|
|
Hi,
I am trying to run your porcupine for last couple of days.. but no success! I tried it in every possible ways.. finally I stucked with the the following errors -
Linking...
Creating library Debug/eikona.lib and object Debug/eikona.exp
eikonaDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Load(char const *,unsigned long)" (?Load@CxImage@@QAE_NPBDK@Z)
eikonaView.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Load(char const *,unsigned long)" (?Load@CxImage@@QAE_NPBDK@Z)
mass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Load(char const *,unsigned long)" (?Load@CxImage@@QAE_NPBDK@Z)
eikonaDoc.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Save(char const *,unsigned long)" (?Save@CxImage@@QAE_NPBDK@Z)
mass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CxImage::Save(char const *,unsigned long)" (?Save@CxImage@@QAE_NPBDK@Z)
eikonaView.obj : error LNK2001: unresolved external symbol "public: long __thiscall CxImage::DrawString(struct HDC__ *,long,long,char const *,struct tagRGBQUAD,char const *,long,long,unsigned char,unsigned char,bool)" (?DrawString@CxImage@@QAEJPAUHD
C__@@JJPBDUtagRGBQUAD@@1JJEE_N@Z)
mass.obj : error LNK2001: unresolved external symbol "public: long __thiscall CxImage::DrawString(struct HDC__ *,long,long,char const *,struct tagRGBQUAD,char const *,long,long,unsigned char,unsigned char,bool)" (?DrawString@CxImage@@QAEJPAUHDC__@@J
JPBDUtagRGBQUAD@@1JJEE_N@Z)
Debug/eikona.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Could you please help me out. Its really very urgent.
Regards
Dipangkur
|
|
|
|
|
These are library errors (CxImage Library). I didn't write the library so I can't say much. What compiler are you using?
You just want to run it or you need the code?
|
|
|
|
|
Thanks Lampros!
I find the error.. ya it was due to library error... now it is resolved..
Thanks once again..
Regards
Dipangkur
|
|
|
|
|
Hi Dipangkur
when I am trying to run Porcupine of Lampros I have the same problem with your, and I know that you had resolved it, Could you please help me.
I am new member of codeproject.com, so could you reply for me by my email: hvd_hutforever@yahoo.com
and hvd.hutforever@gmail.com
please send to both my email.
Thanks alot!
|
|
|
|
|