pristinesource / ElasticDatabaseToolsNetCore

ElasticScale DB modified for .Net Core
0 stars 1 forks source link

TryGetSqlShardMapManager returns exception #1

Open virtuesoft opened 7 years ago

virtuesoft commented 7 years ago

When calling TryGetSqlShardMapManager I get an error saying that the resources are not correctly embedded or linked into the assembly. See below:

My code:

bool shardMapManagerExists = ShardMapManagerFactory.TryGetSqlShardMapManager( shardMapManagerConnectionString, ShardMapManagerLoadPolicy.Lazy, out shardMapManager);

The exception details:

System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.ReadOnlyScripts.resources" was correctly embedded or linked into assembly "ElasticScaleNetCore.Client" at compile time, or that all the satellite assemblies required are loadable and fully signed. at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetString(String name, CultureInfo culture) at Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.SqlUtils.<>c.<.cctor>b__42_0() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.GetShardMapManagerGlobalOperation.DoGlobalExecute(IStoreTransactionScope ts) at Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.StoreOperationGlobal.<Do>b__10_0() at Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func1 func) at Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.StoreOperationGlobal.Do() at Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.ShardMapManagerFactory.GetSqlShardMapManager(String connectionString, ShardMapManagerLoadPolicy loadPolicy, RetryBehavior retryBehavior, EventHandler`1 retryEventHandler, Boolean throwOnFailure) at Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.ShardMapManagerFactory.TryGetSqlShardMapManager(String connectionString, ShardMapManagerLoadPolicy loadPolicy, RetryBehavior retryBehavior, ShardMapManager& shardMapManager) at CheckFlow.Data.ShardManagementUtils.CreateOrGetShardMapManager(String shardMapManagerConnectionString) at CheckFlow.Data.DataAccess.CreateShardMapManagerAndShard() at CheckFlow.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)} System.Resources.MissingManifestResourceException

thuru-zz commented 7 years ago

Same issue on both .NET 4.7 and .NET Core as well

206mph commented 7 years ago

I'm getting the same error as well in .NET Core.

206mph commented 7 years ago

Has anyone found a workaround for this?

thuru-zz commented 7 years ago

seems like the elastic pool development in the asp.net core is not active. I ended up handling this manually using custom code and switching the context in EFCore. https://thuru.net/2017/05/28/ef-core-with-azure-elastic-database-pool-on-net-framework/

thePmr commented 7 years ago

@206mph yes, there's a workaround.

Seems what happened with the project when you've opened it is described here – files .xproj and project.json have been converted to good old .csproj. The problem here is that resource files were expelled from project during this upgrade. What you need is to add them manually:

  1. Open .csproj with text editor.
  2. Copy the following in the end of this file, right before tag:

    
    ...
    <ItemGroup>
    <Compile Update="ShardManagement\Errors.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Errors.resx</DependentUpon>
    </Compile>
    <Compile Update="ShardManagement\PerformanceCounters.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>PerformanceCounters.resx</DependentUpon>
    </Compile>
    <Compile Update="ShardManagement\ReadOnlyScripts.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>ReadOnlyScripts.resx</DependentUpon>
    </Compile>
    <Compile Update="ShardManagement\Scripts.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Scripts.resx</DependentUpon>
    </Compile>
    </ItemGroup>
    
    <ItemGroup>
    <EmbeddedResource Update="ShardManagement\Errors.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Errors.Designer.cs</LastGenOutput>
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </EmbeddedResource>
    <EmbeddedResource Update="ShardManagement\PerformanceCounters.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>PerformanceCounters.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <EmbeddedResource Update="ShardManagement\ReadOnlyScripts.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>ReadOnlyScripts.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <EmbeddedResource Update="ShardManagement\Scripts.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Scripts.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    </ItemGroup>


3. Run the project from VS
4. May be you will need to regenerate resources. To do so: right click on each .resx file and select "Run custom tool".
PraisyA commented 6 years ago

Hello ,

I got same issue , is anybody got the solution . If you get solution please share with us .

I got below error today (after i upgraded to .NetCore2.0 ) .

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Microsoft.Azure.SqlDatabase.ElasticScaleNetCore.ShardManagement.ReadOnlyScripts.resources" was correctly embedded or linked into assembly "ElasticScaleNetCore.Client" at compile time, or that all the satellite assemblies required are loadable and fully signed.

Thanks.