dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.32k stars 9.97k forks source link

System.TypeLoadException: Could not load type 'Microsoft.Framework.DependencyInjection.Fallback.ServiceCollectionExtensions' #244

Closed anuraj closed 9 years ago

anuraj commented 9 years ago

I am getting an exception like this System.TypeLoadException: Could not load type 'Microsoft.Framework.DependencyInjection.Fallback.ServiceCollectionExtensions' from assembly 'Microsoft.Framework. DependencyInjection, Version=1.0.0.0, ulture=neutral, PublicKeyToken=null'. at Microsoft.AspNet.Hosting.Program.Main(String[] args)

while running my web app using k web command. Application is compilable using kpm build

I tried upgrading kvm, changed runtime, removed .kpm and .kre folders still issue exists

davidfowl commented 9 years ago

Sounds like you're mixing versions of things. What version of the KRE are you using? What version of MVC are you using?

anuraj commented 9 years ago

KRE - 1.0.0-beta1 MVC - 6.0.0-beta1

davidfowl commented 9 years ago

Are you sure?

anuraj commented 9 years ago

Yes

Directory of C:\Users\Anuraj.kre\packages 12/22/2014 07:10 AM

kre-clr-amd64.1.0.0-beta1 12/22/2014 06:45 AM kre-clr-x86.1.0.0-beta1 12/22/2014 07:03 AM kre-coreclr-x86.1.0.0-beta1

And

Directory of C:\Users\Anuraj.kpm\packages\Microsoft.AspNet.Mvc 12/22/2014 06:54 AM

6.0.0-beta1

anuraj commented 9 years ago

And here is output of KVM list

kvmlist

Praburaj commented 9 years ago

ServiceCollectionExtensions previously lived in the Microsoft.Framework.DependencyInjection.Fallback namespace. As @davidfowl said it makes me thing you have some old versions stuck somewhere.

I tried upgrading kvm, changed runtime, removed .kpm and .kre folders still issue exists

Do you have a different "packages" folder configured in your global.json?

anuraj commented 9 years ago

No. I don't have a packages folder configured in global.json. I don't have a global.json file

anuraj commented 9 years ago

Not sure, but I found something like this, when ever I add reference of SignalR it is creating problem. If I remove SignalR reference, and kpm restore, it is working without any issue. Is there any relation / dependencies?

davidfowl commented 9 years ago

Nope, it just sounds like a version mismatch.

anuraj commented 9 years ago

Right now I can fix it by removing the SignalR reference, but I am facing same issue with Moq reference.

Praburaj commented 9 years ago

Could you copy paste your project.json contents and the output of your kvm list command to the bug?

davidfowl commented 9 years ago

Yep, This specific exception just means that you're mixing versions like beta1,beta2 rc1 of different things. And then there's the KRE version. It's always been that issue. Are you aware of what concrete versions are the packages and KRE you are actually referencing?

anuraj commented 9 years ago

project.json

project_json

Result of KVM list command

kvmlist

k --version returns 1.0.0-beta1-10662

suhasj commented 9 years ago

@anuraj Microsoft.Framework.CodeGenerators.Mvc has version 1.0.0-* defined. Can you check if that is pulling in beta2 packages ?

anuraj commented 9 years ago

No I think - Here is the result from kpm restore

codegen

suhasj commented 9 years ago

ok so you have a mixture of rc1 beta2 packages and you are running against beta1 version kvm. Your kpm restore should restore all beta1 packages for consistency

Praburaj commented 9 years ago

Rc1 bits are from the myget feed - but you can some beta1 bits. Try replacing all *s in project.json with beta1 and change xunit.runner.kre to Xunit.KRunner. I think xunit.runner.kre is available only in the myget feed.

Or alternatively you can fully switch using the the latest RC1 bits and that should work as well.

Praburaj commented 9 years ago

For myget feed url: https://github.com/aspnet/MusicStore/blob/dev/NuGet.Config#L4. To pull down all the latest bits from myget feed use a * in version numbers of applicable packages like this : https://github.com/aspnet/MusicStore/blob/dev/src/MusicStore/project.json https://github.com/aspnet/MusicStore/blob/dev/test/E2ETests/project.json