我有我在Visual Studio 2010中創建的解決方案。它有兩個項目,假設這些項目是project A
, 和project B
。用戶輸入參數到project A
,然後project B
假設在隨機列中生成隨機數在Excel文件中。輸出應該隨機保存在Excel文件中。C#程序在部署後行爲有所不同
當我使用Visual Studio 2010測試程序時,它的行爲如所需。現在,當我打包 程序並創建一個設置.exe
文件它不隨機。相反,輸出順序保存。
誰能告訴我什麼似乎是問題?
這裏是generatin隨機志願服務崗位
public void AppendCards(int seriesNumber, int batchSize, string cardVal, long batchId)
{
Random random = new Random();
Random ran = new Random();
int commentsNumber = comments.Count - 1;
List<int> position = new List<int>();
for (int i = 1; i < seriesNumber + 1; i++)
{
position.Add(i);
}
long CardTypeId = DataAcc.GetCardTypeId(cardVal);
WinningCard sc = new WinningCard();
sc.BatchId = batchId;
sc.CardTypeId = CardTypeId;
sc.DateCreated = DateTime.Now;
int winpos = random.Next(1, seriesNumber);
switch (winpos)
{
case 1:
sc.PositionOne = cardVal;
break;
case 2:
sc.PositionTwo = cardVal;
break;
case 3:
sc.PositionThree = cardVal;
break;
case 4:
sc.PositionFour = cardVal;
break;
case 5:
sc.PositionFive = cardVal;
break;
}
for (int k = 1; k <= seriesNumber; k++)
{
int w = random.Next(0, DataAcc.GetCommets().Count);
switch (k)
{
case 1:
if (sc.PositionOne == "")
{
sc.PositionOne = comments[w].CommentDescription;
}
break;
case 2:
if (sc.PositionTwo == "")
{
sc.PositionTwo = comments[w].CommentDescription;
}
break;
case 3:
if (sc.PositionThree == "")
{
sc.PositionThree = comments[w].CommentDescription;
}
break;
case 4:
if (sc.PositionFour == "")
{
sc.PositionFour = comments[w].CommentDescription;
}
break;
case 5:
if (sc.PositionFive == "")
{
sc.PositionFive = comments[w].CommentDescription;
}
break;
}
}
請包括一些代碼,告訴我們你在嘗試什麼。 –
告訴我們關於**保存順序** ... – matzone
葉,這不是幫了大忙。 我可以建議如果發佈所有代碼太多(您總是可以發佈一個鏈接到pastebin),嘗試使用簡單的Hello World類型程序重新創建問題? – dwjohnston