I'm trying to use Unity.Webforms in a web application without success. As per the documentation, I put the following line in the AssemblyInfo.cs to tell the runtime to invoke a method before the application starts:
[assembly: PreApplicationStartMethod(typeof(Unity.WebForms.PreApplicationStart), "PreStart")]
The error I'm getting says:
The method specified by the PreApplicationStartMethodAttribute on assembly ... cannot be resolved
And this is the class holding the method (within App_Start folder):
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using System;
using System.Collections.Generic;
using System.Web;
namespace Unity.WebForms
{
public static class PreApplicationStart
{
private static bool _isStarting;
public static void PreStart()
{
if (!_isStarting)
{
_isStarting = true;
DynamicModuleUtility.RegisterModule(typeof(UnityHttpModule));
}
}
}
}
Is there anything I'm missing or misunderstanding?
Thanks
Change Unity.Webforms namespace in your custom file with PreApplicationStart, because this namespace already exists.
My solution, that works:
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
namespace TestApp.WebUi
{
public static class PreApplicationStart
{
private static bool _isStarting;
public static void PreStart()
{
if (!_isStarting)
{
_isStarting = true;
DynamicModuleUtility.RegisterModule(typeof(UnityHttpModule));
}
}
}
}
And:
[assembly: PreApplicationStartMethod(typeof(TestApp.WebUi.PreApplicationStart), "PreStart")]