Base solution for your next web application

Activities of "amwdrizz"

Here is a Gist of the stack trace [https://gist.github.com/amwdrizz/73bb6abb62f29bec404c96f10812fd0e])

I have tried adding DefaultDbContext to the CoreDBContext class, no change in operation. In fact that is the only thing that permits Core + Module to function. I apologize if I wasn't clear about that.

My current solution was to do the following.

Create generic role builder under core. Reference the core ef project from the modules. Then call the generic role builder from each module. This allowed me to drop the AbpZeroDBContext requirement from the sub-modules. Once I did that, the app launched with out error.

Still testing to ensure nothing else broke in the process, but it looks promising.

Using ABP 0.12 across the board, I have 1 master solution containing the core projects (EF,App,Core,Web,WebApi). In addition I have several 'Module' projects (each on their own with their own EF,App,Core). Each module project has a base repo/ef configuration to allow them to manage their own tables. I have 2 modules right now. When I tell the Web module to load the second module as a dependancy, it throws the error 'Multiple Concrete DBContext defined'

The way I have it laid out is as so

Master -> MainDbContext (Abstract) (No Repo's/Tables) Core -> CoreDbContext (Public / non abstract / inherits MainDbContext) (Contains all core tables + ABP+Zero Tables) Module 1 -> Module1DbContext (Public / Non-abstract / Inherits MainDbContext) (Contains only Module 1 tables) Module 2- > Module2DbContext (Public / Non-Abstract / Inherits MainDbContext) (Contains only Module 2 tables)

Master & Core are in the same EF project, the other modules link to that EF project to get the Master context and build.

The odd thing, maybe not so odd. Is that everything works when I disable one of the modules. Each module is referenced identically.

Thanks for any help,

amwdrizz

Answer

<cite>hikalkan: </cite> It seems related to EntityFramework. See <a class="postlink" href="http://stackoverflow.com/questions/10087508/the-magic-number-in-gzip-header-is-not-correct-make-sure-you-are-passing-in-a-g">http://stackoverflow.com/questions/1008 ... ing-in-a-g</a> for example.

That was the problem, thank you for catching that. Seems like the __migrationHistory table got corrupted some how. Soon as I truncated that table (emptied it), everything started working as it should.

Thanks.

Question

I am running into an issue on deploying ASP.Net Boilerplate to IIS 8 / Windows 2012 R2. I have a Windows 2012 R2 server spun up with a default install of IIS 8/8.5? (Which ever comes with it). Enabled ASP.Net 4.5, installed .Net 4.5.2 web installer so it has .Net 4.5.2 installed. Doing a file layout publish (not a web pack zip file). The database is configured, and seeded. The website correctly points to the database.

I get the following error:

The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.

Source Error:

Line 70:                     <label class="control-label visible-ie8 visible-ie9">Tenancy Name</label>
Line 71:                     <input type="text" class="form-control form-control-solid placeholder-no-fix" id="TenancyName" name="TenancyName" placeholder="Tenancy name" maxlength="@Onyxeye.MultiTenancy.Tenant.MaxTenancyNameLength">
Line 72:                     <span class="text-muted">@L("CanBeEmptyToLoginAsHost")</span>
Line 73:                 </div>
Line 74:             }

Stack Trace:

[InvalidDataException: The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.]
   System.IO.Compression.GZipDecoder.ReadHeader(InputBuffer input) +8407780
   System.IO.Compression.Inflater.Decode() +560
   System.IO.Compression.Inflater.Inflate(Byte[] bytes, Int32 offset, Int32 length) +118
   System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 count) +85
   System.Xml.XmlTextReaderImpl.InitStreamInput(Uri baseUri, String baseUriStr, Stream stream, Byte[] bytes, Int32 byteCount, Encoding encoding) +350
   System.Xml.XmlTextReaderImpl.FinishInitStream() +79
   System.Xml.XmlReaderSettings.CreateReader(Stream input, Uri baseUri, String baseUriString, XmlParserContext inputContext) +111
   System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings, String baseUri) +50
   System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options) +119
   System.Data.Entity.Migrations.Edm.ModelCompressor.Decompress(Byte[] bytes) +108
   System.Data.Entity.Migrations.History.HistoryRepository.GetLastModel(String& migrationId, String& productVersion, String contextKey) +1256
   System.Data.Entity.Internal.InternalContext.QueryForModel(DatabaseExistenceState existenceState) +344
   System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata, DatabaseExistenceState existenceState) +72
   System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata, DatabaseExistenceState existenceState) +72
   System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +128
   System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +66
   System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +596
   System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +208
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +263
   Abp.EntityFramework.AbpDbContext.Initialize() +101
   Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.ApplyConcerns(IEnumerable`1 steps, Object instance) +98
   Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context) +83
   Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden) +27
   Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally) +57
   Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) +29
   Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) +282
   Castle.MicroKernel.Handlers.ExtendedHandler.InvokeResolvePipeline(Int32 extensionIndex, ResolveInvocation invocation) +119
   Castle.MicroKernel.Handlers.ComponentLifecycleExtension.Intercept(ResolveInvocation invocation) +342
   Castle.MicroKernel.Handlers.ExtendedHandler.InvokeResolvePipeline(Int32 extensionIndex, ResolveInvocation invocation) +261
   Castle.MicroKernel.Handlers.ExtendedHandler.Resolve(CreationContext context, Boolean instanceRequired) +101
   Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy) +154
   Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) +74
   Castle.Windsor.WindsorContainer.Resolve() +65
   Abp.EntityFramework.Uow.EfUnitOfWork.GetOrCreateDbContext() +214
   Castle.Proxies.EfRepositoryBase`2Proxy_2.get_Context_callback() +24
   Castle.Proxies.Invocations.EfRepositoryBase`3_get_Context_4.InvokeMethodOnTarget() +40
   Castle.DynamicProxy.AbstractInvocation.Proceed() +116
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) +73
   Castle.DynamicProxy.AbstractInvocation.Proceed() +595
   Castle.Proxies.EfRepositoryBase`2Proxy_2.get_Context() +154
   Castle.Proxies.EfRepositoryBase`2Proxy_2.get_Table_callback() +15
   Castle.Proxies.Invocations.EfRepositoryBase`3_get_Table_4.InvokeMethodOnTarget() +40
   Castle.DynamicProxy.AbstractInvocation.Proceed() +116
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) +73
   Castle.DynamicProxy.AbstractInvocation.Proceed() +595
   Castle.Proxies.EfRepositoryBase`2Proxy_2.get_Table() +154
   Castle.Proxies.EfRepositoryBase`2Proxy_2.GetAll_callback() +14
   Castle.Proxies.Invocations.EfRepositoryBase`3_GetAll_4.InvokeMethodOnTarget() +36
   Castle.DynamicProxy.AbstractInvocation.Proceed() +116
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) +73
   Castle.DynamicProxy.AbstractInvocation.Proceed() +595
   Castle.Proxies.EfRepositoryBase`2Proxy_2.GetAll() +154
   Abp.EntityFramework.Repositories.&lt;GetAllListAsync&gt;d__3.MoveNext() +80
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   Abp.Localization.&lt;GetLanguagesFromDatabaseAsync&gt;d__35.MoveNext() +788
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +49
   Abp.Threading.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__10`1.MoveNext() +1020
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   Abp.Runtime.Caching.&lt;&lt;GetAsync&gt;b__c>d__f.MoveNext() +339
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +49
   Abp.Runtime.Caching.<GetAsync>d__1.MoveNext() +1459
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   Abp.Runtime.Caching.<GetAsync>d__13`2.MoveNext() +547
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +49
   Abp.Localization.<GetLanguageDictionary>d__2a.MoveNext() +483
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   Abp.Localization.<GetLanguagesAsync>d__0.MoveNext() +288
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +49
   Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task`1 task) +100
   System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() +106
   System.Threading.Tasks.Task.Execute() +110
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +144
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +84
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +49
   Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task`1 task) +100
   Nito.AsyncEx.AsyncContext.Run(Func`1 action) +422
   Abp.Localization.ApplicationLanguageProvider.GetLanguages() +59
   Abp.Localization.MultiTenantLocalizationDictionaryProvider.GetDictionaries() +54
   Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource.GetStringOrNull(String name, CultureInfo culture, Boolean tryDefaults) +69
   Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource.GetString(String name, CultureInfo culture) +26
   ASP._Page_Views_Account_Login_cshtml.Execute() in c:\Program Files (x86)\Onyxeye\Onyxeye Web App Installer\ONX_OUT\Views\Account\Login.cshtml:72
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +143
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +110
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass21.&lt;BeginInvokeAction&gt;b__1e(IAsyncResult asyncResult) +241
   System.Web.Mvc.Controller.&lt;BeginExecuteCore&gt;b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   Castle.DynamicProxy.AbstractInvocation.Proceed() +116
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) +143
   Castle.DynamicProxy.AbstractInvocation.Proceed() +595
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
   Castle.DynamicProxy.AbstractInvocation.Proceed() +116
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) +143
   Castle.DynamicProxy.AbstractInvocation.Proceed() +595
   System.Web.Mvc.MvcHandler.&lt;BeginProcessRequest&gt;b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

Everything works on my dev system. Which is Windows 8.1, VS2015, IIS Express. But for some reason when moved over to a production IIS server it doesn't seem to work. Any thoughts?

Answer

<cite>hikalkan: </cite> Also, does your Modal implements IMustHaveTenant or IMayHaveTenant which may filter entities automatically.

That would be the problem, I glossed over adding the tenantid to the seed method. Thank you for pointing that out.

Question

I am running into an error with my unit tests that fail when testing. But the same code, when in production; executes correctly.

For Ex: I have this unit test function

[Fact]
        public void Get_Model_List()
        {
            var models = _modelAppService.GetModelList(new GetModelInput());
            models.Items.Count.ShouldBe(2);
        }

This returns an error, well ShouldBe resolves to 0 as models is empty. The GetModelList function is below

public ListResultOutput<ModelListDto> GetModelList(GetModelInput input)
        {
            var models = _modelRepository
                .GetAll()
                .Include(p => p.Manufacture)
                .Include(p => p.ModelType)
                .WhereIf(
                    !input.Filter.IsNullOrEmpty(),
                    p => p.Name.Contains(input.Filter)
                )
                .OrderBy(p => p.Name)
                .ToList();
            return new ListResultOutput<ModelListDto>(models.MapTo<List<ModelListDto>>());
        }

That function (above) when called in a production setting returns data correctly. But when that function is called via Unit testing, it returns 0.

Now, I ran some debug checks on the test code. I can see that the seed method is seeding the in-ram db correctly. Other unit tests work. They test the manufacture side of the code; they all work. For ex: This works.

[Fact]
        public void Should_Get_All_Manufactures_Without_Filter()
        {
            var manufactures = _manufactureAppService.GetManufacture(new GetManufactureInput());

            manufactures.Items.Count.ShouldBe(2);
        }

Even moving my Model unit test code to the manufacture class results in an error. The only thing I can think of, is ABP is disposing of the DB before running the Model unit tests.

And for the sake of clarity, below is the entire Model unit test .cs file.

using System;
using Onyxeye.Inventory.Model;
using Onyxeye.Inventory.Model.Inputs;
using Onyxeye.Tests.Sessions;
using Onyxeye.Users;
using Shouldly;
using Xunit;

namespace Onyxeye.Tests.Inventory
{
    public class ModelAppService_Test : OnyxeyeTestBase
    {
        private readonly IModelAppService _modelAppService;

        public ModelAppService_Test()
        {
            _modelAppService = Resolve<IModelAppService>();
        }

        [Fact]
        public void Get_Model_List()
        {
            var models = _modelAppService.GetModelList(new GetModelInput());
            models.Items.Count.ShouldBe(2);
        }
    }
}
Showing 1 to 7 of 7 entries