Closed cjindustries closed 8 years ago
I'm faced same problem!
Same here after I upgraded to the latest 2.0.1 version. I can't compile any project with code that calls the Humanize extension method.
I think this is related to #537. Do you have any instances of ImplicitlyExpandDesignTimeFacades
in your csproj file? If you add that and set it to true, does that help?
I have the same issue afer upgrading from 1.3.7 to 2.0.1 using ASP.NET MVC5 .Net 4.6.
System.Web.HttpCompileException (0x80004005): error CS0012: The type 'System.Globalization.CultureInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)
I tried to add as you suggested: <ImplicitlyExpandDesignTimeFacades>true</ImplicitlyExpandDesignTimeFacades>
to my csproj file, but that didn't help.
@davkean do you have any ideas here? These are standard PCL contract assemblies? What could be going on here?
Thanks for the quick reply @davkean!
I've updated the documentation to reflect the need for this here: https://github.com/Humanizr/Humanizer#aspnet4mvc
For future readers, if you don't want to dump a hundred lines of configuration into your web.config (i sure don't want to) this is all that was necessary
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Globalization, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Runtime, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
The System.Runtime one seems more optional, but it made resharper happier in the view file so i'm including it.
You might want to double verify your web.release.config or other transforms that they will properly respect these changes. The default
<compilation xdt:Transform="RemoveAttributes(debug)" />
should be directly compatible, but if you changed it to xdt:Replace
or other transforms you may have to update these too
I am having the same issue in a Windows Forms application. Adding the following to App.config does not help:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" version="" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
</dependentAssembly>
</runtime>
Any clues?
I just came across this issue today also. I understand the problem and the fix, but I am curious why I needed to add the compilation assembly reference now. As far as I understand Humanizer has always been a PCL, and as such this would always have been a problem?
Hi all,
I'm getting this when viewing a page in a MVC5 web project targeting .NET 4.6.1 when I do a Humanize() call on a DateTime:
Compiler Error Message: CS0012: The type 'CultureInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Anyone else getting this and is there a workaround?
If I try and add a reference by browsing to the package it downloaded or the file in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\Facades it won't even build.
Thanks for any pointers, Chris.