допустим у меня есть веб приложение, оно использует dllку. перед тем как вызвать любой метод из dll я хочу что бы в dll вызвался метод например OnLoading
как такое сделать?
Здравствуйте, -rsdn-, Вы писали:
R>допустим у меня есть веб приложение, оно использует dllку. перед тем как вызвать любой метод из dll я хочу что бы в dll вызвался метод например OnLoading
R>как такое сделать?
PreApplicationStartMethodAttribute
This new attribute allows you to have code run way early in the ASP.NET pipeline as an application starts up. I mean way early, even before Application_Start. This happens to also be before code in your App_code folder (assuming you have any code in there) has been compiled. To use this attribute, create a class library and add this attribute as an assembly level attribute. A common place to add this would be in the AssemblyInfo.cs class within the Properties folder. Here’s an example:
[assembly: PreApplicationStartMethod(typeof(SomeClassLib.Initializer), "Initialize")]
Note that I specified a type and a method. That method needs to be a public static void method with no arguments. Now, any ASP.NET website that references this assembly will call the Initialize method when the application is about to start, giving this method a chance to do perform some early initialization.
public static class Initializer
{
public static void Initialize() {
// Whatever can we do here?
}
}
http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx
Здравствуйте, -rsdn-, Вы писали:
R>допустим у меня есть веб приложение, оно использует dllку. перед тем как вызвать любой метод из dll я хочу что бы в dll вызвался метод например OnLoading
R>как такое сделать?
http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyload%28v=vs.110%29.aspx
Подойдет?
Здравствуйте, QrystaL, Вы писали:
QL>Здравствуйте, -rsdn-, Вы писали:
R>>допустим у меня есть веб приложение, оно использует dllку. перед тем как вызвать любой метод из dll я хочу что бы в dll вызвался метод например OnLoading
R>>как такое сделать?
QL>[q]
QL>PreApplicationStartMethodAttribute
QL>This new attribute allows you to have code run way early in the ASP.NET pipeline as an application starts up. I mean way early, even before Application_Start. This happens to also be before code in your App_code folder (assuming you have any code in there) has been compiled. To use this attribute, create a class library and add this attribute as an assembly level attribute. A common place to add this would be in the AssemblyInfo.cs class within the Properties folder. Here’s an example:
QL>QL>[assembly: PreApplicationStartMethod(typeof(SomeClassLib.Initializer), "Initialize")]
QL>
у нас так было сделано
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(LightInjectMvcActivator), "Start")]
спасибо! я не знал, Ваше решение лучше
Здравствуйте, artelk, Вы писали:
A>Здравствуйте, -rsdn-, Вы писали:
R>>допустим у меня есть веб приложение, оно использует dllку. перед тем как вызвать любой метод из dll я хочу что бы в dll вызвался метод например OnLoading
R>>как такое сделать?
A>http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyload%28v=vs.110%29.aspx
A>Подойдет?
совсем не то