none
Could not load type 'NuGet.NuGetConstants' from assembly'NuGet.VisualStudio'.

    Question

  • Hi

        I am facing below issue while Code First Reverse Engineering in VS2015 running against SQL Server 2012 database.

    Issue Details:

    System.TypeLoadException: Could not load type 'NuGet.NuGetConstants' from assembly 'NuGet.VisualStudio'.
       at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
       at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
       at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
       at System.Type.GetType(String typeName, Boolean throwOnError)
       at Microsoft.DbContextPackage.Extensions.ProjectExtensions.InstallPackage(Project project, String packageId)
       at Microsoft.DbContextPackage.Handlers.ReverseEngineerCodeFirstHandler.ReverseEngineerCodeFirst(Project project)

    One or more errors occurred while processing template 'Entity.tt'.
    error : An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
    System.ArgumentException: Empty path name is not legal.
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at System.IO.File.OpenRead(String path)
       at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
       at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
       at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Linq.Enumerable.<UnionIterator>d__66`1.MoveNext()
       at System.Linq.Enumerable.<UnionIterator>d__66`1.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
       at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1 items)
       at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
       at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
       at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable`1 newReferences)
       at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()
       at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()
       at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions)

    System.TypeLoadException: Could not load type 'NuGet.NuGetConstants' from assembly 'NuGet.VisualStudio'.
       at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
       at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
       at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
       at System.Type.GetType(String typeName, Boolean throwOnError)
       at Microsoft.DbContextPackage.Extensions.ProjectExtensions.InstallPackage(Project project, String packageId)
       at Microsoft.DbContextPackage.Handlers.ReverseEngineerCodeFirstHandler.ReverseEngineerCodeFirst(Project project)

    One or more errors occurred while processing template 'Entity.tt'.
    error : An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
    System.ArgumentException: Empty path name is not legal.
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at System.IO.File.OpenRead(String path)
       at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
       at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
       at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Linq.Enumerable.<UnionIterator>d__66`1.MoveNext()
       at System.Linq.Enumerable.<UnionIterator>d__66`1.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
       at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1 items)
       at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
       at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
       at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable`1 newReferences)
       at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()
       at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()
       at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions)

    Please help on this issue...

    Saturday, February 25, 2017 4:23 PM

All replies

  • After installing EntityFramework package from Nuget Package Manager and it's working for me...

    Saturday, February 25, 2017 5:30 PM
  • Hi Sudhakar Boina,

    Glad to know that you have resolved this issue. Please mark your answer which is benefit to other communities who has the same problem.


    MSDN Community Support<br/> Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.

    Monday, February 27, 2017 10:16 AM