[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

App is crashing after communicating with ActiveX control

nickdu

5/23/2007 1:06:00 AM

We're having some trouble getting our .NET 2.0 application working with an
ActiveX control. We're using the RTList control
(http://www.xyris.com/products/...). I've created the interop
assemblies using aximp. It appears that we're communicating with the control
and get back the results, but sometime afterwards our application terminates
with no messages. I did attach WinDbg to our application, and while I'm not
sure we had the proper symbols for the OS, it appeared we terminated because
we jumped to some invalid location (eip was some invalid address). We're
using events exposed by the ActiveX control to communicate with it. Is there
anything special we need to be aware of in this interop scenario? Our
application does have the [STAThread] attribute on the Main() entry point.

Below is a snippet of our code:

// Initialization

internal RTListPricingFeedManager(VWAPMultiplier[] vwapMultipliers,
Country[] volume1xPrice1Countries,
Exchange[] ignoreVolumeAccumulatedExchanges, string reutersSource, string
bloombergSource)
{
_hiddenContainerForm = new HiddenContainerForm();
_axRTList = _hiddenContainerForm._axRTList;

_axRTList.ChangeEx += new
AxRTList._DRTListEvents_ChangeExEventHandler(_axRTList_ChangeEx);
_axRTList.SnapComplete += new EventHandler(_axRTList_SnapComplete);

foreach (VWAPMultiplier vwapMultiplier in vwapMultipliers)
_countryToVWAPMultiplier.Add(vwapMultiplier.Country,
vwapMultiplier.Multiplier);

foreach (Country country in volume1xPrice1Countries)
_volume1xPrice1CountriesSet.Add(country.Name, null);

foreach (Exchange exchange in ignoreVolumeAccumulatedExchanges)
_ignoreVolumeAccumulatedExchangesSet.Add(exchange.Name, null);

_reutersSourceName = reutersSource;
_bloombergSourceName = bloombergSource;
}

// Method that kicks off the work.

internal override bool Request(
Pricing.StrikeOption strikeOption,
SecurityCollection securityCollection,
IPricingResults pricingResults,
Pricing.PrimaryOrComposite otcPorC,
Pricing.PrimaryOrComposite listedPorC,
TimeSpan compositeStartTime,
TimeSpan compositeEndTime,
TimeSpan primaryStartTime,
TimeSpan primaryEndTime,
DateTime vwapDate,
int timeout,
bool allowException,
out string errorText)
{
bool retVal = true;

_currentSecurityCollection = securityCollection;
_currentPricingResults = pricingResults;

errorText = "";

try
{
_axRTList.Clear();

if (_log.IsDebugEnabled)
_log.DebugFormat("RTList Source = '{0}'", GetSourceText(strikeOption));

_axRTList.Source = GetSourceText(strikeOption);

_strikeOptionArray = new Pricing.StrikeOption
[_currentSecurityCollection.Count];
int index = 0;
foreach (Security security in _currentSecurityCollection)
{
string requestString = GetRequestString(security, strikeOption, otcPorC,
listedPorC, compositeStartTime, compositeEndTime, primaryStartTime,
primaryEndTime, vwapDate);

if (_log.IsDebugEnabled)
_log.DebugFormat("Adding request item: '{0}'", requestString);

_axRTList.AddItem(requestString, index);
_strikeOptionArray[index] = strikeOption;
index++;
}

_snapComplete = false;

if (_log.IsDebugEnabled)
_log.Debug("Sending request");

_axRTList.Mode = (short)Modes.Manual;

int sleepDuration = 100;

for (int i = 0; i < timeout / 100; i++)
{
Application.DoEvents();

if (_snapComplete)
break;

System.Threading.Thread.Sleep(sleepDuration);
}

if (!_snapComplete)
throw new ApplicationException("Request timed out");
}
catch (Exception e)
{
if (allowException)
throw;

retVal = false;
errorText = e.Message;
}

return retVal;
}

// Event handlers

private void _axRTList_ChangeEx(object sender,
AxRTList._DRTListEvents_ChangeExEvent e)
{
int index = e.itemIndex;

Security security = _currentSecurityCollection[index];
try
{
double resultValue = CalculateResultValue(security,
_strikeOptionArray[index], (object[])_axRTList.ItemValueToArray(index));
_currentPricingResults.SetResult(security, resultValue);
}
catch (Exception exc)
{
_log.Warn("Error in _axRTList_ChangeEx", exc);
}
}

private void _axRTList_SnapComplete(object sender, EventArgs e)
{
_axRTList.Mode = (short)Modes.None;
_snapComplete = true;

if (_log.IsDebugEnabled)
_log.Debug("Snap complete");
}

Also, this class above is a member of another class that is a member of a
WinForm. Each time we price something (use this ActiveX to get a price) we
create a new instance of this WinForm which creates a pricing component which
creates the above component. And as you can see the above component creates
a HiddenContainerForm which contains the ActiveX control. I know that was
probably a confusing explanation.
--
Thanks,
Nick

nicknospamdu@community.nospam
remove "nospam" change community. to msn.com
1 Answer

wawang

5/23/2007 12:27:00 PM

0

Hi Nick,

I've carefully reviewed your code and post, also read some related articles
on handling COM events from .NET. Honestly, I cannot see some obvious
problem in your code. Handling COM events using .NET delegate is fully
supported.

Can you reproduce the issue using some reliable steps? If it's random, I
think a live debugging or dump analysis is needed to find the root cause.

I'm sorry that I really cannot provide much help from here. I suggest use
one of your MSDN subscription support incident and contact our Customer
Support and Service (see my signature). Thank you for your understanding.


Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/de....
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.