Failure in delete performance counter category - c#

I have this simple code:
public void CreateCounters() {
if (PerformanceCounterCategory.Exists(_categoryName)) {
PerformanceCounterCategory.Delete(_categoryName);
}
// create logic…
}
works on my machine.
I run it on my server, get the following stack trace:
System has detected a fatal error. EXITING...
NativeErrorCode: 1010
ErrorCode: -2147467259
Message: The configuration registry key is invalid
TargetSite: Void RegisterFiles(System.String, Boolean)
HelpLink:
Source: System
Stack Trace:
at System.Diagnostics.PerformanceCounterLib.RegisterFiles(String arg0, Boolean unregister)
at System.Diagnostics.PerformanceCounterCategory.Delete(String categoryName)
at myApp.Common.Utils.PerformanceCounters.PerformanceCounters.CreateCounters()
at myApp.Common.Utils.PerformanceCounters.myAppPerformanceCounterReporter.Init()
at myApp.Common.Utils.PerformanceCounters.myAppPerformanceCounterReporter.get_Instance()
at myApp.Program.Main(String[] args)
The category exists on the server, I can see it in perfmon GUI.

ok this is some error in performance counter mechanis, that should be fixed by the following script :
cd %systemroot%\system32
lodctr /R
check out this link : http://geekswithblogs.net/robz/archive/2008/08/10/possible-performance-counter-corruption-or-performance-counters-are-just-disabled.aspx

Related

How to use message pack in xamarin forms

I have to use MessagePack to deserialize data returned from a web API (ASP.net), which was Serialized using the same package.
Used the following code
public async static Task<T> DeserializeAsync<T>(Stream stream)
{
if (stream == null)
{
throw new ArgumentNullException(nameof(stream), "Stream value cannot be null");
}
stream.Position = 0;
T deserialized = await MessagePackSerializer.DeserializeAsync<T>(stream, MessagePack.Resolvers.ContractlessStandardResolver.Options).ConfigureAwait(false);
return deserialized;
}
All was working fine in Android in debug mode but in iOS both debug and release and in Android release mode. The deserialization code crashed with the following exceptions
Android -> Release
[MonoDroid] at MessagePa07-10 18:06:01.269 I/MonoDroid(13495): MessagePack.MessagePackSerializationException: Failed to deserialize Project.Core.Models.SomeData Class value. ---> System.TypeInitializationException: The type initializer for 'FormatterCache`1' threw an exception. ---> MessagePack.Internal.MessagePackDynamicObjectResolverException: can't find public constructor. type:System.Drawing.Drawing2D.Matrix
[MonoDroid] at MessagePack.Internal.ObjectSerializationInfo.CreateOrNull (System.Type type, System.Boolean forceStringKey, System.Boolean contractless, System.Boolean allowPrivate) [0x009a0] in <23c4c9b023514c20801c8f07fd69206c>:0
[MonoDroid] at MessagePack.Internal.DynamicObjectTypeBuilder.BuildType (MessagePack.Internal.DynamicAssembly assembly, System.Type type, System.Boolean forceStringKey, System.Boolean contractless) [0x00015] in <23c4c9b023514c20801c8f07fd69206c>:0
iOS->
System.TypeInitializationException: The type initializer for 'Project.Core.Helpers.BinarySerializer' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.ContractlessStandardResolver' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Internal.StandardResolverHelper' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.DynamicEnumResolver' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at MessagePack.Internal.DynamicAssembly..ctor (System.String moduleName) [0x0001a] in <f04e2061de5c414991b8e36a20354820>:0
at MessagePack.Resolvers.DynamicEnumResolver..cctor () [0x00010] in <f04e2061de5c414991b8e36a20354820>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
at MessagePack.Internal.StandardResolverHelper..cctor () [0x00000] in <f04e2061de5c414991b8e36a20354820>:0
--- End of inner exception stack trace ---
Found the section in the MessagePack git page specifying a way to overcome this issue using an Ahead of time code generator. I followed the steps but was not able to fix the issue. Also I'm sure I'm doing it right.
How do I use MessagePack in Xamarin.Forms. Can anyone who has already suggest me or provide a reference.
Update on steps followed
Used message pack serialization in a button click.
Installed mpc tool.
Used don't mpc -i "{FormsProject.csproj path}" -o "{FormsProject directory path}"
Added the created message pack generated class to the forms project.
Used the following code in App.xaml.cs Initialize method
StaticCompositeResolver.Instance.Register(
MessagePack.Resolvers.GeneratedResolver.Instance,
MessagePack.Resolvers.StandardResolver.Instance
Now also the (Operation is not supported in the platform) Exception is thrown. I'm not quite getting what I'm doing wring here.
Update 2:
Exception in the MessagePackSerializerOptions
System.TypeInitializationException: The type initializer for 'MessagePackSerializerOptionsDefaultSettingsLazyInitializationHelper' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.StandardResolver' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Internal.StandardResolverHelper' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.DynamicEnumResolver' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly (System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.pns.cs:129
at MessagePack.Internal.DynamicAssembly..ctor (System.String moduleName) [0x0001a] in <f04e2061de5c414991b8e36a20354820>:0
at MessagePack.Resolvers.DynamicEnumResolver..cctor () [0x00010] in <f04e2061de5c414991b8e36a20354820>:0
Require to set StaticCompositeResolver.Instance as default.
You lacks following code.
var option = MessagePackSerializerOptions.Standard.WithResolver(StaticCompositeResolver.Instance);
MessagePackSerializer.DefaultOptions = option;
Upgrade to version of MessagePack 2.1.165 or higher.
This issue was fixed in Message pack in version 2.1.165. Regarding the lazy loading of DynamicAssembly.
Issue link

Exception when trying to get reference to MongoDB collections with .Net Core 3.0 (MongoDB.Driver 2.8.0)

My Environment:
Microsoft.NETCore.Platforms (3.0.0-preview5.19224.8)
MongoDB.Driver (2.8.0)
My problem:
Before updating the version of "Microsoft.NETCore.Platforms" the following code worked perfectly:
//Collection of resales
public IMongoCollection<Revenda> CollRevendas;
public BaseRepository(IConfiguration config)
{
try
{
// Location of the database, configured in the "appsettings.json" file
var client = new MongoClient(config.GetConnectionString("Config.api.mstiDFE"));
// Name of the database
Database = client.GetDatabase("api_mstiDFE_II");
// Get the reference for the collection "Resales"
CollRevendas = Database.GetCollection<Revenda>("Revendas");
}
catch (System.Exception ex)
{
throw;
}
}
After updating, when attempting to execute the "CollRevendas = Database.GetCollection("Revendas");" statement, the following exception is thrown:
{"The type initializer for 'MongoDB.Bson.Serialization.BsonClassMap' threw an exception."}
With the following stack trace:
System.TypeInitializationException: The type initializer for 'MongoDB.Bson.Serialization.BsonClassMap' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Reflection.IntrospectionExtensions.GetTypeInfo(Type type)
at MongoDB.Bson.Serialization.BsonClassMap..cctor()
--- End of inner exception stack trace ---
at MongoDB.Bson.Serialization.BsonClassMap.LookupClassMap(Type classType)
at MongoDB.Bson.Serialization.BsonClassMapSerializationProvider.GetSerializer(Type type, IBsonSerializerRegistry serializerRegistry)
at MongoDB.Bson.Serialization.BsonSerializerRegistry.CreateSerializer(Type type)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at MongoDB.Bson.Serialization.BsonSerializerRegistry.GetSerializer[T]()
at MongoDB.Driver.MongoCollectionImpl`1..ctor(IMongoDatabase database, CollectionNamespace collectionNamespace, MongoCollectionSettings settings, ICluster cluster, IOperationExecutor operationExecutor)
at MongoDB.Driver.MongoDatabaseImpl.GetCollection[TDocument](String name, MongoCollectionSettings settings)
at api.mstiDFE.Infra.Repositories.BaseRepository..ctor(IConfiguration config) in C:\Users\Source\Workspace\api.mstiDFE\api.mstiDFE\Infra\Repositories\BaseRepository.cs:line 27
Unfortunately I can not downgrade the "Microsoft.NETCore.Platforms". So any hint will be very welcome.
Version 2.8.1 of the MongoDB Driver for C # was released yesterday (05-15-19).
Soon after asking this question, I obtained the information in the following link:
CSHARP-2595: Fix initialization on .NET Core 3.0 preview 4.
After upgrading to version 2.8.1, the issue was resolved.
So I'll leave the question here as it can serve other people with the same problem.
The same issue was happening in 2.9.0-beta1 also but updating to 2.9.0-beta2 fixed the issue for me.
You need to install MongoDB.Bson package also.
<PackageReference Include="MongoDB.Bson" Version="2.11.4" />
It worked for me.

Enterprise Semantic Logging OOP Exception

I'm trying to use Out-Process Logging using Semantic Logging Application Block. I have downloaded and installed out of process service from here, changed the event source name to point to my source name. But on running the service I get following error:
Message : A fault was detected while processing the configuration for the element 'svcRuntime'. Message: System.Runtime.InteropServices.COMException (0x800705AA): Insufficient system resources exist to
complete the requested service. (Exception from HRESULT: 0x800705AA)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.InsureStarted(EVENT_TRACE_PROPERTIES* properties)
at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableProvider(Guid providerGuid, TraceEventLevel providerLevel, UInt64 matchAnyKeywords, TraceEventProviderOptions options)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.Utility.TraceEventUtil.EnableProvider(TraceEventSession session, Guid providerId, EventLevel level, EventKeywords matchAnyKeyword, IEnume
rable`1 arguments, IEnumerable`1 processNamesToFilter, Boolean sendManifest)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServiceWorker.Initialize()
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventService.<>c__DisplayClass6.<AddWorkers>b__2()
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventService.HandleException(String callerName, Action body)
Opcode : Info
Task : 64731
Version : 0
Payload : [faultedElement : svcRuntime] [message : System.Runtime.InteropServices.COMException (0x800705AA): Insufficient system resources exist to complete the requested service. (Exception from HRESU
LT: 0x800705AA)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.InsureStarted(EVENT_TRACE_PROPERTIES* properties)
at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableProvider(Guid providerGuid, TraceEventLevel providerLevel, UInt64 matchAnyKeywords, TraceEventProviderOptions options)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.Utility.TraceEventUtil.EnableProvider(TraceEventSession session, Guid providerId, EventLevel level, EventKeywords matchAnyKeyword, IEnume
rable`1 arguments, IEnumerable`1 processNamesToFilter, Boolean sendManifest)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServiceWorker.Initialize()
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventService.<>c__DisplayClass6.<AddWorkers>b__2()
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventService.HandleException(String callerName, Action body)]
EventName : TraceEventServiceConfigurationFaultInfo
Timestamp : 2015-02-28T10:31:09.3220291Z
ProcessId : 16524
ThreadId : 16984
The In-Process listener works fine. Is there anything else I need to do configure?
In my case it was related to the amount of flat file sinks that I have configured in the SemanticLogging-svc.xml.
It seems once I go past 36 file sinks this error appears.

Enterprise Library issue

We are using Enterprise Library 6.0 and the following code to create database instance and execute a stored procedure? Any help highly appreciated. Thanks in Advance.
DatabaseProviderFactory factory = new DatabaseProviderFactory();
Database db = factory.CreateDefault();
DbCommand dbCommand = db.GetStoredProcCommand("ProcedureName");
OracleParameter outval = new OracleParameter("Test", OracleDbType.RefCursor);
outval.Direction = ParameterDirection.Output;
dbCommand.Parameters.Add(outval);
using (IDataReader reader = db.ExecuteReader(dbCommand))
{
while (reader.Read())
{
}
}
<add name="providerConnString" connectionString="Data Source=ABCD;Password=testuser;User ID=testpwd" providerName="Oracle.DataAccess.Client" />
Intermittently we are receiving the following exception. This is occurring when we are trying to access the application after an idle time. How the connection pooling happens in enterprise library?How will it work if the application is idle for long time? What is the default min pool size and default max pool size?
Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.TypeInitializationException: The type initializer for
'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.CThreadPool' threw an exception. --->
System.Runtime.InteropServices.COMException: Retrieving the COM class
factory for component with CLSID
{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E} failed due to the following
error: 800703fa Illegal operation attempted on a registry key that has
been marked for deletion. (Exception from HRESULT: 0x800703FA). at
Oracle.DataAccess.Client.CThreadPool..cctor() --- End of inner
exception stack trace --- at
Oracle.DataAccess.Client.OracleInit.Initialize() --- End of inner
exception stack trace --- --- End of inner exception stack trace
--- at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean&
domainInitialized) at
System.Reflection.RtFieldInfo.UnsafeGetValue(Object obj) at
System.Reflection.RtFieldInfo.InternalGetValue(Object obj,
StackCrawlMark& stackMark) at
System.Reflection.RtFieldInfo.GetValue(Object obj) at
System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at
Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings.GetDefaultMapping(String
dbProviderName) at
Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings.GetDatabaseData(ConnectionStringSettings
connectionString, DatabaseSettings databaseSettings) at
Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings.GetDatabase(String
name) at
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseProviderFactory.DatabaseConfigurationBuilder.b__2(String
n) at
System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey
key, Func2 valueFactory) at
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseProviderFactory.DatabaseConfigurationBuilder.CreateDefault()
I had a issue with the App pool identity user in IIS. I removed the identity user and put the default identity user. Then reverted back to my custom user identity. This resolved my issue.

Python.CreateEngine() eventually throws System.Reflection.TargetInvocationException

After several cycles of debugging, Python.CreateEngine() eventually throws the exception shown below. I don't know why this is occurring and the version that I have installed is actually 2.7.4.1. I end up reinstalling IronPython and the exception disappears, but it eventually returns. I am using VS2010 with Windows 7.
System.Reflection.TargetInvocationException occurred
HResult=-2146232828
Message=Failed to load language 'IronPython 2.7.2.1': Method not found: '!!1[] Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(!!0[], System.Func`2<!!0,!!1>)'.
Source=Microsoft.Scripting
StackTrace:
at Microsoft.Scripting.Runtime.LanguageConfiguration.LoadLanguageContext(ScriptDomainManager domainManager, Boolean& alreadyLoaded)
at Microsoft.Scripting.Runtime.DlrConfiguration.LoadLanguageContext(ScriptDomainManager manager, LanguageConfiguration config)
at Microsoft.Scripting.Runtime.DlrConfiguration.TryLoadLanguage(ScriptDomainManager manager, AssemblyQualifiedTypeName providerName, LanguageContext& language)
at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageByTypeName(String providerAssemblyQualifiedTypeName)
at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngineByTypeName(String assemblyQualifiedTypeName)
at IronPython.Hosting.Python.GetEngine(ScriptRuntime runtime)
at IronPython.Hosting.Python.CreateEngine()
at OneWireTest.Form1.InitializeScriptEngine() in D:\IPYTest\Form1.cs:line 374
InnerException: System.MissingMethodException
HResult=-2146233069
Message=Method not found: '!!1[] Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(!!0[], System.Func`2<!!0,!!1>)'.
Source=IronPython
StackTrace:
at IronPython.Runtime.PythonContext..ctor(ScriptDomainManager manager, IDictionary`2 options)
InnerException:

Categories