USQL JsonTextWriter.Writevalue抛出错误“类型‘URI’在一个组件定义的

2019-10-30 08:44发布

我有我的工作USQL自定义输出机构,基本上都在使用JsonTextWriter一个文件中写入JSON输出。 当我尝试编译我得到以下错误

error: "The type 'Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'." at line: 60, column 20

行号60

writer.WriteValue("Test");

我基本上得到这个错误对所有在那里我做WriteValue线

这里是我的SampleOutputter

        using Microsoft.Analytics.Interfaces;
    using Microsoft.Analytics.Types.Sql;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using Newtonsoft.Json;

    namespace JSONOutputter
    {

        [SqlUserDefinedOutputter(AtomicFileProcessing = true)]
        public class JSONOutputter : IOutputter
        {
            // Local variables initialization
            private bool isHeaderRow;
            private Encoding encoding;
            private JsonTextWriter writer;

            // Parameters definition            
            public JSONOutputter(bool isHeader = true, Encoding encoding = null)
            {
                this.isHeaderRow = isHeader;
                this.encoding = ((encoding == null) ? Encoding.UTF8 : encoding);
            }

            // The Close method is used to write the footer to the file. It's executed only once, after all rows
            public override void Close()
            {
                if (this.writer != null)
                {
                    //Audience Targeting Array End
                    writer.WriteEnd();
                    // Survey Object Ends
                    this.writer.WriteEndObject();
                    this.writer.Close();
                }
            }

            public override void Output(IRow row, IUnstructuredWriter output)
            {
                if (this.writer == null)
                {
                    // Json.Net (writer)
                    this.writer = new JsonTextWriter(new StreamWriter(output.BaseStream));
                    writer.WriteStartObject();
                }

                // Metadata schema initialization to enumerate column names
                ISchema columns = row.Schema;

                // Header row output--runs only once
                if (isHeaderRow)
                {
                    string val = row.Get<string>(0);
                    if (val != null)
                    {
                        writer.WritePropertyName("key",escape:true);
                        writer.WriteValue("Test");
                    }
                }

请帮忙

文章来源: USQL JsonTextWriter.Writevalue is throwing error “The type 'Uri' is defined in an assembly that is not referenced”