Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

The following error is being thrown when calling the StackyClient.GetUser method from within an Azure Worker Role:

Method 'ReadJson' in type 'Stacky.UnixDateTimeConverter' 
from assembly 'Stacky, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)     
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType)     
at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttributes[T](ICustomAttributeProvider attributeProvider, Boolean inherit)     
at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttribute[T](ICustomAttributeProvider attributeProvider, Boolean inherit)     
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute[T](MemberInfo memberInfo)     
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute[T](ICustomAttributeProvider attributeProvider)     
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverterTypeFromAttribute(ICustomAttributeProvider attributeProvider)     
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.AddValue(TKey key)     
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.Get(TKey key)     
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverterType(ICustomAttributeProvider attributeProvider)     
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverter(ICustomAttributeProvider attributeProvider, Type targetConvertedType)     
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperty(JsonObjectContract contract, MemberInfo member)     
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(JsonObjectContract contract)     
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)     
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)     
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe(Type type)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, String reference, JsonArrayContract contract)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.<>c__DisplayClass1.<CreateAndPopulateList>b__0(IList l, Boolean isTemporaryListReference)     
at Newtonsoft.Json.Utilities.CollectionUtils.CreateAndPopulateList(Type listType, Action`2 populateList)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateList(JsonReader reader, String reference, JsonArrayContract contract)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String reference)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueProperty(JsonReader reader, JsonProperty property, Object target, Boolean gottenCurrentValue, Object currentValue)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonReader reader, Object target)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, String id)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateObject(JsonReader reader, JsonObjectContract contract, String id)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract)     
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType)     
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)     
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)     
at Stacky.SerializationHelper.DeserializeJson[T](String json) in C:\Code\Stacky\trunk\source\Stacky\Helpers\SerializationHelper.cs:line 71     
at Stacky.JsonResponse`1.Parse[T](String json, JsonResponse`1 response) in C:\Code\Stacky\trunk\source\Stacky\Protocols\JsonResponse.cs:line 43     
at Stacky.JsonResponse`1..ctor(String json) in C:\Code\Stacky\trunk\source\Stacky\Protocols\JsonResponse.cs:line 30     
at Stacky.JsonProtocol.GetResponse[T](String message) in C:\Code\Stacky\trunk\source\Stacky\Protocols\JsonProtocol.cs:line 9     
at Stacky.StackyClient.ParseResponse[T](HttpResponse httpResponse) in C:\Code\Stacky\trunk\source\Stacky\StackyClient\StackyClient.cs:line 61     
at Stacky.StackyClient.MakeRequest[T](String method, String[] urlArguments, Dictionary`2 queryStringArguments) in C:\Code\Stacky\trunk\source\Stacky\StackyClient\StackyClient.cs:line 49     
at Stacky.StackyClient.MakeRequest[T](String method, String[] urlArguments, Object queryStringArguments) in C:\Code\Stacky\trunk\source\Stacky\StackyClient\StackyClient.cs:line 42     
at Stacky.StackyClient.GetUsers(IEnumerable`1 userIds, UserSort sortBy, SortDirection sortDirection, Nullable`1 page, Nullable`1 pageSize, String filter, Nullable`1 fromDate, Nullable`1 toDate, Nullable`1 min, Nullable`1 max) in C:\Code\Stacky\trunk\source\Stacky\StackyClient\UserMethods.cs:line 29     
at Stacky.StackyClient.GetUser(Int32 userId) in C:\Code\Stacky\trunk\source\Stacky\StackyClient\UserMethods.cs:line 47

The code that generates the error:

StackyClient stackyClient = new StackyClient("1.0", myApiKey, Sites.StackOverflow, new UrlClient(), new JsonProtocol());
Stacky.User stackyUser = stackyClient.GetUser(123456);

The exact same code and binaries will run without issue in a WinForms application. It is only when used within a Windows Azure role and running in the local dev fabric or in the cloud that the error is generated.

Both the Stacky and Newtonsoft.Json DLLs are referenced in the worker role, both have the "Copy Local" property set to true, and both have been verified as present in the bin directories.

Has anyone successfully used the Stacky library in an Azure role? If so, are there any additional steps required beyond referencing the DLLs?

share|improve this question
    
Did you ever got this solved ? I'm having the exact same issue, but don't find a reason for it –  Sam Vanhoutte May 12 '13 at 16:52

1 Answer 1

I have not tried Stacky in Azure so I can't really comment from experience on that.

I can say that the problem doesn't appear to be the assembly not being there. If, for example, the newtonsoft assembly was missing you would be getting an exception like:

System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

Usually the exception you are seeing has more to do with assembly versions. Did you happen to update the version of the newtsonsoft assembly from the one which stacky references? You have to make sure to use the version that is bundled with stacky.

This SO question has a pretty good explanation of the problem.

share|improve this answer

You must log in to answer this question.