Nesper - LoaderExceptions - c#

I am building a Nesper application and after deployment it throws this error:
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at com.espertech.esper.script.ScriptingServiceImpl.DiscoverEngines(Assembly assembly, Predicate`1 isEngine)
at com.espertech.esper.script.ScriptingServiceImpl.DiscoverEngines(Predicate`1 isEngine)
at com.espertech.esper.core.service.EPServicesContextFactoryDefault.CreateServicesContext(EPServiceProvider epServiceProvider, ConfigurationInformation configSnapshot)
at com.espertech.esper.core.service.EPServiceProviderImpl.DoInitialize(Nullable`1 startTime)
at com.espertech.esper.core.service.EPServiceProviderImpl..ctor(Configuration configuration, String engineURI, IDictionary`2 runtimes)
at com.espertech.esper.client.EPServiceProviderManager.GetProvider(String providerURI, Configuration configuration)

After I printed the LoaderExceptions, it shows that these two libraries are missing:
DevExpress.Printing.v13.2.Core
DevExpress.Sparkline.v13.2.Core

Related

ReflectionTypeLoadException exception in Asp.Net Core in-memory TestServer

I create a IWebHostBuilder like so:
public IWebHostBuilder GetWebHostBuilder()
{
return new WebHostBuilder().UseContentRoot(_contentRoot)
.ConfigureServices(InitializeServiceCollection)
.UseEnvironment(_environment)
.UseConfiguration(GetConfiguration())
.UseStartup(typeof(TStartup));
}
Here, the InitializeServiceCollection is implemented like so:
private void InitializeServiceCollection(IServiceCollection services)
{
var manager = new ApplicationPartManager();
manager.ApplicationParts.Add(new AssemblyPart(_assembly));
manager.FeatureProviders.Add(new ControllerFeatureProvider());
manager.FeatureProviders.Add(new ViewComponentFeatureProvider());
services.AddSingleton(manager);
}
Then I create the TestServer like so:
var myTestServer = new TestServer(GetWebHostBuilder());
Here I get the exception (full exception below). It gets thrown at services.AddAutoMapper(); method call in the system under test. However, when I run the system under test on it's own and test it manually with Postman, it's working fine and the object mapping with Automapper is working well too. It just raises the exception in the integration test.
Full exception:
System.AggregateException : One or more errors occurred. (Unable to load one or more of the requested types.
Could not load type 'Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalFullAnnotationNames' from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=2.2.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.) (The following constructor parameters did not have matching fixture data: TestFixture fixture)
---- System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types.
Could not load type 'Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalFullAnnotationNames' from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=2.2.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
---- The following constructor parameters did not have matching fixture data: TestFixture fixture
----- Inner Stack Trace #1 (System.Reflection.ReflectionTypeLoadException) -----
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeAssembly.get_DefinedTypes()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at AutoMapper.ServiceCollectionExtensions.AddAutoMapperClasses(IServiceCollection services, Action`2 configAction, IEnumerable`1 assembliesToScan) in xxx\automapper-extensions-microsoft-dependencyinjectio\src\AutoMapper.Extensions.Microsoft.DependencyInjection\ServiceCollectionExtensions.cs:line 72
at xxx.Startup.ConfigureServices(IServiceCollection services) in xxx\Startup.cs:line 35
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection)
at xxx.Tests.TestFixture.InitializeServer() in xxx.Tests\TestFixture.cs:line 67
at xxx.Tests.TestFixture..ctor() in xxx.Tests\TestFixture.cs:line 31
----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----
So, I managed to resolve the issue by replacing services.AddAutoMapper() with services.AddAutoMapper(Type[] types) overload. Not sure what is wrong with the original method, but in order to avoid that reflective call on the assemblies, I used this overload and it's working now.

Dapper unable to cast object of type 'Microsoft.SqlServer.Types.SqlGeography' to type 'System.Data.Entity.Spatial.DbGeography'

I have EF configured with a Location field on my User table:
public DbGeography Location { get; set; }
However when I query my User table with:
user = connection.Query<User>("update [User] set LastOnline = #lastOnline output INSERTED.* where Username = #un",
new { lastOnline = DateTime.UtcNow, un = username }).First();
I get the following error:
Message=Error parsing column 122 (Location=POINT (-118.2436849
34.0522342) - Object) Source=Dapper StackTrace:
at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value) in
d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 4045
at Deserialize4650b5f0-d037-49ad-802e-8a9be95e8496(IDataReader )
at Dapper.SqlMapper.d__111.MoveNext() in d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1572
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1
commandTimeout, Nullable1 commandType) in
d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1443
at App.Services.BrowseService.GetProfiles(ProfileSearchDto query, String username, Boolean isAdmin) in
c:\PROJECTS\App\App-MAIN\App\Services\BrowseService.cs:line 330
InnerException: System.InvalidCastException
HResult=-2147467262
Message=Unable to cast object of type 'Microsoft.SqlServer.Types.SqlGeography' to type
'System.Data.Entity.Spatial.DbGeography'.
What is causing this?
Update
Just for kicks, I tried using EF:
db.Database.SqlQuery<User>("bla bla")
And I get a different error:
Message=No mapping exists from object type
<>f__AnonymousTypef`2[[System.DateTime, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]] to a known managed provider native
type. Source=System.Data
goes bald
Conclusion
My app needs to search by radius and currently uses a naive lat/long boxed query. I was trying to upgrade my implementation to use spatial types, but it looks like my tooling doesn't support this scenario. Back to being naive I go.
Dapper doesn't support Entity Framework types in the core library, to reduce the number of dependencies. However, it has an extensible type-handler model, and bindings for DbGeography are included in the Dapper.EntityFramework package. Once you have added that, you need to call:
Dapper.EntityFramework.Handlers.Register();
to ask the add-in to register itself. And then it should work. If you get assembly mismatch exceptions, you should be able to resolve it with assembly binding redirects. This applies in particular to the underlying SqlGeography type, where the metadata that SQL Server returns is a different version to the metadata in the Microsoft.SqlServer.Types package. But an assembly-binding redirect works fine.

App.Config does cannot access section specified

http://pastebin.com/QaCCM2Zv
I have a config file in the above link, every time i try to access the section 'InventoryFactory' using this code:
var config = (ObjectFactoryConfiguration)ConfigurationManager.GetSection("InventoryFactory");
it returns an error:
An exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll but was not handled in user code
Additional information: An error occurred creating the configuration section handler for InventoryFactory: Could not load type 'WDG.ObjectFactory.ObjectFactoryConfiguration' from assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Any idea guys? Thanks :
If you haven't done so already you probably need to set up a custom configuration section handler to parse the "InventoryFactory" section into your "ObjectFactoryConfiguration" object. The error message indicates that the runtime is trying to load the "WDG.ObjectFactory.ObjectFactoryConfiguration" class from the "System.Configuration" assembly which wouldn't contain any of your custom classes.
...Also, you want to specify the assembly in the section, if you look at the line right above yours:<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> you can see at the end there the "log4net" assembly has been specified. Try putting the name of your assembly which contains the "ObjectFactoryConfiguration" class in the type attribute as well.

Telerik.OpenAccess.OpenAccessException was unhandled by user code

The following is error I am getting. Please help on this.
Telerik.OpenAccess.OpenAccessException was unhandled by user code
Message=No metadata has been registered for class Ind.Data.IndiStage.Academy. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///C:/Users/suresh/Documents/WorkSpace/Ind_folder/Ind.ETLService/bin/Release/Ind.Data.IndiStage.DLL.)
Source=Telerik.OpenAccess
CanRetry=true
StackTrace:
at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
at OpenAccessRuntime.ExceptionWrapper.Throw()
at OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createSmfForURL()
at OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createStorageManagerFactory()
at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp.createStorageManagerFactory()
at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryBase.init()
at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp.init()
at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp..ctor(PropertySet properties, Object classloader)
at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp.getPersistenceManagerFactory(PropertySet props)
at OpenAccessRuntime.DataObjects.BootstrapPMF.getPersistenceManagerFactory(PropertySet props)
at OpenAccessRuntime.Helper.getPersistenceManagerFactory(PropertySet props)
at OpenAccessRuntime.DatabaseAdapter.AssertPersistenceManagerFactory(String usr, String password, Boolean open)
at OpenAccessRuntime.DatabaseAdapter.GetObjectScope(TransactionProvider provider)
at Telerik.OpenAccess.Database.GetObjectScope(TransactionProvider provider)
at Telerik.OpenAccess.OpenAccessContextBase.GetScope()
at Telerik.OpenAccess.OpenAccessContext.GetAllCore[T]()
at Telerik.OpenAccess.OpenAccessContext.GetAll[T]()
at System.Timers.Timer.MyTimerCallback(Object state)
InnerException:
wow.
I got a hardtime to get rid of this exception. "No metadata has been registered for class" with Telerik OpenAccess.
read this article especially you use CI build system like TeamCity: http://docs.telerik.com/data-access/developers-guide/integrating-data-access-in-your-solution/external-tools-howto-integrate-enhancer-msbuild

A Cause for HRESULT 0X80131468 when accessing IsolatedStorageBackingStore

The scenario I am facing is that I have an ASP.NET web service (.NET 3.5) running on an W2k3 server which is using the CacheManager/IsolatedStorage store to store a persisted state variable. This configuration has been working fine for quite sometime until we changed the physical machine. Now whenver the code that accesses that value runs it throws an IsolatedStorageException (Posted below). As I understand it the user/assembly store is what is being accessed and the executing user is a member of the local administrators group. Does anyone have a suggestion as to what privilege is missing?
Error
Unable to create the store directory. (Exception from HRESULT: 0x80131468)
Stack Trace
Type: Microsoft.Practices.ObjectBuilder2.BuildFailedException. Error: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, Cache Manager]) failed: Unable to create the store directory. (Exception from HRESULT: 0x80131468) (Strategy type ConfiguredObjectStrategy, index 2). Trace: at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase1.CreateDefault()
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager()
at Ept.Commands.SettlementCommand.BeginSettlement() in c:\Projects\EPT\Ept.Framework.Services\Commands\SettlementCommand.cs:line 102
at Ept.Commands.SettlementCommand.ExecuteKernel(SettlementRequest request) in c:\Projects\EPT\Ept.Framework.Services\Commands\SettlementCommand.cs:line 188
at Ept.Command2.Execute(TRequest request) in c:\Projects\EPT\Ept.Framework.Services\Commands\Command.cs:line 79. ExecutingStrategyTypeName: ConfiguredObjectStrategy ExecutingStrategyIndex: 2 BuildKey: Build Key[Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, Cache Manager] Type: System.IO.IsolatedStorage.IsolatedStorageException. Error: Unable to create the store directory. (Exception from HRESULT: 0x80131468). Trace: at System.IO.IsolatedStorage.IsolatedStorageFile.nGetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore.Initialize()
at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore..ctor(String storageAreaName, IStorageEncryptionProvider encryptionProvider)
at Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.IsolatedStorageBackingStoreAssembler.Assemble(IBuilderContext context, CacheStorageData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedObjectFactory2.Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory2.Create(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerAssembler.Assemble(IBuilderContext context, CacheManagerDataBase objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedObjectFactory2.Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheManagerCustomFactory.Create(IBuilderContext context, CacheManagerDataBase objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory2.Create(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory`2.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context).
The root cause of the issue is that the account which the web service was running under did not have a local user profile created thus the user assembly store didn't exist. The simple fix was just to logon to the box with the service account.
If you are using Windows 2012 R2 and IIS 8.5, in the case your App is running on a specific Application Pool under its own identity, you need to check that the option "Load user Profile" in the Pool Advanced Parameters is set to True.
By doing so, Windows will create a folder having App Pool Identity name under C:\Users and allow your app to write inside the local storage.
I had this issue but creating "C:\Documents and Settings\Default User\Local Settings\Application Data\IsolatedStorage" did not resolve the problem because at some point there was a profile name change. The actual location for this server was "C:\Documents and Settings\Default User.WINDOWS\Local Settings\Application Data\IsolatedStorage".
If that does not work, I used Process Monitor with a filter for "IsolatedStorage" to find the correct path for the access denied error.
On Windows 10 IIS Application Pool setting "Load User Profile" is True by default. But on Windows 2012 is False. Switching to True solved my issue.

Categories