Coder Social home page Coder Social logo

Comments (12)

picrap avatar picrap commented on May 26, 2024

Hi,

I'm aware of these two. I even had to ignore three errors in my peverify call, here is the batch part in Mr. Advice which checks the generated assemblies:

rem muted errors as follow (not sure muting them is good, but they are no valid errors)
rem 0x801318BF because an advised ctor can call the base class ctor
rem 0x80131859 warning of 'this' being uninitialized in ctor
rem 0x8013184F because .ctor inner (wrapped original) method calls base..ctor()
%peverify% /nologo /hresult /ignore=0x801318BF,0x80131859,0x8013184F %1

I'm open to suggestions if you know how to fix this anyway.

Pascal.

from mradvice.

natehitze avatar natehitze commented on May 26, 2024

I'll try to look into it.

The asp.net project that I'm trying to use MrAdvice in doesn't work. When I
try to access a page, the app pool crashes and I have to go into iis to
restart it. I'll try to get the specific error later, but iirc it said
something about a stack overflow.
On Oct 2, 2015 10:45 PM, "Pascal Craponne" [email protected] wrote:

Hi,

I'm aware of these two. I even had to ignore three errors in my peverify
call, here is the batch part in Mr. Advice which checks the generated
assemblies:

rem muted errors as follow (not sure muting them is good, but they are no valid errors)
rem 0x801318BF because an advised ctor can call the base class ctor
rem 0x80131859 warning of 'this' being uninitialized in ctor
rem 0x8013184F because .ctor inner (wrapped original) method calls base..ctor()
%peverify% /nologo /hresult /ignore=0x801318BF,0x80131859,0x8013184F %1

I'm open to suggestions if you know how to fix this anyway.

Pascal.


Reply to this email directly or view it on GitHub
#48 (comment).

from mradvice.

picrap avatar picrap commented on May 26, 2024

As a first step, try to apply the advices only at a type-level, not assembly-level, and even more, at method-level. Then we'll try to understand what's exactly causing the problem in order to solve it.

from mradvice.

natehitze avatar natehitze commented on May 26, 2024

I created a new project from MVC template to make sure that it wasn't something we were doing in the other solution that caused the problem.

I placed the simple advice on a method and the PEverify passed it.

I placed it on a controller class and PEverfify gave the following error. HOWEVER, the project still runs fine.

[IL]: Error: [C:\Users\Nate\Documents\Visual Studio 2015\Projects\MrAdviceProof\MrAdviceProof\bin\MrAdviceProof.dll : MrAdviceProof.Controllers.HomeController::.ctor][offset 0x00000001][found <uninitialized> ref ('this' ptr) 'MrAdviceProof.Controllers.HomeController'] Uninitialized item on stack.(Error: 0x80131859)
[IL]: Error: [C:\Users\Nate\Documents\Visual Studio 2015\Projects\MrAdviceProof\MrAdviceProof\bin\MrAdviceProof.dll : MrAdviceProof.Controllers.HomeController::.ctor?][offset 0x00000001][found ref ('this' ptr) 'MrAdviceProof.Controllers.HomeController'] Call to .ctor only allowed to initialize this pointer from within a .ctor. Try newobj.(Error: 0x801318BF)
2 Error(s) Verifying C:\Users\Nate\Documents\Visual Studio 2015\Projects\MrAdviceProof\MrAdviceProof\bin\MrAdviceProof.dll  MrAdviceProof       

When I placed it on the assembly, I get the same error repeated for a bunch of classes.

When I run it, the webapp crashes.

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

From looking at the errors, it looks like most of the issues are in constructors. I'm going to start looking at it, but I don't really know where to begin looking in the MrAdvice code.

from mradvice.

picrap avatar picrap commented on May 26, 2024

OK, I'll create an ASP.NET MVC project and check it!

from mradvice.

picrap avatar picrap commented on May 26, 2024

Just to know: is your advice in the same assembly, on in a separated one?

from mradvice.

natehitze avatar natehitze commented on May 26, 2024

Same assembly in the test project that I setup for this, but it will likely
end up in a separate assembly in production code.
On Oct 3, 2015 11:05 AM, "Pascal Craponne" [email protected] wrote:

Just to know: is your advice in the same assembly, on in a separated one?


Reply to this email directly or view it on GitHub
#48 (comment).

from mradvice.

picrap avatar picrap commented on May 26, 2024

An advice placed at assembly level will advice everything: constructors and methods of course, but it will also advise itself, which may lead to a stackoverflow. It should work if you place the advice in an external assembly.

from mradvice.

picrap avatar picrap commented on May 26, 2024

Confirmed: the advice advises itself. I've opened a new issue #49
Regarding your case, this should be solved if you place the advice in another assembly. Let me know!

from mradvice.

natehitze avatar natehitze commented on May 26, 2024

Placing the advice in another assembly did the trick.

However, I ran into a new bug when I applied the advice to the assembly:

System.InvalidCastException was unhandled by user code
  HResult=-2147467262
  Message=Unable to cast object of type 'System.Reflection.RuntimeConstructorInfo' to type 'System.Reflection.MethodInfo'.
  Source=MrAdvice
  StackTrace:
       at ArxOne.MrAdvice.Aspect.AspectInfo.ApplyGenericParameters(Type[] genericArguments)
       at ArxOne.MrAdvice.Invocation.GetAspectInfo(MethodBase methodBase, MethodBase innerMethod, Boolean abstractedTarget, Type[] genericArguments)
       at ArxOne.MrAdvice.Invocation.ProceedAdvice(Object target, Object[] parameters, MethodBase methodBase, MethodBase innerMethod, Boolean abstractedTarget, Type[] genericArguments)
       at <>f__AnonymousType0`2..ctor(<controller>j__TPar controller, <action>j__TPar action)
       at MrAdviceProof.RouteConfig.RegisterRoutes​(RouteCollection routes) in C:\Users\Nate\Documents\Visual Studio 2015\Projects\MrAdviceProof\MrAdviceProof\App_Start\RouteConfig.cs:line 19
  InnerException: 

The following code that came out of the MVC template is where this is coming from:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index" }
            );
    }
}

When I modify it to take out the defaults: parameter, I no longer get the error above. The modified code looks like this:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}"
        );
    }
}

I don't know if this helps or not, but putting the advice on just the RouteConfig class doesn't cause the exception.

from mradvice.

picrap avatar picrap commented on May 26, 2024

Confirmed, there was a bug with constructors in anonymous classes (generic classes, actually), this is fixed in package 1.1.6.

from mradvice.

natehitze avatar natehitze commented on May 26, 2024

Thanks! I updated the package and the project is working perfectly.

from mradvice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.