All,
I am using ZeroFormatter for serialization of a big object, sometimes it is giving following error while serializing the error, this issue is observed after using Union concept of ZeroFormatter for inheritence.
Here are the exception details:
System.InvalidProgramException: Common Language Runtime detected an invalid program.
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Factors.RateFactor$Formatter.Serialize(Byte[]& , Int32 , RateFactor )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.RateClass$Formatter.Serialize(Byte[]& , Int32 , RateClass )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.PackagePlan$Formatter.Serialize(Byte[]& , Int32 , PackagePlan )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Package$Formatter.Serialize(Byte[]& , Int32 , Package )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.PackageGroup$Formatter.Serialize(Byte[]& , Int32 , PackageGroup )
at ZeroFormatter.Formatters.CollectionFormatter3.Serialize(Byte[]& bytes, Int32 offset, TCollection value)
at ZeroFormatter.DynamicObjectSegments.ZeroFormatter_Formatters_DefaultResolver.Colibrium.Common.Ontology.Rating.Group.GroupRatingResults$Formatter.Serialize(Byte[]& , Int32 , GroupRatingResults )
at ZeroFormatter.ZeroFormatterSerializer.CustomSerializer1.Serialize[T](T obj)
at Colibrium.Utility.Library.ObjectConverter`1.ConvertO
bjectToBinaryZeroFormatter(T p_object)
in C:\TFS\UPMC\Repos\Colibrium.Utility.Library\ObjectConverter.cs:line 407
Looking at the source code for DynamicFormatter it appears the library tries to optimize formatting of your user types by generating CLR types at runtime to serialize / deserialize the user type to a byte array. Based on the error, it seems there must be a bug in this IL generation.
You should report this problem in the ZeroFormatter project issues but note you will likely need to have a good way to reproduce this issue, as tracking down an InvalidProgramException is very challenging.
In case you happen to have Application Insights in use, the exception may be thrown due to issue 18323 reported to .Net Core CRL
The issue is reported on .Net core, but I have also reported it on .Net Framework due to the solution seeming to work also there.
ApplicationInsights has moved towards a Preinstalled Site Extension model and does not have the offending bits anymore. In addition, the private Site Extension will not be updated as it is estimated to be deprecated within a month. You should be able to upgrade to the preinstalled site extension through the ApplicationInsights configuration in the AppService blade in Azure.
However, if you want an immediate solution for the private site extension, you can workaround the issue by removing the following two files in the site extension and restarting the site:
Instrumentation32\ProductionBreakpoints_x86.config
Instrumentation64\ProductionBreakpoints_x64.config
This will effectively remove the part of AppInsights extension causing issues.
Related
As my first task working with vb.net, I was assigned the job of migrating a VB6 project over to vb.net using Visual Studio 2008. I am now working with Visual Studio 2017 and have gone through and cleared up all of the Upgrade Warnings that the conversion process gave me. The only remaining issues I have are with two instances of "Class Not Registered" Exceptions.
Things to note:
the original vb6 program was on a Windows XP machine. I am currently working on a Windows 7 64bit system.
I have read a couple of other posts here and here, but I haven't been able to solve my issue.
This warning is more specifically related to a Design view of a form
I believe the issue is probably something to do with a missing dll, as I had to move the source code to another computer to do the debugging.
Here is the call stack if anyone can help point me in the right direction:
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Instances of this error (2)
1. Hide Call Stack
at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.set_Site(ISite value)
at System.ComponentModel.Container.Add(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.PerformAdd(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements)
Thanks for the help!
Hy,
In my project I am using Antlr.StringTemplate.StringTemplateGroup class in order to create a localized template. I access the .st file and set the desired attributes as below.
public StringTemplate WrapValuesReportTemplateContent(
private StringTemplateGroup StringTemplateGroup = new StringTemplateGroup(StringTemplateGroupName);
StringTemplate stringTemplate = this.StringTemplateGroup.GetInstanceOf(path);
stringTemplate.SetAttribute("atr1", value1);
stringTemplate.SetAttribute("atr2", value2);
return stringTemplate
)
The class is repeatedly used by a manager and due to this reason the following exception was triggered.
System.IndexOutOfRangeException: Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithread applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.WriteLine(String value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(String value)
at Antlr.StringTemplate.ConsoleErrorListener.Error(String s, Exception e)
at Antlr.StringTemplate.StringTemplate.BreakTemplateIntoChunks()
I am quire new to StringTemplate and it's not clear for me how StringTemplates really work. From the error description I understand that the .st resource is not closed. And I have the following questions:
When creating a new StringTemplate we create a Stream for writing and reading to the .st file, or a new object where we modify the attributes
After a .st file is opened is it closed automatically once it gets out of scope
How is the best approach in order to avoid this error. We should use locks on the resources, or wrap everything in a using?
Any clarification would be very useful.
Thanks
You could try synchronizing accesses on the stringTemplate object.
My guess is that you will only need to synchronize if you are simultaneously modifying it and reading or modifying it. If you are just reading it, it doesn't usually matter.
lock (stringTemplate)
{
// Access thread-sensitive resources.
}
For efficiency reasons, you should keep your synchronized block as small as possible; just with the stringTemplate access.
I've recently encountered the same bug!
Look at your stacktrace: it is thrown from ConsoleErrorListener.
To be short, the exception is thrown because of two threads are trying to write to Console.Out stream.
To eliminate this error You should override error handler for your template.
The solution which is marked as answer will work, but there will be too much lock contention.
After installing Visual Studio 2015 preview an issue was introduced where the ToString() method on the hierarchyid throws a HierarchyException 24000 in SSMS
A .NET Framework error occurred during execution of user-defined routine or aggregate "hierarchyid":
Microsoft.SqlServer.Types.HierarchyIdException: 24000: SqlHierarchyId operation failed because HierarchyId object was constructed from an invalid binary string.
Microsoft.SqlServer.Types.HierarchyIdException:
at Microsoft.SqlServer.Types.OrdPath.GetBits(UInt16 startBit, UInt16 nBits, UInt64& bits)
at Microsoft.SqlServer.Types.OrdPath.ExtractOrd(UInt16& bitOffset, UInt32 stage, Int64& ord)
at Microsoft.SqlServer.Types.OrdPath.ExtractComponent(UInt16& bitOffset, SComponent& component, levelType& type)
at Microsoft.SqlServer.Types.OrdPath.ToString()
I couldn't find a solution for this!
Thanks for help
Yup, it sure does :-(
Already has been reported, and you are not the only one to reproduce it.
https://connect.microsoft.com/SQLServer/feedback/details/1063935/visual-studio-2015-breaks-hierarchyid-clr-type
I have a program in VB.Net (v2.0 framework) and while doing http post from a sql data reader, I am getting the following error on few machines:
System.NotSupportedException: The stream does not support concurrent IO read or write operations.
at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at ProtoBuf.ProtoWriter.Flush(ProtoWriter writer)
at ProtoBuf.ProtoWriter.Dispose()
at ProtoBuf.ProtoWriter.System.IDisposable.Dispose()
at ProtoBuf.Meta.TypeModel.SerializeWithLengthPrefix(Stream dest, Object value, Type type, PrefixStyle style, Int32 fieldNumber, SerializationContext context)
at ProtoBuf.Serializer.SerializeWithLengthPrefix[T](Stream destination, T instance, PrefixStyle style, Int32 fieldNumber)
at ProtoBuf.Serializer.SerializeWithLengthPrefix[T](Stream destination, T instance, PrefixStyle style)
Code:
postStream = request.GetRequestStream()
While dr.Read()
dd.Add(dr) ' Adding data row to proto
ProtoBuf.Serializer.SerializeWithLengthPrefix(Of DataDump)(postStream, dd, ProtoBuf.PrefixStyle.Base128) ' stream proto to http post stream
dd.Clear() ' Clear proto
End While
response = DirectCast(request.GetResponse(), HttpWebResponse)
Protobuf-net does not issue concurrent read or write operations. Since you mention request streams, I expect the actual problem is related to this question.
In the end, it is not a protbuf-net related issue at all. Even after saving the protos in binary file and then trying to upload, it throws the error.
It might be httpwebrequest, .net or windows patch or sophos antivirus.
I am closing this question as it has gone in different tangent.
Thanks for all your help.
I'm evaluating Server 2008. My C++ executable is getting this error. I've seen this error on MSDN that seems to have required a hot-fix for several previous OSes. Anyone else seen this? I get the same results for the 32 & 64 bit OS.
Code snippet:
HRESULT GroupStart([in] short iClientId, [in] VARIANT GroupDataArray,
[out] short* pGroupInstance, [out] long* pCommandId);
Where the GroupDataArray VARIANT argument wraps a single-dimension SAFEARRAY of VARIANTs wrapping a DCAPICOM_GroupData struct entries:
// DCAPICOM_GroupData
[
uuid(F1FE2605-2744-4A2A-AB85-1E1845C280EB),
helpstring("removed")
]
typedef struct DCAPICOM_GroupData {
[helpstring("removed")]
long m_lImageID;
[helpstring("removed")]
unsigned char m_ucHeadID;
[helpstring("removed")]
unsigned char m_ucPlateID;
} DCAPICOM_GroupData;
After opening a support case with Microsoft, I can now answer my own question. This is (now) a recognized bug. The issue has to do with marshalling on the server side, but before the server code is called. Our structure is 6 bytes long, but this COM implementation is interpreting it as 8, so the marshalling fails, and this is the error you get back. The workaround, until a Service Pack is released to deal with this, is to add two extra bytes to the structure to pad it up to 8 bytes. We haven't run across any more instances that fail yet, but we still have a lot of testing to do still.
We ran into the same error recently with a client/server app communicating via DCOM. It turned out that the size of a marshalled interface pointer going across the wire (i.e., not local) had changed (gotten bigger). You might like to check whether your code is doing any special marshalling via CoMarshalInterface or the like.