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

我只是一个虾纸丫 提交于 2019-12-11 16:17:33

问题


I have a custom outputter for my USQL job which basically writes json output in a file using JsonTextWriter. I get following error when I try to compile

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

Line number 60 is

writer.WriteValue("Test");

I basically get this error for all the lines where I am doing WriteValue

Here is my 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");
                    }
                }

Please help

来源:https://stackoverflow.com/questions/49583497/usql-jsontextwriter-writevalue-is-throwing-error-the-type-uri-is-defined-in-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!