의존성을 해결하기 위해 실패합니다. 유형 'React.TinyIoC.TinyIoCResolutionException'의 예외가 React.dll에서 발생했지만 사용자 코드에서ReactJS.Net 내가 서버 측 렌더링 및 번들을 포함, <a href="http://reactjs.net" rel="nofollow">ReactJS.Net</a>과 함께 일할 수있는 ASP.Net MV5 응용 프로그램을 설정하기 위해 노력하고있어
추가 정보 처리되지
:
불행하게도,이 예외와 함께 실패 할 수 없음 해결 유형 : React.ReactEnvironment
이 예외는,이 라인에서 발생
:
@Scripts.Render("~/bundles/ui-components")
이 줄은 내 _layouts.cshtml
파일입니다.
문제는 어떻게 해결해야합니까?
내가 무슨 짓을했는지 여기에, 세부 사항의 제공하려면 BundleConfig.cs에서
: 나는 폴더 "콘텐츠/UI/구성 요소"를 만들어
내 모든 jsx 파일 (튜토리얼에서 촬영 실제로 하나 "commentsbox.jsx"파일을.bundles.Add(new ScriptBundle("~/bundles/reactjs").Include( "~/Scripts/react/react-{version}.js")); bundles.Add(new JsxBundle("~/bundles/ui-components") .Include("~/content/ui/components/*.jsx"));
ReactConfig.cs에서 Owin 구성 요소의 이점으로 MVC5에서 더 이상 지원되지 않기 때문에
이WebActivatorEx.PreApplicationStartMethod
특성을 제거했습니다. 그것은 포함 스틸 사진 (파일의 맨 아래에)public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { ReactConfig.Configure(); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } }
내
이_layouts.cshtml
보기가 포함되어 있습니다 : 내Global.asax.cs
파일에서public static class ReactConfig { public static void Configure() { ReactSiteConfiguration.Configuration .AddScript("~/content/ui/*.jsx"); } }
, 내가 명시 적으로
WebActivatorEx.PreApplicationStartMethod
후크를 대체 할ReactConfig.Configure
메소드를 호출@Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @Scripts.Render("~/bundles/reactjs") @Scripts.Render("~/bundles/ui-components") @RenderSection("scripts", required: false) @Html.ReactInitJavaScript()
내보기 중 하나 :
,@{ ViewBag.Title = "Home Page"; } <div id="content"></div> @section scripts { @Html.React("CommentBox", new {}, containerId:"content") }
그리고 마지막으로, 내 jsx 파일 :
var CommentBox = React.createClass({ render: function() { return ( <div class="row"> <div class="col-md-4"> hello </div> </div> ); } });
좋은 점은 오류 메시지가 아마도 더 이해하기 쉽다는 것입니다. 나는 InnerException 어딘가에 더 나은 메시지가 숨어 있다고 생각한다. 와일드 카드를 허용하는 Github 문제가 있습니다. https://github.com/reactjs/React.NET/issues/60 –
thx로 링크되어 있습니다. –