小编Ben*_*ele的帖子

Ax 2012 tts错误

我在更新发明表中的记录时遇到错误.我使用以下示例代码.

static void Job4(Args _args)
{
    CsInvBOMSplitQtyCalcHelper  bomCalc;
    Qty                         qty;
    InventTable                 inventTable;
    InventTable                 updateInventTable;
    BOM                         bom;
    boolean                     result;
    BOMId                       bomId;             
    BOMVersion                  bomVersion;
    ItemId                      item        = "1000M-3C-Pcs";

    select firstOnly * from bomversion
            where bomversion.Active == true
            && bomversion.ItemId    == item
            && csIsLengthItem(item) == false;

    if (0 != bomVersion.RecId)
    {
        select * from bom
            where bom.BOMId                 == bomversion.BOMId
        exists join inventTable
            where bom.ItemId                == inventTable.ItemId
            && inventTable.CsIsLengthItem   == true;
    }

    if (0 != bom.RecId)
    {
        result  = true;
        bomCalc = CsInvBOMSplitQtyCalcHelper::construct(item);
        qty …
Run Code Online (Sandbox Code Playgroud)

runtime-error axapta

5
推荐指数
1
解决办法
246
查看次数

如何在Windows Phone 8.1应用清单中添加文件类型关联?

我正在尝试使用KnownFolders.MusicLibrary以下代码访问中的文件。

    internal async void Update()
    {
        StorageFolder rootFolder = KnownFolders.MusicLibrary;
        ScanFolder(rootFolder);
    }

    private async void ScanFolder(StorageFolder storageFolder)
    {
        var items = await storageFolder.GetItemsAsync();

        foreach (var item in items)
        {
            if (item is StorageFolder)
            {
                ScanFolder(item as StorageFolder);
            }
            else if (item is StorageFile)
            {
                var fs = new FileStream(item.Path, FileMode.Open, FileAccess.Read);
                < ... snip ... >
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我已经MusicLibrary检查了功能,以便可以使用KnownFolders.MusicLibrary。但这似乎并没有授予我文件访问库的权限,因为出现以下错误:

+       [System.UnauthorizedAccessException]    

{System.UnauthorizedAccessException: Access to the path 'C:\Data\Users\Public\Music\tmp' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String …
Run Code Online (Sandbox Code Playgroud)

xaml windows-phone-8.1

2
推荐指数
1
解决办法
3742
查看次数

如何查看我的数据绑定项ItemTemplate的设计?

我有一个简单的ListBox绑定对象集合ItemsSource.我现在分配的DataTemplate非常简单,但我怎样才能在设计器中看到该模板?

这是我的xaml:

<ListBox.ItemTemplate>
    <DataTemplate>
        <Grid>
            <TextBlock Text="{Binding Title}" />
            <TextBlock Text="{Binding Address}" />
        </Grid>
    </DataTemplate>
</ListBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

这就是设计师的样子:

在此输入图像描述

这就是数据绑定和应用程序运行时的外观:

在此输入图像描述

如何让设计师展示我的预览DataTemplate?我不需要填写的实际数据(在运行时发生),但欣赏预览.

c# wpf visual-studio-2013

2
推荐指数
1
解决办法
1215
查看次数

为什么ObservableCollection不实现IList?

我有一个Type,{System.Collections.ObjectModel.ObservableCollection}它实现了以下接口

在此输入图像描述

这是我检查类型是否实现的代码 IList

if (type.IsGenericType && type.GetInterfaces().Contains(typeof(IList<>)))
{
    type = type.GetGenericArguments()[0];
    enclosedType = EnclosedType.List;
}
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?我觉得我错过了一些明显的东西.

c# ilist observablecollection

0
推荐指数
1
解决办法
1129
查看次数

通过反射将Collection <T>转换为ObservableCollection <T>时出现InvalidCastException

我可以投出Collection<T>一个ObservableCollection<T>这样的:

ObservableCollection<MyObject> col1;
col1 = (ObservableCollection<MyObject>)new Collection<MyObject>();
Run Code Online (Sandbox Code Playgroud)

但是当我尝试通过反射做到这一点时,我得到以下错误:

myProperty.SetValue(
    element, 
    Convert.ChangeType(values, myProperty.PropertyType, null)
    , null);
Run Code Online (Sandbox Code Playgroud)

mscorlib.ni.dll中出现"System.InvalidCastException"类型的第一次机会异常附加信息:对象必须实现IConvertible.

为什么转换在正常运行时工作,但在使用反射时却不行?

编辑 我最后通过不使用Collection<T>作为类型但直接使用我myProperty.PropertyType的类型来"解决"我的问题.

c# reflection windows-phone-8.1

0
推荐指数
1
解决办法
574
查看次数

为什么在此示例中使用return -1?

 static int Main(string[] args)
        {
            Guid obj = Guid.NewGuid();

            Console.WriteLine("New Guid is " + obj.ToString());
            Console.ReadLine();
            return -1;
        }
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么return -1在这里使用它,这意味着什么?

c# guid

-3
推荐指数
1
解决办法
725
查看次数