我有一个quickfix .net应用程序。我正在使用.net/c++ version of quickfix
有时我的应用程序抛出此错误,我无法用try catch块捕获它。 修复消息的长度大约是3000.我不会每次都收到此错误。 这是事件日志:
框架版本:v4.0.30319描述:该过程已终止 由于未处理的异常。例外信息: System.AccessViolationException Stack:at System.String..ctor(SByte *)at QuickFix.Group.getField(QuickFix.StringField)at FixApplication.onMessage(QuickFix44.MarketDataIncrementalRefresh, QuickFix.SessionID)at QuickFix44.MessageCracker.crack(QuickFix.Message,QuickFix.SessionID) 在QuickFix.MessageCracker.crack(QuickFix.Message,QuickFix.SessionID, QuickFix.BeginString)at QuickFix.MessageCracker.crack(QuickFix.Message,QuickFix.SessionID)
在FixApplication.fromApp(QuickFix.Message, QuickFix.SessionID)at .Application.fromApp(Application *, FIX.Message *,FIX.SessionID *)
引发错误的行:
public override void onMessage(QuickFix44.MarketDataIncrementalRefresh msg, SessionID sessionID)
{
try
{
var mdReqId = new MDReqID();
if (msg.isSet(mdReqId))
msg.get(mdReqId);
var noMdEntries = new NoMDEntries();
if (msg.isSet(noMdEntries))
msg.get(noMdEntries);
int noMdEntriesInt;
if (Int32.TryParse(noMdEntries.ToString(), out noMdEntriesInt))
{
for (uint i = 1; i <= noMdEntriesInt; i++)
{
var group = new MarketDataIncrementalRefresh.NoMDEntries();
Group repeatedData;
if (msg.isSet(noMdEntries))
{
repeatedData = msg.getGroup(i, group);
var mdUpdateAction = new MDUpdateAction();
if (repeatedData.isSetField(mdUpdateAction))
repeatedData.getField(mdUpdateAction);
var mdEntryType = new MDEntryType();
if (repeatedData.isSetField(mdEntryType))
repeatedData.getField(mdEntryType);
var symbol = new Symbol();
if (repeatedData.isSetField(symbol))
repeatedData.getField(symbol);
var mdEntryPx = new MDEntryPx();
if (repeatedData.isSetField(mdEntryPx))
repeatedData.getField(mdEntryPx);
var mdEntrySize = new MDEntrySize();
if (repeatedData.isSetField(mdEntrySize))
repeatedData.getField(mdEntrySize);
var numberOfOrders = new NumberOfOrders();
if (repeatedData.isSetField(numberOfOrders))
repeatedData.getField(numberOfOrders);
var mdEntryPositionNo = new MDEntryPositionNo();
if (repeatedData.isSetField(mdEntryPositionNo))
repeatedData.getField(mdEntryPositionNo);
var quoteCondition = new QuoteCondition();
if (repeatedData.isSetField(quoteCondition))
repeatedData.getField(quoteCondition);
var sysSymbolId = 0;
var mdEntryId = new MDEntryID();
if (repeatedData.isSetField(mdEntryId))
{
repeatedData.getField(mdEntryId);//THIS LINE THROWS ERROR
string strMdEntryId = mdEntryId.getValue();
}
//}
}
}
}
}
Functions.WriteDebugLog("OK");
}
catch (Win32Exception e)
{
Functions.WriteSystemLog("Ex Msg:" + e.ToString() + " Fix Msg : " + msg.ToString());
}
catch (Exception ex)
{
Functions.WriteSystemLog("Ex Msg:" + ex.ToString() + " Fix Msg : " + msg.ToString());
}
}
这是修复消息(您可以使用此在线工具解析它:http://fixloganalyzer.com/):
8 = FIX.4.4 | 9 = 2254 | 35 = X | 34 = 21998 | 49 = * | 50 = 的 * | 52 = 20140411-07:52:52.472 | 56 = ** | 262 = 1397202772472 | 268 = 42 | 279 = 1 | 278 = 25500 | 270 = 2.11636 | 271 = 3500000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 25501 | 270 = 2.11626 | 271 = 2000000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 25502 | 270 = 2.11616 | 271 = 3000000 | 276 = A | 290 = 3 | 279 = 1 | 278 = 25504 | 270 = 2.11596 | 271 = 7000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 25510 | 270 = 2.11716 | 271 = 3500000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 25512 | 270 = 2.11736 | 271 = 5000000 | 276 = A | 290 = 3 | 279 = 1 | 278 = 25513 | 270 = 2.11746 | 271 = 5000000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 25514 | 270 = 2.11756 | 271 = 6000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 204 | 270 = 1.38947 | 271 = 1500000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 600 | 270 = 0.93834 | 271 = 1000000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 601 | 270 = 0.93833 | 271 = 1000000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 602 | 270 = 0.93832 | 271 = 1000000 | 276 = A | 290 = 3 | 279 = 1 | 278 = 603 | 270 = 0.93831 | 271 = 2000000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 604 | 270 = 0.93821 | 271 = 2000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 610 | 270 = 0.93839 | 271 = 1000000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 611 | 270 = 0.9384 | 271 = 1500000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 613 | 270 = 0.93843 | 271 = 3500000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 614 | 270 = 0.93844 | 271 = 3000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 2200 | 270 = 1.09337 | 271 = 1000000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 2201 | 270 = 1.09336 | 271 = 1000000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 2203 | 270 = 1.09334 | 271 = 4000000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 2204 | 270 = 1.09333 | 271 = 1000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 2211 | 270 = 1.09344 | 271 = 2000000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 2214 | 270 = 1.09356 | 271 = 3000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 19600 | 270 = 1.08182 | 271 = 1000000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 19601 | 270 = 1.08181 | 271 = 1000000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 19602 | 270 = 1.0818 | 271 = 1000000 | 276 = A | 290 = 3 | 279 = 1 | 278 = 19603 | 270 = 1.08179 | 271 = 1000000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 19604 | 270 = 1.08178 | 271 = 1000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 19612 | 270 = 1.08205 | 271 = 1000000 | 276 = A | 290 = 3 | 279 = 1 | 278 = 19613 | 270 = 1.08206 | 271 = 1000000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 19614 | 270 = 1.08216 | 271 = 2000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 23600 | 270 = 1.51927 | 271 = 2000000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 23601 | 270 = 1.51926 | 271 = 1000000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 23602 | 270 = 1.51925 | 271 = 1000000 | 276 = A | 290 = 3 | 279 = 1 | 278 = 23603 | 270 = 1。 51915 | 271 = 3000000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 23604 | 270 = 1.51905 | 271 = 4000000 | 276 = A | 290 = 5 | 279 = 1 | 278 = 23610 | 270 = 1.51945 | 271 = 1500000 | 276 = A | 290 = 1 | 279 = 1 | 278 = 23611 | 270 = 1.51946 | 271 = 1000000 | 276 = A | 290 = 2 | 279 = 1 | 278 = 23612 | 270 = 1.51947 | 271 =百万| 276 = A | 290 = 3 | 279 = 1 | 278 = 23613 | 270 = 1.51957 | 271 = 2000000 | 276 = A | 290 = 4 | 279 = 1 | 278 = 23614 | 270 = 1.51967 | 271 = 3000000 | 276 = A | 290 = 5 | 10 = 142 |
答案 0 :(得分:0)
答案 1 :(得分:0)
我解决了这个问题,提出了一个请求列表。 例如:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="0.5dp"
card_view:cardMaxElevation="1dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"
android:layout_width="match_parent"
android:layout_marginTop="7dp"
android:background="@color/colorWhite"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite">
<TextView
android:id="@+id/txt_rating"
android:background="@drawable/blue_button_background"
android:text="3.8"
android:textColor="@color/colorWhite"
android:layout_marginTop="10dp"
android:textSize="24sp"
android:gravity="center"
android:layout_marginStart="10dp"
android:layout_width="60dp"
android:layout_height="40dp" />
<TextView
android:id="@+id/txt_reviews_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/primary_text"
android:textSize="16sp"
android:layout_toEndOf="@+id/txt_rating"
android:layout_marginStart="20dp"
android:textStyle="bold"
android:paddingTop="1dp"
android:layout_alignTop="@+id/txt_rating"
android:text="Based on 98 reviews"/>
<TextView
android:id="@+id/txt_read_all_reviews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Read All Reviews"
android:layout_alignStart="@id/txt_reviews_title"
android:layout_toEndOf="@id/txt_rating"
android:layout_alignBottom="@id/txt_rating"
android:gravity="bottom"
android:paddingBottom="1dp"
android:textColor="@color/red"
android:layout_below="@id/txt_reviews_title"/>
<View
android:id="@+id/view_dummy1"
android:layout_width="match_parent"
android:layout_height="0.2dp"
android:layout_below="@id/txt_read_all_reviews"
android:layout_marginTop="10dp"
android:background="@color/divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginStart="16dp"
android:layout_below="@+id/view_dummy1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="0.6"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/txt_how_did_your_visit_go"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="How did your visit go?"
android:textStyle="bold"
android:textSize="14sp"
android:textColor="@color/primary_text" />
<TextView
android:id="@+id/txt_tell_everyone_about_it"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tell everyone about it!"
android:layout_marginTop="5dp"
android:textColor="@color/secondary_text"
android:textSize="12sp"
/>
</LinearLayout>
<!--This got some problem-->
<Button
android:id="@+id/btn_add_review"
android:layout_width="0dp"
android:layout_height="40dp"
android:text="Add Your Review"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:textAllCaps="false"
android:textColor="@color/colorWhite"
android:background="@drawable/blue_button_background"
android:layout_weight="0.5"/>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>