我有我在 Visual Studio 2010 中创建的解决方案。它有两个项目,假设这些项目是project A
和project B
. 用户输入参数project A
,然后project B
假设在 excel 文件的随机列中生成随机数。输出应该随机保存在 Excel 文件中。
当我使用 Visual Studio 2010 测试程序时,它的行为符合预期。现在,当我打包程序并创建一个安装.exe
文件时,它不会随机化。相反,输出是按顺序保存的。
谁能告诉我似乎是什么问题?
这是生成随机位置的示例代码
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;
}
}