src/Misc/EFTools/EntityDesign/VisualStudio/EdmUtils.cs
// <summary>
//     Return the EF Runtime assemblies path.
// </summary>
Return the EF Runtime assemblies path.
Return the EF Runtime assemblies path .
internal static string GetRuntimeAssemblyPath(Project project, IServiceProvider serviceProvider)
        {
            var hierarchy = VSHelpers.GetVsHierarchy(project, serviceProvider);
            var dtar = hierarchy as IVsDesignTimeAssemblyResolution;
            if (dtar != null)
            {
                for (var i = 0; i < 2; i++)
                {
                    var resolvedAssemblyPath = new VsResolvedAssemblyPath[1];
                    uint resolvedAssemblyPathCount;
                    if (dtar.ResolveAssemblyPathInTargetFx(
                        new string[1] { "System.Data.Entity" }, 1, resolvedAssemblyPath, out resolvedAssemblyPathCount) == VSConstants.S_OK)
                    {
                        if (resolvedAssemblyPathCount == 1)
                        {
                            return Path.GetDirectoryName(resolvedAssemblyPath[0].bstrResolvedAssemblyPath);
                        }
                    }
                }
            }
            else
            {
                var targetFrameworkMoniker = VsUtils.GetTargetFrameworkMonikerForProject(project, serviceProvider);
                var multiTargetingService =
                    Services.ServiceProvider.GetService(typeof(SVsFrameworkMultiTargeting)) as IVsFrameworkMultiTargeting;
                string assemblyPath;
                if (multiTargetingService.ResolveAssemblyPath("System.Data.Entity", targetFrameworkMoniker, out assemblyPath)
                    == VSConstants.S_OK)
                {
                    return Path.GetDirectoryName(assemblyPath);
                }
            }
            return String.Empty;
        }
internal static string GetRuntimeAssemblyPath ( Project project , IServiceProvider serviceProvider ) { var hierarchy = VSHelpers . GetVsHierarchy ( project , serviceProvider ) ; var dtar = hierarchy as IVsDesignTimeAssemblyResolution ; if ( dtar != null ) { for ( var i = 0 ; i < 2 ; i ++ ) { var resolvedAssemblyPath = new VsResolvedAssemblyPath [ 1 ] ; uint resolvedAssemblyPathCount ; if ( dtar . ResolveAssemblyPathInTargetFx ( new string [ 1 ] { " " } , 1 , resolvedAssemblyPath , out resolvedAssemblyPathCount ) == VSConstants . S_OK ) { if ( resolvedAssemblyPathCount == 1 ) { return Path . GetDirectoryName ( resolvedAssemblyPath [ 0 ] . bstrResolvedAssemblyPath ) ; } } } } else { var targetFrameworkMoniker = VsUtils . GetTargetFrameworkMonikerForProject ( project , serviceProvider ) ; var multiTargetingService = Services . ServiceProvider . GetService ( typeof ( SVsFrameworkMultiTargeting ) ) as IVsFrameworkMultiTargeting ; string assemblyPath ; if ( multiTargetingService . ResolveAssemblyPath ( " " , targetFrameworkMoniker , out assemblyPath ) == VSConstants . S_OK ) { return Path . GetDirectoryName ( assemblyPath ) ; } } return String . Empty ; }
Return the EF Runtime assemblies path.
Return the EF Runtime assemblies path .
// Get Project Design Time Assembly Resolution. // Don't call GetVsHierarchy(project) because it causes dependencies with EDM Package service provider. // There is a bug where the first time you call ResolveAssemblyPathInTargetFx, resolvedAssemblyPathCount is 0. // So we are going to try 1 more time if the first call not successful. // Project Design Time Assembly Resolution is not found, try Global Design Time Assembly Resolution. // if we could not resolve the asembly using global or project design time assembly resolution, return string empty.
project
Project
serviceProvider
IServiceProvider