Closed joelnet closed 11 years ago
I wasn't able to repro this. Here is my test app: https://github.com/davidebbo-test/WebActivatorBug12. Can you try with that app to see if you repro? If not, maybe there are differences with what you're doing?
It looks like it's something specific to one of the machine's here. On one machine it produces an exception, on the other machine, no exception. (aren't these fun to trouble shoot?)
I will attempt to discover the difference.
Yeah, that's a weird error; no idea what that even means! :) And very few references to it out there, so it's not at a common thing.
And if you switch back to the older Microsoft.Net.Http, it definitely doesn't happen?
Here is where WebActivator calls GetCustomAttributes
: https://github.com/davidebbo/WebActivator/blob/master/WebActivator/AssemblyExtensions.cs#L12. If you debug it, you should be able to tell which specific assembly is triggering that. And then maybe you can isolate to a simple Console app repro that just does that on that assembly.
i've never seen that error before either. and ya, if i switch back to v2.0.20710.0 it starts to work again. I'll poke around it some more tomorrow.
Has anyone found out why this is happening. I am getting this error. WebActivator is added when im trying to add Ninject.MVC3 to my project. I have another project running webactivator v2.0.20710.0 and its running fine.
I'm yet to be able to repro this myself, making it hard to investigate. If you have a repro, can you try isolating it as I suggest above (calling GetCustomAttributes
directly to see what assembly causes it)?
Hi David, How to i call this. Im fairly new to all of this.
For my project it only happens when i updated ALL the base MVC Internet Template then added Ninject which add WebActivator.
You can reproduce it this way.
I gave him the steps to reproduce, and it works just fine on his machine. He also gave me his project, which doesn't work on my machine. It seems to be something specific to our machines maybe like .net version or some other assembly.
This is just one of about a handful off issues I've been having on this project so I haven't had time to look into it further. I'm going to test this later.
No i think it has to do with what you have installed for your project.
Heres the debug info.. and steps to reproduce
T = WebActivatorEx.PreApplicationStartMethodAttribute Assembly = System.Net.Http.Primitives, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Under CustomAttributes says assembly.CustomAttributes threw and exception of type 'System.MissingMethodException'
Hope this helps
Hmmm, interesting that you get a MissingMethodException. If you run it in debugger with Break on all Exceptions, can you maybe get more details? e.g. what specific method is missing, and from where?
I think we've established that these repro steps don't actually repro the issue on all machines, only on some.
Sorry never dont that before how to i do that in VS2012?
The error I was getting was not System.MissingMethodException, it was System.ArgumentException.
I do not believe it has to do with what is installed (nuget) in the project. I ran David's project exactly as it was, which works for him, yet I got the error message above.
@LorenDorez Try:
It still breaks at the same point.
All i see digging in the Assembly object is Method not found: 'Void
@joelnet I notice david's project wasnt using the latest versions System.Net.Http and all of its dependecies like OpenAuth etc.. that the Basic Internet Template for MVC4 comes with
@LorenDorez it contains this in the packages.config (https://github.com/davidebbo-test/WebActivatorBug12/blob/master/MvcApplication5/packages.config), which is the latest released build:
Though regardless, his project works on his machine, yet the same exact project produces the error on my machine, which is why he's not able to reproduce.
@joelnet David Pack is not using the lastest MVC See here
HIS:
Differeences like these make all the difference.
It appears the System.Net.Http.Primitives.dll method GetCustomAttributes doesnt have or load the modules properly.
If i change From
return assembly.GetCustomAttributes(
typeof(T),
inherit: false).OfType
To
return assembly.GetModules(false)[0].GetCustomAttributes(
typeof(T),
inherit: false).OfType
Everything works just fine. I will try later tonight to decompile the System.Net.Http.Primitives.dll
Hmmm, interesting. What's strange is that is I evaluate a.GetModules().Length
for System.Net.Http.Primitives.dll, it only finds one module. Maybe there is more than one for you?
Hi David, no just one for me as well. From what im seeing the System.Net.Http.Primitives.dll doesnt support the method call for CustomAttributes
Strange that it worked when you called assembly.GetModules(false)[0].GetCustomAttributes()
instead, since in the end it's the same module.
Back to your earlier finding about it relating to Void ..ctor(System.String)
. Can you tell what type this ctor is supposed to be on?
I get that message when i did through the main assembly > Base > base > Base etc..
Also from what i can tell System.Net.Http.Primitives is a completely blank module, there is no actual code inside the default namespace. And ill im finding on the web is its something MS is planning to use to help with backwards compatibility for .net 40 and 4.5 apps
I really wish I could repro myself. But if all else fails, I think using assembly.GetModules(false)[0].GetCustomAttributes()
should be ok. Please make sure it works well, and if so, send a pull request and I'll get it in.
Actually, an alternate approach would be to just ignore exceptions when assembly.GetCustomAttributes
throws, as it really should not happen for 'normal' assemblies.
David If you do my steps you should be able to reproduce it but you need to make sure you MVC projects gets updated to the lastest version also might have to install WebTools 2012.2.
Here is how i get to the Voide
assembly > Custom Attributes (Currently says threw an ex of type 'System.MissingMethodException') > base >base> base > base (Thats Base 4 times) >
Actually a Pic probably does better..
I still can't repro, but I put in a workaround to ignore GetCustomAttributes
exceptions. Can you upgrade to WebActivatorEx 2.0.2 to verify that it fixes it?
Whilst I'm not a user of WebActivator I have encountered the very same issue in my own app and came across this thread when trying to work out the cause. I am running some of the prerelease ASP.Net bits - I suspect some of them are relying on other ASP.Net bits that haven't yet been released and the problem will end up righting itself in the coming days as new nightly packages get published. (at least I'm hoping!)
Hi David this updates works on my test. Now i just need to get ninject to update the reference/dependency to this new version.
If i knew how to upload to GIT i could upload my test project for you try try an reproduce
David i think i figured out how to upload/make repositories on here...
https://github.com/LorenDorez/WebActivator-Test
I had to create a New WebAppTest as you wasnt working correctly. See if you can download that and reproduce
Note from above that @joelnet was able to repro with my test app, while I wasn't. So we know it is not simply a function of the app, but some other machine factors (that we don't understand) come into play as well.
In any case, hopefully with the fix it's not longer an issue. Note that you shouldn't need to get ninject to update (although they should). All you have to do is update the WebActivator NuGet package in your solution, and everything should be fine.
@IanYates I hope you're right, but I wouldn't bet on it given how poorly we understand the issue. The team may not know about it at all.
If you have Telerik JustMock remove and solve the problem. See http://www.telerik.com/community/forums/justmock/general-discussions/after-installing-justmock-i-get-token-0x02000001-metadatatoken.aspx
I do have JustMock installed as part of the Telerik DevCraft suite but haven't made any use of JustMock itself yet. I'll remove it and see what happens. I found a couple of other links on the net for this issue from some time back to do with Delphi's ill-fated .NET product and I think the root cause was possibly similar (attributes from a non-existent or misbehaving assembly) Cheers for the tip! Much appreciated :)
Interesting ill uninstalled JustTrace and run some more tests this weekend.
Oh, so is the Theory that this Telerik software was the root of this issue? Does everyone on this thread who ran into the WebActivator issue have this software installed?
@davidebbo
I have JustMock installed. I just uninstalled all Telerik products and the test project you gave me ran just fine.
I have since downloaded the latest version of JustMock and after reinstalling, things still seem to be working fine.
My problem appears to have been some sort of conflict with JustMock, WebActivator and HttpClient.
Thanks for your help!
Cool. Well, I have the fix in WebActivator anyway, so hopefully we won't see this again!
@joelnet, can you confirm what version of JustMock you installed in which the problem was resolved?
I just installed the latest. The version is 2013.1.507.0
I had the same problem. BTW, you have to actually uninstall JustMock from add and remove programs, disabling it doesn't help.
I've updated to the latest JustMock and the problem has gone away for me too.
I created a New ASP.NET MVC 4 Project and selected Web API as my template. This template installs the package Microsoft.Net.Http version 2.0.20710.0. If I upgrade this package to 2.1.10 (http://nuget.org/packages/Microsoft.Net.Http/2.1.10) WebActivator throws the following exception when I run the project...
Server Error in '/' Application.