Highlighted
2 Bronze

Atmos C# bindings error _COMPlusExceptionCode = -532459699

Hi

I've been trying to get the C# bindings working (via an SQL SSIS C# script task).  For the most part, everything work fine, however when testing with a large file I encounter the above error.  Any advice welcome.

I'm not sure exactly at what file size this occurs, but 600Mb works ok and 2.7 Gb does not.  This is using CreateObjectFromStream.

Separately, when attempting to use the checksum feature I hit an "Object Is Not copyable" error.  For now I'm leaving the MD5 out to get over the other issue.

C# is not my primary dev language, any advice welcome.

0 Kudos
Reply
7 Replies
Highlighted
3 Argentum

What version of the C# binding and the .NET SDK are in use?  Is there a stack trace available anywhere?

We've never seen any COM errors before.  Perhaps this is the error if there is an unhandled Exception in the script?

0 Kudos
Reply
Highlighted
2 Bronze

Hi Jason

The script task is set to .NET 3.5.  AssemblyInfo.cs contains 2.1.4.31

This might be more useful:

[] Information: zSystem.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

   at System.Net.ScatterGatherBuffers.MemoryChunk..ctor(Int32 bufferSize)

   at System.Net.ScatterGatherBuffers.AllocateMemoryChunk(Int32 newSize)

   at System.Net.ScatterGatherBuffers..ctor(Int64 totalSize)

   at System.Net.ConnectStream.EnableWriteBuffering()

   at System.Net.HttpWebRequest.SetRequestSubmitDone(ConnectStream submitStream)

   at System.Net.Connection.CompleteConnection(Boolean async, HttpWebRequest request)

The server has 16Gb Ram, 8Gb free.  I will try on a different machine on monday.

0 Kudos
Reply
Highlighted
2 Bronze

I'm working around this for now by streaming if it's <= 512Mb, and chunking it myself if > 512Mb calling CreateObject and UpdateObject to append each additional chunk.  Which kind of missed the point of streaming the larger files, but is functional as most files are less than that.

Unfortunatley .NET 3.5 does not have the filestream.copyto so either way it end up in a byte and using memory.


0 Kudos
Reply
Highlighted
3 Argentum

Can you post your whole code?  This is very strange behavior.  You should be able to use a smaller buffer and pass data to the stream:

public static void CopyStream(Stream input, Stream output)
{
  
byte[] buffer = new byte[32768];
  
int read;
  
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
  
{
  output
.Write (buffer, 0, read);
  
}
}

0 Kudos
Reply
Highlighted
2 Bronze

Hi

Apologies for the delay, I was on leave.

I now have checksumming working, and have worked around the file size issue in a similar way to that suggested.  I skipped the copystream method as it's just using byte[] anyway, so use the createobject directly in that case to save copying back to a stream.  This seems to be working fine so far.

The complus error was a red herring, the error I still get when attempting a large file without the workaround is:

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> EsuApiLib.EsuException: Error executing request: The underlying connection was closed: Unable to connect to the remote server. ---> System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

   at System.Net.ScatterGatherBuffers.MemoryChunk..ctor(Int32 bufferSize)

   at System.Net.ScatterGatherBuffers.AllocateMemoryChunk(Int32 newSize)

   at System.Net.ScatterGatherBuffers..ctor(Int64 totalSize)

   at System.Net.ConnectStream.EnableWriteBuffering()

   at System.Net.HttpWebRequest.SetRequestSubmitDone(ConnectStream submitStream)

   at System.Net.Connection.CompleteConnection(Boolean async, HttpWebRequest request)

   --- End of inner exception stack trace ---

   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)

   at System.Net.HttpWebRequest.GetRequestStream()

   at EsuApiLib.Rest.EsuRestApi.writeRequestBodyFromStream(HttpWebRequest con, Stream data, Int64 streamLength)

   at EsuApiLib.Rest.EsuRestApi.CreateObjectFromStream(Acl acl, MetadataList metadata, Stream data, Int64 streamLength, String mimeType, Checksum checksum)

   --- End of inner exception stack trace ---

   at ST_3fd03fc03c144d9eb015ae46a529d171.csproj.ScriptMain.Main()

   --- End of inner exception stack trace ---

   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

   at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

0 Kudos
Reply
Highlighted
3 Argentum

So, is everything working correctly now or do you still have issues?

0 Kudos
Reply
Highlighted
2 Bronze

Hi Jason

We still have issues when attempting to submit a 2.7Gb file via CreateFromStream, but the workaround of chunking @ 512Mb is so far OK.  Mostly this won't be used, it's more for test coverage.

But would be good to get it working without still!

0 Kudos
Reply