RE: Runtime problem when using .Net connector

[email protected] Sun, 7 Nov 2004 23:59:25 -0800
Newsgroups gmane.comp.web.mod-pubsub.devel
Message-ID <CA4D186E24985848974590F39B79777C1F55@w2k3-exchange.home.chhuoii.com>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C4C568.E29230DE
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

It wouldn't let me send with the .zip files. So if are interested, send
me an email and I'll send the .zip to you directly.
=20
Tommy

________________________________

From: Tommy Hui=20
Sent: Sunday, November 07, 2004 11:46 PM
To: '[email protected]'
Subject: RE: [Mod-pubsub-developer] Runtime problem when using .Net
connector


Hi everyone!
=20
Okay, I've gotten it to work finally with VC71. Apparently, due to a bug
with VC71, the DotNet layer doesn't work. It ultimately leads to a
coding area that has been vauge with MC++.
=20
There's a workaround fix to the code in the DotNet directory. Note that
you should only do this if you are compiling with VC71. The code changes
I'm about to show you do not have the proper #ifdefs around it to ensure
only VC71 pick up the changes. If you ever want to build with any of the
older compilers, it will likely fail. There are two affected files:
=20
MessageM.h
MessageM.cpp
=20
The problem is the unmanaged C++ stl type is part of the managed class.
Apparently, VC71 no longer likes to generate the proper metadata for any
unmanaged types. Therefore, the change is to make the iterator
implementation completely hidden from the managed class. Change the type
of m_Iter from=20
=20
  ::Message::Container::const_iterator* m_Iter;
=20
to
=20
  void* m_Iter;
=20
The next step is that in the MessageEnumerator methods that use m_Iter,
we need to cast it to back to the const_iterator:
=20
Object* MessageEnumerator::get_Current()
{
 if (m_Iter =3D=3D 0)
  throw new InvalidOperationException();
=20
 ::Message::Container::const_iterator* temp =3D
(::Message::Container::const_iterator*)m_Iter;
=20
 if ((*temp) =3D=3D m_Message->GetImpl()->GetContainer().end())
  throw new InvalidOperationException();
=20
 MessageEntry* me =3D new MessageEntry();
 me->Field =3D new String((*(*temp)).first.c_str());
 me->Value =3D new String((*(*temp)).second.c_str());
=20
 return me;
}
=20
void MessageEnumerator::Reset()
{
 if (m_Iter)
 {
  ::Message::Container::const_iterator* temp =3D
(::Message::Container::const_iterator*)m_Iter;
  delete temp;
  m_Iter =3D 0;
 }
}
=20
bool MessageEnumerator::MoveNext()
{
 if (m_Message->GetImpl()->GetContainer().empty())
  return false;
=20
 if (m_Iter =3D=3D 0)
 {
  m_Iter =3D new ::Message::Container::const_iterator();
  ::Message::Container::const_iterator* temp =3D
(::Message::Container::const_iterator*)m_Iter;
  *temp =3D m_Message->GetImpl()->GetContainer().begin();
  return true;
 }
=20
 ::Message::Container::const_iterator* temp =3D
(::Message::Container::const_iterator*)m_Iter;
=20
 (*temp)++;
=20
 bool retVal =3D (*temp) !=3D =
m_Message->GetImpl()->GetContainer().end();
=20
 m_Iter =3D temp;
=20
 return retVal;
}
=20
For your convenience, I've attached the two affected files in the
MessageM.zip.
=20
Finally, when you build the sample files, you will need to do the
following to make it work with VC71:
=20
1. Convert the project over to VC71. You will need to make the files
writable.
2. Move the using LibKNDotNet statement from outside of the namespace to
inside the namespace to remove any ambiguity.
3. Remove the reference to LibKNDotNet assembly and change it to
LibKNDotNet71 or LibKNDotNet71D depending on whether it is debug or not.
=20
Tommy

________________________________

From: [email protected]
[mailto:[email protected]]=20
Sent: Sunday, November 07, 2004 10:39 PM
To: [email protected]
Subject: RE: [Mod-pubsub-developer] Runtime problem when using .Net
connector


Hi Rohit,
=20
Yes, I've been able to reproduce the problem. It appears the problem is
related to something VC7.1 is doing differently from VC7.0. I'm trying
to track down the issue and will let you know when I find something.
=20
Tommy

________________________________

From: [email protected]
[mailto:[email protected]]=20
Sent: Sunday, November 07, 2004 8:56 PM
To: '[email protected]'
Subject: [Mod-pubsub-developer] Runtime problem when using .Net
connector



Hi,=20
        I am facing a problem when I used the .Net connector (client) in
the given sample dotnet code. (It is supposed to work with Visual Studio
7.1 and later, I am using Visual Studio 2003).The python server is
running. I am able to successfully run the javascript examples. The
given .Net code (which subscribes to events for some stock quote web
service) compiles properly. But when I start it up , it throws an
exception saying could not load type const_iterator. The references path
etc. are correct. What could be the problem. I understand that the C++
connector code has been wrapped in managed C++ code and is then invoked
from the C# client. Any help would be appreciated.

Regards,=20
Rohit Khetan.=20


This message is free from Virus - IMSS
=09

------_=_NextPart_001_01C4C568.E29230DE
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Runtime problem when using .Net connector</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR></HEAD>
<BODY>
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2><SPAN=20
class=3D109445807-08112004>It wouldn't let me send with the .zip files. =
So if are=20
interested, send me an email and I'll send the .zip to you=20
directly.</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2><SPAN=20
class=3D109445807-08112004></SPAN></FONT>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2><SPAN=20
class=3D109445807-08112004>Tommy</SPAN></FONT></DIV><BR>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
<HR tabIndex=3D-1>
<FONT face=3DTahoma size=3D2><B>From:</B> Tommy Hui <BR><B>Sent:</B> =
Sunday,=20
November 07, 2004 11:46 PM<BR><B>To:</B>=20
'[email protected]'<BR><B>Subject:</B> RE:=20
[Mod-pubsub-developer] Runtime problem when using .Net=20
connector<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>Hi everyone!</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>Okay, I've gotten it to work finally with VC71. Apparently, due =
to a bug=20
with VC71, the DotNet layer doesn't work. It ultimately leads to a =
coding area=20
that has been vauge with MC++.</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>There's a workaround fix to the code in the DotNet directory. =
Note that=20
you should only do this if you are compiling with VC71. The code changes =
I'm=20
about to show you do not have the proper #ifdefs around it to ensure =
only VC71=20
pick up the changes. If you ever want to build with any of the older =
compilers,=20
it will likely fail. There are two affected files:</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>MessageM.h</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>MessageM.cpp</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>The problem is the unmanaged C++ stl type is part of the =
managed class.=20
Apparently, VC71 no longer likes to generate the proper metadata for any =

unmanaged types. Therefore, the change is to make the iterator =
implementation=20
completely hidden from the managed class. Change the type of m_Iter from =

</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>&nbsp; ::Message::Container::const_iterator* =
m_Iter;</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>to</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D390163507-08112004><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;void* m_Iter;</FONT></SPAN></DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff size=3D2>The =
next step is=20
that in the MessageEnumerator methods that use m_Iter, we need to cast =
it to=20
back to the const_iterator:</FONT></SPAN></DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>Object*=20
MessageEnumerator::get_Current()<BR>{<BR>&nbsp;if (m_Iter =3D=3D=20
0)<BR>&nbsp;&nbsp;throw new =
InvalidOperationException();</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2>&nbsp;::Message::Container::const_iterator* temp =3D=20
(::Message::Container::const_iterator*)m_Iter;</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>&nbsp;if ((*temp)=20
=3D=3D =
m_Message-&gt;GetImpl()-&gt;GetContainer().end())<BR>&nbsp;&nbsp;throw =
new=20
InvalidOperationException();</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2>&nbsp;MessageEntry* me =3D new =
MessageEntry();<BR>&nbsp;me-&gt;Field =3D new=20
String((*(*temp)).first.c_str());<BR>&nbsp;me-&gt;Value =3D new=20
String((*(*temp)).second.c_str());</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>&nbsp;return=20
me;<BR>}</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>void=20
MessageEnumerator::Reset()<BR>{<BR>&nbsp;if=20
(m_Iter)<BR>&nbsp;{<BR>&nbsp;&nbsp;::Message::Container::const_iterator* =
temp =3D=20
(::Message::Container::const_iterator*)m_Iter;<BR>&nbsp;&nbsp;delete=20
temp;<BR>&nbsp;&nbsp;m_Iter =3D 0;<BR>&nbsp;}<BR>}</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>bool=20
MessageEnumerator::MoveNext()<BR>{<BR>&nbsp;if=20
(m_Message-&gt;GetImpl()-&gt;GetContainer().empty())<BR>&nbsp;&nbsp;retur=
n=20
false;</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>&nbsp;if (m_Iter=20
=3D=3D 0)<BR>&nbsp;{<BR>&nbsp;&nbsp;m_Iter =3D new=20
::Message::Container::const_iterator();<BR>&nbsp;&nbsp;::Message::Contain=
er::const_iterator*=20
temp =3D =
(::Message::Container::const_iterator*)m_Iter;<BR>&nbsp;&nbsp;*temp =3D=20
m_Message-&gt;GetImpl()-&gt;GetContainer().begin();<BR>&nbsp;&nbsp;return=
=20
true;<BR>&nbsp;}</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2>&nbsp;::Message::Container::const_iterator* temp =3D=20
(::Message::Container::const_iterator*)m_Iter;</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2>&nbsp;(*temp)++;</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>&nbsp;bool retVal=20
=3D (*temp) !=3D=20
m_Message-&gt;GetImpl()-&gt;GetContainer().end();</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>&nbsp;m_Iter =3D=20
temp;</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>&nbsp;return=20
retVal;<BR>}</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff size=3D2>For =
your=20
convenience, I've attached the two affected files in the=20
MessageM.zip.</FONT></SPAN></DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff =
size=3D2>Finally, when you=20
build the sample files, you will need to do the following to make it =
work with=20
VC71:</FONT></SPAN></DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff size=3D2>1. =
Convert the=20
project over to VC71. You will need to make the files=20
writable.</FONT></SPAN></DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff size=3D2>2. =
Move the using=20
LibKNDotNet statement from outside of the namespace to inside the =
namespace to=20
remove any ambiguity.</FONT></SPAN></DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff size=3D2>3. =
Remove the=20
reference to LibKNDotNet assembly and change it to LibKNDotNet71 or=20
LibKNDotNet71D depending on whether it is debug or =
not.</FONT></SPAN></DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D390163507-08112004><FONT color=3D#0000ff=20
size=3D2>Tommy</DIV></FONT></SPAN><BR>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
<HR tabIndex=3D-1>
<FONT face=3DTahoma size=3D2><B>From:</B>=20
[email protected]=20
[mailto:[email protected]] =
<BR><B>Sent:</B>=20
Sunday, November 07, 2004 10:39 PM<BR><B>To:</B>=20
[email protected]<BR><B>Subject:</B> RE:=20
[Mod-pubsub-developer] Runtime problem when using .Net=20
connector<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D703143706-08112004><FONT =
color=3D#0000ff=20
size=3D2>Hi Rohit,</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D703143706-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D703143706-08112004><FONT =
color=3D#0000ff=20
size=3D2>Yes, I've been able to reproduce the problem. It appears the =
problem is=20
related to something VC7.1 is doing differently from VC7.0. I'm trying =
to track=20
down the issue and will let you know when I find =
something.</FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D703143706-08112004><FONT =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D703143706-08112004><FONT =
color=3D#0000ff=20
size=3D2>Tommy</FONT></SPAN></DIV><BR>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
<HR tabIndex=3D-1>
<FONT face=3DTahoma size=3D2><B>From:</B>=20
[email protected]=20
[mailto:[email protected]] =
<BR><B>Sent:</B>=20
Sunday, November 07, 2004 8:56 PM<BR><B>To:</B>=20
'[email protected]'<BR><B>Subject:</B>=20
[Mod-pubsub-developer] Runtime problem when using .Net=20
connector<BR></FONT><BR></DIV>
<DIV></DIV>
<P><FONT face=3DArial size=3D2>Hi,</FONT>=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face=3DArial =
size=3D2>I am=20
facing a problem when I used the .Net connector (client) in the given =
sample=20
dotnet code. (It is supposed to work with Visual Studio 7.1 and later, I =
am=20
using Visual Studio 2003).The python server is running. I am able to=20
successfully run the javascript examples. The given .Net code (which =
subscribes=20
to events for some stock quote web service) compiles properly. But when =
I start=20
it up , it throws an exception saying could not load type =
const_iterator. The=20
references path etc. are correct. What could be the problem. I =
understand that=20
the C++ connector code has been wrapped in managed C++ code and is then =
invoked=20
from the C# client. Any help would be appreciated.</FONT></P>
<P><FONT face=3DArial size=3D2>Regards,</FONT> <BR><FONT face=3DArial =
size=3D2>Rohit=20
Khetan.</FONT> </P><BR>
<TABLE>
  <TBODY>
  <TR>
    <TD bgColor=3D#ffffff><FONT color=3D#000000>This message is free =
from Virus -=20
      IMSS<BR></FONT></TD></TR></TBODY></TABLE></BODY></HTML>

------_=_NextPart_001_01C4C568.E29230DE--


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click