Enterprise Library issue - c#

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.

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.

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:

Failure in delete performance counter category

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

IBatis.net converting project from VS2003 to VS2008 crashes on load

The project has been working fine in 2003 but when opening it in 2008 we now get the below error. I've tried ripping all of the code out of the 'Accessory' result map and then it just goes onto the next result map and tells me the same error with that one. Any thoughts?
[ERROR]-- Accessing Accessory Datasource --
Error: Data connection configurations are invalid.
Descriptive: Net.Autodata.Accessories.Exceptions.AccessoryConnectException: Failed loading iBATIS.NET Default SQL MAP ---> IBatisNet.Common.Exceptions.ConfigurationException:
- The error occurred while loading SqlMap.
- initialize ResultMap
- The error occurred in .
- Check the Accessories.Accessory. ---> IBatisNet.Common.Exceptions.ConfigurationException: Could not configure ResultMap named "Accessories.Accessory", Cause: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at IBatisNet.Common.Utilities.Objects.ObjectFactory.CreateFactory(Type typeToCreate, Type[] types)
at IBatisNet.DataMapper.Configuration.ResultMapping.ResultMap.GetChildNode(ConfigurationScope configScope)
at IBatisNet.DataMapper.Configuration.ResultMapping.ResultMap.Initialize(ConfigurationScope configScope)
--- End of inner exception stack trace ---
at IBatisNet.DataMapper.Configuration.ResultMapping.ResultMap.Initialize(ConfigurationScope configScope)
at IBatisNet.DataMapper.Configuration.Serializers.ResultMapDeSerializer.Deserialize(XmlNode node, ConfigurationScope configScope)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.BuildResultMap()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureSqlMap()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao)
--- End of inner exception stack trace ---
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, Boolean useConfigFileWatcher)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(String resource, ConfigureHandler configureDelegate)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(ConfigureHandler configureDelegate)
at IBatisNet.DataMapper.Mapper.InitMapper()
at IBatisNet.DataMapper.Mapper.Instance()
at Net.Autodata.Accessories.Processing.Editor.AccessoryEditor..ctor() in C:\Perforce\Clients\GM\Accessories\Editor\main\Editor.Processing\AccessoryEditor.cs:line 94
--- End of inner exception stack trace ---
at Net.Autodata.Accessories.Processing.Editor.AccessoryEditor..ctor() in C:\Perforce\Clients\GM\Accessories\Editor\main\Editor.Processing\AccessoryEditor.cs:line 98
at Net.Autodata.Accessories.Editor.AccessoryEditor.LoadEditor() in C:\Perforce\Clients\GM\Accessories\Editor\main\Editor\AccessoryEditor.cs:line 1028
Project was originally compiled with .Net v1.1 Upgraded IBatis DLL's to 2.0 and now it works fine.

Categories