Uploading sharepoint document exception using SaveBinaryDirect - sharepoint

I have a Windows Application that saves .pdfs to a SharePoint Document Library. It works fine except this one file. Whenever I use SaveBinaryDirect with this 10.1MB file I get the following exception:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.File.SaveBinary(ClientContext context, String serverRelativeUrl, Stream stream, String etag, Boolean overwriteIfExists, SaveBinaryCheckMode checkMode)
at Microsoft.SharePoint.Client.File.SaveBinaryDirect(ClientContext context, String serverRelativeUrl, Stream stream, Boolean overwriteIfExists)
at BKWatch.BKWatchViewModel.UploadDocument(String siteURL, String documentListName, String documentListURL, String documentName, Byte[] documentStream, Int64 AccountId, String DebtorName, Nullable`1 Pages, String Title)
I have already tried the following:
clientContext.PendingRequest.RequestExecutor.WebRequest.KeepAlive = false;
System.Net.ServicePointManager.MaxServicePointIdleTime = 600000;
clientContext.RequestTimeout = 600000;
Increasing max size in SharePoint - already at 50 MB
Increasing max size in IIS web.config - Already at 2GB
Thanks.

Well after a couple long phone conversations with Microsoft, they think there is a bug in the SaveBinaryDirect code and recommended I use the ClientObject.Add functionality instead. Seems to be working so far.

I have encountered this problem with Microsoft.SharePoint.Client.File.SaveBinaryDirect when uploading a number of big files in a row.
The fix for this, is on each time you are using SaveBinaryDirect, wrap it with a try-catch, and catch System.Net.WebException.
once Webexception is caught, run the same SaveBinaryDirect command you ran before, and it should work.

Related

IDAPython Debugger Script for logging input data obtained by read()

I am writing an idapython debugger script for logging runtime program information.
In particular, I want to log system calls such as read(0, buf, size), and especially, record the data in buf after calling.
As illustrated in debughook.py, it is easy to trace each instruction:
class MyDbgHook(DBG_Hooks):
def dbg_trace(self, tid, ea):
print("Trace tid=%d ea=0x%x" % (tid, ea))
# return values:
# 1 - do not log this trace event;
# 0 - log it
return 0
debughook = MyDbgHook()
debughook.hook()
Therefore, a simple solution is:
record the memory address of buf when entrying read()
get the data in buf after calling read()
However, I found it will be complex and unstable when actually implementing. If there is a more elegent solution for above purpose?

ServiceStack ProtoBuf Error: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

I have a ServiceStack service on a server and I am trying to run a program that connects to that service. I am getting the intermittent error below. This is the stack trace and anything that was below this was just the point in my program at which I was calling the server. The most frustrating part is that it is not consistent. If it fails and I restart the program it may fail but at a different point, it may not fail at all. (It usually does fail again, but after a different amount of time). Almost always it is the same call to the server I am making but I have seen it happen during other calls as well. Any help would be greatly appreciated as this has been an issue I have been trying to solve for a while now.
System.AggregateException: One or more errors occurred. ---> System.Runtime.Serialization.SerializationException:
ProtoBufServiceClient:
Error deserializing: Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host. --->
System.IO.IOException: Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host. --->
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at ProtoBuf.ProtoReader.Ensure(Int32 count, Boolean strict)
at ProtoBuf.ProtoReader.TryReadUInt32VariantWithoutMoving(Boolean trimNegative, UInt32& value)
at ProtoBuf.ProtoReader.TryReadUInt32Variant(UInt32& value)
at ProtoBuf.ProtoReader.ReadFieldHeader()
at proto_32(Object , ProtoReader )
at ProtoBuf.ProtoReader.ReadTypedObject(Object value, Int32 key, ProtoReader reader, Type type)
at proto_64(Object , ProtoReader )
at ProtoBuf.ProtoReader.ReadTypedObject(Object value, Int32 key, ProtoReader reader, Type type)
at proto_84(Object , ProtoReader )
at ProtoBuf.ProtoReader.ReadTypedObject(Object value, Int32 key, ProtoReader reader, Type type)
at proto_56(Object , ProtoReader )
at ProtoBuf.ProtoReader.ReadTypedObject(Object value, Int32 key, ProtoReader reader, Type type)
at proto_50(Object , ProtoReader )
at ProtoBuf.ProtoReader.ReadTypedObject(Object value, Int32 key, ProtoReader reader, Type type)
at proto_78(Object , ProtoReader )
at ProtoBuf.Meta.TypeModel.DeserializeCore(ProtoReader reader, Type type, Object value, Boolean noAutoCreate)
at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type type, SerializationContext context)
at ProtoBuf.Serializer.Deserialize[T](Stream source)
at ServiceStack.ProtoBuf.ProtoBufServiceClient.DeserializeFromStream[T](Stream stream)
--- End of inner exception stack trace ---
at ServiceStack.ProtoBuf.ProtoBufServiceClient.DeserializeFromStream[T](Stream stream)
at ServiceStack.ServiceClientBase.GetResponse[TResponse](WebResponse webResponse)
at ServiceStack.ServiceClientBase.Send[TResponse](String httpMethod, String relativeOrAbsoluteUrl, Object request)

protobuf: string content is overlapped when 2 different instance of the same message in multithread

Recently I encountered a protobuf problem that the string was overlapped. The scenario is :
1/ defined a message like in proto file.
message fund_inout_rsp {
uint64 seq_no = 1;
uint32 err_id = 2;
string err_msg = 3
};
and then convert this message to C++ code using protoc --cpp_out。
so I got a class named fund_inout_rsp.
2/ Now there are two thread A and B.
In thread A,
fund_inout_rsp instance1;
instance1.set_err_msg(u8("123456789"))
instance1.SerializeToArray();
send out by TCP
In thread B,
fund_inout_rsp instance2;
instance2.set_err_msg(u8("abcd"));
instance2.SerializeToArray();
send out by TCP
3/ the TCP receiver got a message.
"abcd56789"
it seems that the instance1's err_msg is overlapped by instance2's err_msg.
The following is the auto generated code by protoc.
fund_inout_rsp::set_err_msg(const char* value) {
err_msg_.SetNoArena(
&google::protobuf::internal::GetEmptyStringAlreadyInited(),
std::string(value))
}
Can anyone give me a hint how to solve this problem?
Thanks in advance.

SharpDX: Creating TextureCube from set of images

So I have 6 seperate images and I would like to build a textureCube out of them. What's the best way to go about it? Right now this is what I have, but I'm getting a memory access violation when the TextureCube tries to create itself.
SharpDX.DataBox[] textureData = new SharpDX.DataBox[6];
for(int i = 0; i < 6; i++)
{
Texture2D tex = Texture2D.Load(device, resources[i].Filepath);
SharpDX.Direct3D11.Texture2D staged = (SharpDX.Direct3D11.Texture2D)tex.ToStaging();
textureData[i] = new SharpDX.DataBox(staged.NativePointer, staged.Description.Width, 0);
}
SharpDX.Toolkit.Graphics.TextureCube cube = SharpDX.Toolkit.Graphics.TextureCube.New(
device,
2048,
PixelFormat.R8G8B8A8.UNorm,
textureData);
The texture load is working fine. I can load the texture and then create a textureCube from a single image no problem. That's not much use though. When I try to create a cube using the raw data from my 6 separate images I'm getting the memory exception.
Result Message:
Test method ResourceLoadingTests.LoadCubemapAndSave threw exception:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Result StackTrace:
at SharpDX.Direct3D11.Device.CreateTexture2D(Texture2DDescription& descRef, DataBox[] initialDataRef, Texture2D texture2DOut)
at SharpDX.Direct3D11.Texture2D..ctor(Device device, Texture2DDescription description, DataBox[] data)
at SharpDX.Toolkit.Graphics.Texture2DBase..ctor(GraphicsDevice device, Texture2DDescription description2D, DataBox[] dataBoxes)
at SharpDX.Toolkit.Graphics.TextureCube..ctor(GraphicsDevice device, Texture2DDescription description2D, DataBox[] dataBoxes)
at SharpDX.Toolkit.Graphics.TextureCube.New(GraphicsDevice device, Int32 size, PixelFormat format, DataBox[] textureData, TextureFlags flags, ResourceUsage usage)

Encoding Not supported Execption while parsing HL7 message

I have a C#.NET application in which i am trying to construct an HL7 message and then send to other Application using NHAPI .The message is successfully constructed but it when i am trying to extract throws an error :Encoding NotsupportedException
Specifications:
.NET framework- 4
HL7 version-2.5
Language:C#
here is the piece of code
PipeParser ParserADT = new PipeParser();
IMessage ParsedADTmsg = ParserADT.Parse(ADTMsg);
string Msgstr = ParsedADTmsg.GetStructureName();
I get the exception immediately after the line above.
The constructed message:
MSH|^~\&|HIS|HIS1|||201405291223||ADT^A01^ADT_A01|73944|P|2.5
EVN||201405291223
PID|||102||Oberoi^Anjali^^^Ms||20140529|Female|||||^^PH|^^CP
NK1|1234||||||||||||||||||||||||||||||^^CP
PV1||Emergency –
Replace the space before EVN, NK1, and PV1 with a new line character, so that your message looks like this:
MSH|^~\&|HIS|HIS1|||201405291223||ADT^A01^ADT_A01|73944|P|2.5
EVN||201405291223 PID|||102||Oberoi^Anjali^^^Ms||20140529|Female|||||^^PH|^^CP
NK1|1234||||||||||||||||||||||||||||||^^CP
PV1||Emergency

Resources