Git Product home page Git Product logo

Comments (2)

glennblock avatar glennblock commented on July 21, 2024

I will take a look, thanks!
On Wed, Mar 18, 2015 at 7:27 AM RickEvry [email protected] wrote:

The TestController-example on the home page does work. When you call
http://localhost:8080/api/test you get an error:

An error has occurred.Type 'System.Dynamic.ExpandoObject' with data
contract name 'ArrayOfKeyValueOfstringanyType:
http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not
expected. Consider using a DataContractResolver or add any types not known
statically to the list of known types - for example, by using the
KnownTypeAttribute attribute or by adding them to the list of known types
passed to
DataContractSerializer.System.Runtime.Serialization.SerializationException
at
System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract
dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean
verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
at
System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract
dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle
originalDeclaredTypeHandle, Type graphType)
at
System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator
writer, Object graph, DataContractResolver dataContractResolver)
at
System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator
writer, Object graph, DataContractResolver dataContractResolver)
at
System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator
writer, Object graph, DataContractResolver dataContractResolver)
at
System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter
writer, Object graph)
at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStream(Type
type, Object value, Stream writeStream, HttpContent content)
at
System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStreamAsync(Type
type, Object value, Stream writeStream, HttpContent content,
TransportContext transportContext, CancellationToken cancellationToken)

--- End of stack trace from previous location where exception was thrown

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at

System.Web.Http.Owin.HttpMessageHandlerAdapter.d__13.MoveNext()

install ScriptCs.WebApi2

scriptcs -install ScriptCs.WebApi2
Installing packages...
Installed: ScriptCs.WebApi2
Package installation succeeded.
Saving packages in scriptcs_packages.config...
Creating scriptcs_packages.config...
Added Microsoft.AspNet.WebApi.Client (v5.2.0, .NET 4.5) to
scriptcs_packages.config
Added Microsoft.AspNet.WebApi.Core (v5.2.0, .NET 4.5) to
scriptcs_packages.config
Added Microsoft.AspNet.WebApi.Owin (v5.2.0, .NET 4.5) to
scriptcs_packages.config
Added Microsoft.AspNet.WebApi.OwinSelfHost (v5.2.0) to
scriptcs_packages.config
Added Microsoft.Bcl (v1.1.9, .NET 4.5) to scriptcs_packages.config
Added Microsoft.Bcl.Build (v1.0.14, .NET 4.0) to scriptcs_packages.config
Added Microsoft.Net.Http (v2.2.22, .NET 4.5) to scriptcs_packages.config
Added Microsoft.Owin (v2.0.2, .NET 4.5) to scriptcs_packages.config
Added Microsoft.Owin.Host.HttpListener (v2.0.2, .NET 4.5) to
scriptcs_packages.config
Added Microsoft.Owin.Hosting (v2.0.2, .NET 4.5) to scriptcs_packages.config
Added Newtonsoft.Json (v6.0.2, .NET 4.5) to scriptcs_packages.config
Added Owin (v1.0, .NET 4.0) to scriptcs_packages.config
Added ScriptCs.Contracts (v0.10.0, .NET 4.5) to scriptcs_packages.config
Added ScriptCs.WebApi2 (v1.0.0, .NET 4.5) to scriptcs_packages.config

Successfully updated scriptcs_packages.config.

run script

scriptcs test1.cs -modules mono


Reply to this email directly or view it on GitHub
#17.

from scriptcs-webapi.

tomsw avatar tomsw commented on July 21, 2024

Calling UseJsonOnly before Configure fixes this for me:

var server = webapi.
	UseJsonOnly().
	Configure(typeof(TestController)).
	Start("http://localhost:8080");

In a real situation you will add your own formatters and the problem won't occur.

from scriptcs-webapi.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.